Class PixelInfoStatusBar

java.lang.Object
org.loboevolution.img.StatusBar
org.loboevolution.img.PixelInfoStatusBar
Direct Known Subclasses:
DefaultStatusBar

public class PixelInfoStatusBar extends StatusBar
A status bar implementation that display information based on a pixel of the image. Call the setPixel(int, int) function to specify which pixel it should display. The current implementation shows the position and color of the pixel; override updateLabel(java.awt.image.BufferedImage, int, int, int) to customize this information. Author Kazo Csaba
  • Field Details

    • label

      protected final JLabel label
      The label displaying the info text.
  • Constructor Details

    • PixelInfoStatusBar

      public PixelInfoStatusBar()
      Creates a new instance.
  • Method Details

    • setModel

      public final void setModel(PixelModel newModel)
      Sets the model dictating the pixel shown by this status bar.
      Parameters:
      newModel - the new model
      Throws:
      NullPointerException - in case of error if newModel is null
    • getModel

      public PixelModel getModel()
      Returns the model storing the pixel shown by this status bar.
      Returns:
      the current model; never null
    • getComponent

      public final JComponent getComponent()
      Returns the status bar component that can be added to the image viewer GUI.
      Specified by:
      getComponent in class StatusBar
      Returns:
      the status bar component
    • setPixel

      public void setPixel(int x, int y)
      Sets the pixel this status bar is to display information on. The values may be arbitrary; you can use negative values to indicate that there is nothing to display.
      Parameters:
      x - the x coordinate of the pixel
      y - the y coordinate of the pixel
    • update

      protected final void update()
      Updates the info label. This function is called when either the selected pixel or the image shown in the viewer is changed. You can call this method to indicate that the message should be updated for some different reason.
    • updateLabelNoData

      protected void updateLabelNoData()
      This function updates the contents of the label to indicate that no data can be shown. By default, this function is called by update when the image is null or the pixel to be shown is not within bounds.
    • updateLabel

      protected void updateLabel(BufferedImage image, int x, int y, int availableWidth)
      This function updates the contents of the label. It is called when the highlighted pixel or the image changes, and only when the image is not null and the pixel is within the bounds of the image. If either of these conditions aren't true, the update function calls updateLabelNoData() instead. Override it to provide a custom message.
      Parameters:
      image - the current image displayed in the viewer
      x - the x coordinate of the pixel that should be displayed
      y - the y coordinate of the pixel that should be displayed
      availableWidth - the maximum label width that can be displayed; you can use this parameter to specify a shorter message if there is not enough room
    • register

      protected void register(ImageViewer viewer)
      Called when this status bar is added to an image viewer. Subclasses can override this method to register listeners.
      Overrides:
      register in class StatusBar
      Parameters:
      viewer - the new viewer associated with this status bar
    • unregister

      protected void unregister(ImageViewer viewer)
      Called when this status bar is removed from an image viewer. Subclasses can override this method to remove listeners.
      Overrides:
      unregister in class StatusBar
      Parameters:
      viewer - the viewer that this status bar is removed from