jsky.image.gui
Class ImageDisplayPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by jsky.image.gui.ImageDisplayPanel
All Implemented Interfaces:
java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class ImageDisplayPanel
extends javax.swing.JPanel
implements java.awt.event.MouseMotionListener

An image display control panel.

Version:
$Revision: 1.1 $
Author:
Allan Brighton
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
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  javax.swing.JButton autocutButton
           
protected  int bitpix
          number of bits per pixel in source image
protected  javax.swing.JLabel bitpixLabel
           
protected  javax.swing.JLabel bitpixValue
           
protected  javax.swing.JLabel decLabel
           
protected  javax.swing.JLabel decValue
           
protected  javax.swing.JLabel equinoxLabel
           
protected  javax.swing.JLabel equinoxValue
           
protected  javax.swing.JLabel highLabel
           
protected  javax.swing.JTextField highValue
           
protected  MainImageDisplay imageDisplay
           
protected  ImageProcessor imageProcessor
           
protected  GridBagUtil layout
           
protected  javax.swing.JLabel lowLabel
           
protected  javax.swing.JTextField lowValue
           
protected  javax.swing.JLabel maxLabel
           
protected static int maxScale
           
protected  javax.swing.JLabel maxValue
           
protected  javax.swing.JLabel minLabel
           
protected static int minScale
           
protected  javax.swing.JLabel minValue
           
protected static java.text.NumberFormat nf
          Used to format pixel coordinates.
protected  javax.swing.JLabel objectLabel
           
protected  javax.swing.JLabel objectValue
           
protected  int orient
          panel orientation: one of SwingConstants.HORIZONTAL, .VERTICAL
protected  javax.swing.JLabel raLabel
           
protected  javax.swing.JLabel raValue
           
protected  javax.swing.JLabel scaleLabel
           
protected  javax.swing.JMenu scaleMenu
           
protected  javax.swing.JMenuBar scaleMenuBar
           
protected  javax.swing.JLabel valueLabel
           
protected  javax.swing.JLabel valueValue
           
protected  javax.swing.JLabel xLabel
           
protected  javax.swing.JLabel xValue
           
protected  javax.swing.JLabel yLabel
           
protected  javax.swing.JLabel yValue
           
protected  javax.swing.JButton zoomInButton
           
protected  javax.swing.JButton zoomOutButton
           
 
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
ImageDisplayPanel()
          Default constructor: must call setImageDisplay() later
ImageDisplayPanel(MainImageDisplay imageDisplay)
          Constructor: defaults to vertical layout
ImageDisplayPanel(MainImageDisplay imageDisplay, int orient)
          Create a panel for controlling the given image display
 
Method Summary
protected  void addScaleMenuItem(javax.swing.ButtonGroup group, java.lang.String label, float value)
          Add a radio button menu item to the scale menu and given group with the given label and scale value.
protected  void autoSetCutLevels()
          Automatically set the image cut levels based on the image data
 int getBitsPerPixel()
          Return the number of bits per pixel in the source image.
 MainImageDisplay getImageDisplay()
           
 java.lang.String getObjectName()
          Return the name of the source image, if known, otherwise an empty string.
 java.lang.String getScaleLabel(float value)
          Get the scale menu label for the given float scale factor.
protected  void horizontalPanelLayout()
          Combine the panel items in a horizontal layout
 void incScale(boolean zoomIn)
          Zoom the image in or out, depending on the given argument.
protected  void makePanelItems()
          Make the display panel items
protected  void makeScaleMenu()
          Add a menu with zoom settings
protected  void makeZoomButtons()
          Add buttons "Z" and "z" to zoom in and out by 1 factor.
 void mouseDragged(java.awt.event.MouseEvent e)
          Invoked when a mouse button is pressed on the image and then dragged.
 void mouseMoved(java.awt.event.MouseEvent e)
           
protected  void setCutLevels()
          Set the image cut levels according to the values in the low and high cut level fields.
 void setImageDisplay(MainImageDisplay imageDisplay)
          Set the ImageDisplay to work with
 void setScale(float value)
          Set the scale for the image to the given value and update the menu label.
protected  void updateValues()
          fill in the label and text field values, where known
protected  void verticalPanelLayout()
          Combine the panel items in a vertical layout
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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
 
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, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, 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

imageProcessor

protected ImageProcessor imageProcessor

imageDisplay

protected MainImageDisplay imageDisplay

layout

protected GridBagUtil layout

objectLabel

protected javax.swing.JLabel objectLabel

objectValue

protected javax.swing.JLabel objectValue

xLabel

protected javax.swing.JLabel xLabel

xValue

protected javax.swing.JLabel xValue

yLabel

protected javax.swing.JLabel yLabel

yValue

protected javax.swing.JLabel yValue

valueLabel

protected javax.swing.JLabel valueLabel

valueValue

protected javax.swing.JLabel valueValue

raLabel

protected javax.swing.JLabel raLabel

raValue

protected javax.swing.JLabel raValue

decLabel

protected javax.swing.JLabel decLabel

decValue

protected javax.swing.JLabel decValue

equinoxLabel

protected javax.swing.JLabel equinoxLabel

equinoxValue

protected javax.swing.JLabel equinoxValue

minLabel

protected javax.swing.JLabel minLabel

minValue

protected javax.swing.JLabel minValue

maxLabel

protected javax.swing.JLabel maxLabel

maxValue

protected javax.swing.JLabel maxValue

bitpixLabel

protected javax.swing.JLabel bitpixLabel

bitpixValue

protected javax.swing.JLabel bitpixValue

lowLabel

protected javax.swing.JLabel lowLabel

lowValue

protected javax.swing.JTextField lowValue

highLabel

protected javax.swing.JLabel highLabel

highValue

protected javax.swing.JTextField highValue

autocutButton

protected javax.swing.JButton autocutButton

scaleLabel

protected javax.swing.JLabel scaleLabel

scaleMenuBar

protected javax.swing.JMenuBar scaleMenuBar

scaleMenu

protected javax.swing.JMenu scaleMenu

zoomInButton

protected javax.swing.JButton zoomInButton

zoomOutButton

protected javax.swing.JButton zoomOutButton

minScale

protected static final int minScale
See Also:
Constant Field Values

maxScale

protected static final int maxScale
See Also:
Constant Field Values

orient

protected int orient
panel orientation: one of SwingConstants.HORIZONTAL, .VERTICAL


bitpix

protected int bitpix
number of bits per pixel in source image


nf

protected static java.text.NumberFormat nf
Used to format pixel coordinates.

Constructor Detail

ImageDisplayPanel

public ImageDisplayPanel(MainImageDisplay imageDisplay,
                         int orient)
Create a panel for controlling the given image display


ImageDisplayPanel

public ImageDisplayPanel(MainImageDisplay imageDisplay)
Constructor: defaults to vertical layout


ImageDisplayPanel

public ImageDisplayPanel()
Default constructor: must call setImageDisplay() later

Method Detail

setImageDisplay

public void setImageDisplay(MainImageDisplay imageDisplay)
Set the ImageDisplay to work with


getImageDisplay

public MainImageDisplay getImageDisplay()

makePanelItems

protected void makePanelItems()
Make the display panel items


makeScaleMenu

protected void makeScaleMenu()
Add a menu with zoom settings


addScaleMenuItem

protected void addScaleMenuItem(javax.swing.ButtonGroup group,
                                java.lang.String label,
                                float value)
Add a radio button menu item to the scale menu and given group with the given label and scale value.


setScale

public void setScale(float value)
Set the scale for the image to the given value and update the menu label.


getScaleLabel

public java.lang.String getScaleLabel(float value)
Get the scale menu label for the given float scale factor.


incScale

public void incScale(boolean zoomIn)
Zoom the image in or out, depending on the given argument.


makeZoomButtons

protected void makeZoomButtons()
Add buttons "Z" and "z" to zoom in and out by 1 factor.


horizontalPanelLayout

protected void horizontalPanelLayout()
Combine the panel items in a horizontal layout


verticalPanelLayout

protected void verticalPanelLayout()
Combine the panel items in a vertical layout


updateValues

protected void updateValues()
fill in the label and text field values, where known


getObjectName

public java.lang.String getObjectName()
Return the name of the source image, if known, otherwise an empty string. (XXX or the file name, or URL, ... ?)


getBitsPerPixel

public int getBitsPerPixel()
Return the number of bits per pixel in the source image. Floating point images are denoted by -32 for float, or -64 for double.


setCutLevels

protected void setCutLevels()
Set the image cut levels according to the values in the low and high cut level fields.


autoSetCutLevels

protected void autoSetCutLevels()
Automatically set the image cut levels based on the image data


mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Invoked when a mouse button is pressed on the image and then dragged.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

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