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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal JComponent
Returns 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 void
register
(ImageViewer viewer) Called when this status bar is added to an image viewer.final void
setModel
(PixelModel newModel) Sets the model dictating the pixel shown by this status bar.void
setPixel
(int x, int y) Sets the pixel this status bar is to display information on.protected void
unregister
(ImageViewer viewer) Called when this status bar is removed from an image viewer.protected final void
update()
Updates the info label.protected void
updateLabel
(BufferedImage image, int x, int y, int availableWidth) This function updates the contents of thelabel
.protected void
This function updates the contents of thelabel
to 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 ifnewModel
isnull
-
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:
getComponent
in 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 thelabel
to indicate that no data can be shown. By default, this function is called byupdate
when the image isnull
or 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 notnull
and the pixel is within the bounds of the image. If either of these conditions aren't true, theupdate
function 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:
unregister
in classStatusBar
- Parameters:
viewer
- the viewer that this status bar is removed from
-