Package org.loboevolution.img
Class PixelInfoStatusBar
java.lang.Object
org.loboevolution.img.StatusBar
org.loboevolution.img.PixelInfoStatusBar
- Direct Known Subclasses:
DefaultStatusBar
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal JComponentReturns the status bar component that can be added to the image viewer GUI.getModel()Returns the model storing the pixel shown by this status bar.protected voidregister(ImageViewer viewer) Called when this status bar is added to an image viewer.final voidsetModel(PixelModel newModel) Sets the model dictating the pixel shown by this status bar.voidsetPixel(int x, int y) Sets the pixel this status bar is to display information on.protected voidunregister(ImageViewer viewer) Called when this status bar is removed from an image viewer.protected final voidupdate()Updates the info label.protected voidupdateLabel(BufferedImage image, int x, int y, int availableWidth) This function updates the contents of thelabel.protected voidThis function updates the contents of thelabelto indicate that no data can be shown.Methods inherited from class org.loboevolution.img.StatusBar
getImageViewer, setImageViewer
-
Field Details
-
label
The label displaying the info text.
-
-
Constructor Details
-
PixelInfoStatusBar
public PixelInfoStatusBar()Creates a new instance.
-
-
Method Details
-
setModel
Sets the model dictating the pixel shown by this status bar.- Parameters:
newModel- the new model- Throws:
NullPointerException- in case of error ifnewModelisnull
-
getModel
Returns the model storing the pixel shown by this status bar.- Returns:
- the current model; never
null
-
getComponent
Returns the status bar component that can be added to the image viewer GUI.- Specified by:
getComponentin classStatusBar- 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 pixely- 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 thelabelto indicate that no data can be shown. By default, this function is called byupdatewhen the image isnullor the pixel to be shown is not within bounds. -
updateLabel
This function updates the contents of thelabel. It is called when the highlighted pixel or the image changes, and only when the image is notnulland the pixel is within the bounds of the image. If either of these conditions aren't true, theupdatefunction callsupdateLabelNoData()instead. Override it to provide a custom message.- Parameters:
image- the current image displayed in the viewerx- the x coordinate of the pixel that should be displayedy- the y coordinate of the pixel that should be displayedavailableWidth- 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
Called when this status bar is added to an image viewer. Subclasses can override this method to register listeners. -
unregister
Called when this status bar is removed from an image viewer. Subclasses can override this method to remove listeners.- Overrides:
unregisterin classStatusBar- Parameters:
viewer- the viewer that this status bar is removed from
-