public class PixelInfoStatusBar extends StatusBar
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.| Modifier and Type | Field and Description |
|---|---|
protected JLabel |
label
The label displaying the info text.
|
| Constructor and Description |
|---|
PixelInfoStatusBar()
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
JComponent |
getComponent()
Returns the status bar component that can be added to the image viewer GUI.
|
PixelModel |
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.
|
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 void |
update()
Updates the info label.
|
protected void |
updateLabel(BufferedImage image,
int x,
int y,
int availableWidth)
This function updates the contents of the
label. |
protected void |
updateLabelNoData()
This function updates the contents of the
label to indicate that no data can be shown. |
getImageViewerprotected final JLabel label
public final void setModel(PixelModel newModel)
newModel - the new modelNullPointerException - if newModel is nullpublic PixelModel getModel()
nullpublic final JComponent getComponent()
StatusBargetComponent in class StatusBarpublic void setPixel(int x,
int y)
x - the x coordinate of the pixely - the y coordinate of the pixelprotected final void update()
protected void updateLabelNoData()
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.protected void updateLabel(BufferedImage image, int x, int y, int availableWidth)
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.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 roomprotected void register(ImageViewer viewer)
StatusBarprotected void unregister(ImageViewer viewer)
StatusBarunregister in class StatusBarviewer - the viewer that this status bar is removed fromCopyright © 2012. All Rights Reserved.