commandline.ImageTools
Class ImageDisplay

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by commandline.ImageTools.ImageDisplay
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener
Direct Known Subclasses:
MyImageDisplay

public class ImageDisplay
extends javax.swing.JComponent
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

An output widget for a PlanarImage. ImageDisplay subclasses javax.swing.JComponent, and can be used in any context that calls for a JComponent. It monitors resize and update events and automatically requests tiles from its source on demand.

Due to the limitations of BufferedImage, only TYPE_BYTE of band 1, 2, 3, 4, and TYPE_USHORT of band 1, 2, 3 images can be displayed using this widget.

Author:
Daniel Rice, Dennis Sigel
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.awt.image.BufferedImageOp biop
          Brightness control
protected  int brightness
           
protected  boolean brightnessEnabled
           
protected  java.awt.image.ColorModel colorModel
          The image's ColorModel or one we supply.
protected  int componentHeight
           
protected  int componentWidth
           
protected  byte[] lutData
           
protected  int maxTileX
          The image's max X tile.
protected  int maxTileY
          The image's max Y tile.
protected  int minTileX
          The image's min X tile.
protected  int minTileY
          The image's min Y tile.
protected  javax.swing.JLabel odometer
           
protected  int originX
           
protected  int originY
           
protected  java.awt.image.SampleModel sampleModel
          The image's SampleModel.
protected  int shift_x
           
protected  int shift_y
           
protected  PlanarImage source
          The source PlanarImage.
protected  int tileGridXOffset
          The image's tile grid X offset.
protected  int tileGridYOffset
          The image's tile grid Y offset.
protected  int tileHeight
          The image's tile height.
protected  int tileWidth
          The image's tile width.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ImageDisplay()
          Default constructor
ImageDisplay(int width, int height)
          Constructs an ImageDisplay of fixed size (no image)
ImageDisplay(PlanarImage im)
          Constructs an ImageDisplay to display a PlanarImage.
 
Method Summary
 boolean getBrightnessEnabled()
           
 PlanarImage getImage()
           
 javax.swing.JLabel getOdometer()
           
 int getXOrigin()
           
 int getYOrigin()
           
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void paintComponent(java.awt.Graphics g)
          Paint the image onto a Graphics object.
 void set(PlanarImage im)
          Changes the source image to a new PlanarImage.
 void set(PlanarImage im, int x, int y)
           
 void setBounds(int x, int y, int width, int height)
          Records a new size.
 void setBrightness(int b)
           
 void setBrightnessEnabled(boolean v)
           
 void setLocation(int x, int y)
           
 void setOrigin(int x, int y)
          Provides panning
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, 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, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, 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, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
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, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
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, 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, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, 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, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

source

protected PlanarImage source
The source PlanarImage.


sampleModel

protected java.awt.image.SampleModel sampleModel
The image's SampleModel.


colorModel

protected java.awt.image.ColorModel colorModel
The image's ColorModel or one we supply.


minTileX

protected int minTileX
The image's min X tile.


maxTileX

protected int maxTileX
The image's max X tile.


minTileY

protected int minTileY
The image's min Y tile.


maxTileY

protected int maxTileY
The image's max Y tile.


tileWidth

protected int tileWidth
The image's tile width.


tileHeight

protected int tileHeight
The image's tile height.


tileGridXOffset

protected int tileGridXOffset
The image's tile grid X offset.


tileGridYOffset

protected int tileGridYOffset
The image's tile grid Y offset.


originX

protected int originX

originY

protected int originY

shift_x

protected int shift_x

shift_y

protected int shift_y

odometer

protected javax.swing.JLabel odometer

componentWidth

protected int componentWidth

componentHeight

protected int componentHeight

biop

protected java.awt.image.BufferedImageOp biop
Brightness control


brightnessEnabled

protected boolean brightnessEnabled

brightness

protected int brightness

lutData

protected byte[] lutData
Constructor Detail

ImageDisplay

public ImageDisplay()
Default constructor


ImageDisplay

public ImageDisplay(PlanarImage im)
Constructs an ImageDisplay to display a PlanarImage.

Parameters:
source - a PlanarImage to be displayed.

ImageDisplay

public ImageDisplay(int width,
                    int height)
Constructs an ImageDisplay of fixed size (no image)

Parameters:
width - - display width
height - - display height
Method Detail

set

public void set(PlanarImage im)
Changes the source image to a new PlanarImage.


set

public void set(PlanarImage im,
                int x,
                int y)

getImage

public PlanarImage getImage()

getOdometer

public final javax.swing.JLabel getOdometer()

setOrigin

public final void setOrigin(int x,
                            int y)
Provides panning


getXOrigin

public int getXOrigin()

getYOrigin

public int getYOrigin()

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Records a new size. Called by the AWT.

Overrides:
setBounds in class java.awt.Component

setLocation

public void setLocation(int x,
                        int y)
Overrides:
setLocation in class java.awt.Component

setBrightnessEnabled

public final void setBrightnessEnabled(boolean v)

getBrightnessEnabled

public final boolean getBrightnessEnabled()

setBrightness

public final void setBrightness(int b)

paintComponent

public void paintComponent(java.awt.Graphics g)
Paint the image onto a Graphics object. The painting is performed tile-by-tile, and includes a grey region covering the unused portion of image tiles as well as the general background. At this point the image must be byte data.

Overrides:
paintComponent in class javax.swing.JComponent

mouseEntered

public final void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public final void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public final void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseClicked

public final void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseMoved

public final void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseDragged

public final void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener