public class DivaGraphicsImageDisplay extends JCanvas implements GraphicsImageDisplay
Any JAI PlanarImage can be displayed. Grayscale images may be displayed with false colors, depending on the ImageProcessor options specified.
This class also provides methods for converting image coordinates. See the CoordinateConverter interface for details. World coordinates are supported if the information is present in the header (for FITS files).
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
NO_SUCH_PAGE, PAGE_EXISTS
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
DivaGraphicsImageDisplay()
Construct an image display widget.
|
DivaGraphicsImageDisplay(GraphicsPane pane,
ImageProcessor imageProcessor,
String name)
Construct an image display widget with the given graphics pane and name to display
the output of the given image processor.
|
DivaGraphicsImageDisplay(ImageProcessor imageProcessor,
String name)
Construct an image display widget with the given name to display
the output of the given image processor.
|
DivaGraphicsImageDisplay(String name)
Construct an image display widget with the given name.
|
Modifier and Type | Method and Description |
---|---|
protected double |
_getPixelValue(javax.media.jai.PlanarImage im,
int ix,
int iy,
int w,
int h,
int band)
Return the value of the pixel in the given band at the given user coordinates
|
void |
addImageGraphicsHandler(ImageGraphicsHandler igh)
Register as an image graphics handler.
|
void |
blankImage(double ra,
double dec)
Display a blank image with the given center coordinates
(15' * 60 seconds/minutes).
|
protected void |
centerImage(javax.media.jai.PlanarImage im)
If a new image was just loaded, center the image in it's window,
otherwise only center it if it is smaller than the display window.
|
void |
clear()
Clear the image display.
|
protected AffineTransform |
getAffineTransform()
Return an AffineTransform based on the current transformations.
|
JComponent |
getCanvas()
Return the image canvas component.
|
CanvasGraphics |
getCanvasGraphics()
Return an object to be used for drawing persistent graphics over the image
|
CoordinateConverter |
getCoordinateConverter()
Return the object used to convert coordinates.
|
javax.media.jai.PlanarImage |
getDisplayImage()
Return the image being displayed (after image processing).
|
FITSImage |
getFitsImage()
If the current image is in FITS format, return the FITSImage object managing it,
otherwise return null.
|
javax.media.jai.PlanarImage |
getImage()
Return the source image (before processing).
|
int |
getImageHeight()
Return the height of the source image in pixels
|
ImageProcessor |
getImageProcessor()
Return the image processor object.
|
int |
getImageWidth()
Return the width of the source image in pixels
|
javax.media.jai.Interpolation |
getInterpolation()
Return the interpolation object used to scale the image
|
Point2D.Double |
getOrigin()
Return the origin of the displayed image in canvas coordinates.
|
double |
getPixelValue(Point2D.Double p,
int band)
Return the value of the pixel in the given band at the given user coordinates
|
double[] |
getPixelValues(Rectangle region,
int band)
Return an array containing the values of the pixels in the given band in the given
user coordinates region.
|
float |
getScale()
Return the current scale (zoom factor) for the image.
|
RenderingHints |
getScaleHints()
Return the optional rendering hints used for the image scale operation
|
Rectangle2D.Double |
getVisibleArea()
Return a rectangle describing the visible area of the image
(in user coordinates).
|
WorldCoordinateConverter |
getWCS()
Return the object used to convert between image and world coordinates,
or null if none was set.
|
protected void |
initWCS()
Initialize the world coordinate system, if the image properties (keywords) support it
|
boolean |
isAutoCenterImage()
Return true if the image is automatically centered when it is smaller than the window.
|
boolean |
isClear()
Return true if the image has been cleared.
|
boolean |
isImmediateMode()
Return true if immediate mode is turned on.
|
boolean |
isInitialized()
Return true if this widget has been initialized and is displaying an image.
|
boolean |
isPrescaled()
Return true if the image has been prescaled
|
boolean |
isWCS()
Return true if the image supports world coordinates (has the necessary keywords in the
header).
|
static void |
main(String[] args)
test main: usage: java DivaGraphicsImageDisplay
|
protected CanvasGraphics |
makeCanvasGraphics()
Make and return the CanvasGraphics object.
|
protected void |
newImage(boolean before)
This method is called before and after loading a new image.
|
protected void |
notifyGraphicsHandlers(Graphics2D g)
Notify any ImageGraphicsHandlers
|
void |
paintLayer(Graphics2D g2D,
Rectangle2D region)
Paint the image onto a Graphics object.
|
void |
removeImageGraphicsHandler(ImageGraphicsHandler igh)
Unregister as an image graphics handler.
|
protected javax.media.jai.PlanarImage |
scale(javax.media.jai.PlanarImage im)
Perform a translate/scale operation on the given image using the current
settings and return the resulting image.
|
void |
scaleToFit()
Set the scaling factor so that the image will fit in the current window.
|
protected void |
scaleToFit(int width,
int height)
Set the scaling factor so that the image will fit in a window of the
given size.
|
void |
setAutoCenterImage(boolean b)
Set to true (default) to automatically center the image, if it is smaller than the window.
|
void |
setImage(FITSImage fitsImage)
Set the FITS image to display.
|
void |
setImage(javax.media.jai.PlanarImage im)
Set the image to display.
|
void |
setImageProcessor(ImageProcessor imageProcessor)
Set the image processor to use to get the image to display.
|
void |
setImmediateMode(boolean b)
Set to true if scrolling and other operations should update the image immediately,
otherwise only on button release.
|
void |
setInterpolation(javax.media.jai.Interpolation i)
Set the interpolation object used to scale the image (a subclass
of Interpolation, such as InterpolationNearest (default), or
InterpolationBilinear (better, but slower)).
|
void |
setOrigin(Point2D.Double origin)
Set the origin of the image to display in canvas coordinates.
|
void |
setPrescaled(boolean b)
Set to true if the image being displayed has been prescaled (such as
for a pan window or thumbnail image).
|
void |
setScale(float scale)
Set the scale (zoom factor) for the image.
|
void |
setScaleHints(RenderingHints hints)
Set the optional rendering hints for the image scale operation
|
void |
setWCS(WorldCoordinateConverter wcs)
Set the object used to convert between image and world coordinates.
|
protected void |
transformGraphics()
Transform the graphics in the foreground layer according to the current
image transformations.
|
protected void |
transformGraphics(AffineTransform trans)
Transform the image graphics using the given AffineTransform.
|
void |
updateImage()
Called when the image has changed to update the display
|
protected void |
updateImage(javax.media.jai.PlanarImage im)
This method updates the source image for this window, which is
scaled to the correct magnification before displaying.
|
getCanvasPane, getToolTipText, isFocusTraversable, paintComponent, print, print, processMouseEvent, processMouseMotionEvent, repaint, setCanvasPane, setDoubleBuffered, setPreferredSize
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public DivaGraphicsImageDisplay(GraphicsPane pane, ImageProcessor imageProcessor, String name)
pane
- the Diva GraphicsPane to use (contains the layers used to display the
image and graphics)imageProcessor
- Object managing the imagename
- name to associate with this instancepublic DivaGraphicsImageDisplay(ImageProcessor imageProcessor, String name)
imageProcessor
- Object managing the imagename
- name to associate with this instancepublic DivaGraphicsImageDisplay(String name)
name
- name to associate with this instancepublic DivaGraphicsImageDisplay()
protected CanvasGraphics makeCanvasGraphics()
public javax.media.jai.PlanarImage getImage()
getImage
in interface BasicImageDisplay
public javax.media.jai.PlanarImage getDisplayImage()
getDisplayImage
in interface BasicImageDisplay
public CoordinateConverter getCoordinateConverter()
getCoordinateConverter
in interface BasicImageDisplay
public CanvasGraphics getCanvasGraphics()
getCanvasGraphics
in interface GraphicsImageDisplay
public void setImageProcessor(ImageProcessor imageProcessor)
setImageProcessor
in interface BasicImageDisplay
public ImageProcessor getImageProcessor()
getImageProcessor
in interface BasicImageReadableProcessor
getImageProcessor
in interface BasicImageDisplay
PlanarImage
public void setImage(javax.media.jai.PlanarImage im)
setImage
in interface BasicImageDisplay
public void setImage(FITSImage fitsImage)
public int getImageWidth()
getImageWidth
in interface BasicImageDisplay
public int getImageHeight()
getImageHeight
in interface BasicImageDisplay
public FITSImage getFitsImage()
getFitsImage
in interface GraphicsImageDisplay
protected void newImage(boolean before)
before
- If true, it is before loading the image, otherwise afterwards.protected void initWCS()
public boolean isWCS()
isWCS
in interface BasicImageDisplay
public WorldCoordinateConverter getWCS()
getWCS
in interface BasicImageDisplay
public void setWCS(WorldCoordinateConverter wcs)
setWCS
in interface BasicImageDisplay
public void clear()
clear
in interface GraphicsImageDisplay
public boolean isClear()
isClear
in interface GraphicsImageDisplay
public void blankImage(double ra, double dec)
blankImage
in interface GraphicsImageDisplay
ra
- RA center coordinate in deg J2000dec
- Dec center coordinate in deg J2000public void updateImage()
updateImage
in interface BasicImageDisplay
protected void updateImage(javax.media.jai.PlanarImage im)
public void setAutoCenterImage(boolean b)
setAutoCenterImage
in interface BasicImageDisplay
public boolean isAutoCenterImage()
isAutoCenterImage
in interface BasicImageDisplay
protected void centerImage(javax.media.jai.PlanarImage im)
public void paintLayer(Graphics2D g2D, Rectangle2D region)
g2D
- the graphics contextregion
- if not null, the region to paintpublic void addImageGraphicsHandler(ImageGraphicsHandler igh)
addImageGraphicsHandler
in interface BasicImageDisplay
public void removeImageGraphicsHandler(ImageGraphicsHandler igh)
removeImageGraphicsHandler
in interface BasicImageDisplay
protected void notifyGraphicsHandlers(Graphics2D g)
public void setOrigin(Point2D.Double origin)
setOrigin
in interface BasicImageDisplay
public Point2D.Double getOrigin()
getOrigin
in interface BasicImageDisplay
public JComponent getCanvas()
getCanvas
in interface BasicImageDisplay
public void setScale(float scale)
setScale
in interface BasicImageDisplay
public float getScale()
getScale
in interface BasicImageDisplay
public void setInterpolation(javax.media.jai.Interpolation i)
setInterpolation
in interface BasicImageDisplay
public javax.media.jai.Interpolation getInterpolation()
getInterpolation
in interface BasicImageDisplay
public double getPixelValue(Point2D.Double p, int band)
getPixelValue
in interface BasicImageDisplay
getPixelValue
in interface GraphicsImageDisplay
p
- the user coordinates of the point to getband
- the bad of the image (0 for FITS files)protected double _getPixelValue(javax.media.jai.PlanarImage im, int ix, int iy, int w, int h, int band)
im
- the (rescaled) image to get the value fromix
- the X user coordinate of the point to getiy
- the Y user coordinate of the point to getw
- the width of the image in user coordinat pixelsh
- the height of the image in user coordinat pixelsband
- the bad of the image (0 for FITS files)public double[] getPixelValues(Rectangle region, int band)
getPixelValues
in interface GraphicsImageDisplay
region
- describes the region of the image to get in user coordinatesband
- the band of the image to getpublic void setPrescaled(boolean b)
setPrescaled
in interface BasicImageDisplay
public boolean isPrescaled()
isPrescaled
in interface BasicImageDisplay
public void setScaleHints(RenderingHints hints)
setScaleHints
in interface BasicImageDisplay
public RenderingHints getScaleHints()
getScaleHints
in interface BasicImageDisplay
protected javax.media.jai.PlanarImage scale(javax.media.jai.PlanarImage im)
protected void transformGraphics()
protected void transformGraphics(AffineTransform trans)
protected AffineTransform getAffineTransform()
protected void scaleToFit(int width, int height)
Note that only integer scaling factors are used, for example 2, 1, 1/2, 1/3, etc., for performance reasons.
public void scaleToFit()
Note that only integer scaling factors are used, for example 2, 1, 1/2, 1/3, etc., for performance reasons.
scaleToFit
in interface BasicImageDisplay
public Rectangle2D.Double getVisibleArea()
getVisibleArea
in interface BasicImageReadableProcessor
getVisibleArea
in interface BasicImageDisplay
public boolean isInitialized()
isInitialized
in interface BasicImageDisplay
public void setImmediateMode(boolean b)
setImmediateMode
in interface BasicImageDisplay
public boolean isImmediateMode()
isImmediateMode
in interface BasicImageDisplay
public static void main(String[] args)
Copyright © 2023 Central Laboratory of the Research Councils. All Rights Reserved.