ncsa.hdf.view
Class DefaultImageView

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JInternalFrame
                  extended byncsa.hdf.view.DefaultImageView
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, DataView, java.util.EventListener, java.awt.image.ImageObserver, ImageView, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public class DefaultImageView
extends javax.swing.JInternalFrame
implements ImageView, java.awt.event.ActionListener

ImageView displays an HDF dataset as an image.

A scalar dataset in HDF can be displayed in image or table. By default, an HDF4 GR image and HDF5 image is displayed as an image. Other scalar datasets are display in a two-dimensional table.

Users can also choose to display a scalar dataset as image. Currently verion of the ImageView only supports 8-bit raster image with indexed RGB color model of 256 colors or 24-bit true color raster image. Data of other type will be converted to 8-bit integer. The simple linear conversion is used for this purpose:

      y = f * (x - min),
      where y   = the value of 8-bit integer,
            x   = the value of original data,
            f   = 255/(max-min), conversion factor,
            max = the maximum of the original data,
            min = the minimum of the original data.
  

A default color table is provided for images without palette attached to it. Current choice of default palettes include Gray, Rainbow, Nature and Wave. For more infomation on palette, read HDF5 Image and Palette Specification

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JInternalFrame
javax.swing.JInternalFrame.AccessibleJInternalFrame, javax.swing.JInternalFrame.JDesktopIcon
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int FLIP_HORIZONTAL
          Horizontal direction to flip an image.
static int FLIP_VERTICAL
          Vertical direction to flip an image.
static int ROTATE_CCW_90
          ROTATE IMAGE COUNTER CLOCKWISE 90 DEGREE.
static int ROTATE_CW_90
          ROTATE IMAGE 90 DEGREE CLOCKWISE.
 
Fields inherited from class javax.swing.JInternalFrame
closable, CONTENT_PANE_PROPERTY, desktopIcon, FRAME_ICON_PROPERTY, frameIcon, GLASS_PANE_PROPERTY, iconable, IS_CLOSED_PROPERTY, IS_ICON_PROPERTY, IS_MAXIMUM_PROPERTY, IS_SELECTED_PROPERTY, isClosed, isIcon, isMaximum, isSelected, LAYERED_PANE_PROPERTY, maximizable, MENU_BAR_PROPERTY, resizable, ROOT_PANE_PROPERTY, rootPane, rootPaneCheckingEnabled, title, TITLE_PROPERTY
 
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 javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DefaultImageView(ViewManager theView)
          Constructs an ImageView.
DefaultImageView(ViewManager theView, java.lang.Boolean _isTransposed)
          Constructs an ImageView.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
static java.awt.Image createIndexedImage(byte[] imageData, byte[][] palette, int w, int h)
          Creates a RGB indexed image of 256 colors.
static java.awt.Image createTrueColorImage(byte[] imageData, boolean planeInterlace, int w, int h)
          Creates a true color image.
 void dispose()
          Disposes of this dataobserver.
 HObject getDataObject()
          returns the data object displayed in this data viewer
 java.awt.Image getImage()
          returns the image displayed in this imageView
 byte[] getImageByteData()
          returns the byte array of the image data
 byte[][] getPalette()
          returns the palette of the image
 java.awt.Rectangle getSelectedArea()
          returns the selected area of the image
 java.lang.Object getSelectedData()
          Returns the selected data values.
 boolean isPlaneInterlace()
           
 boolean isTrueColor()
           
 void setImage(java.awt.Image img)
          sets the image
 void setPalette(byte[][] pal)
          sets the image palette
 
Methods inherited from class javax.swing.JInternalFrame
addImpl, addInternalFrameListener, createRootPane, doDefaultCloseAction, fireInternalFrameEvent, getAccessibleContext, getContentPane, getDefaultCloseOperation, getDesktopIcon, getDesktopPane, getFocusCycleRootAncestor, getFocusOwner, getFrameIcon, getGlassPane, getInternalFrameListeners, getJMenuBar, getLayer, getLayeredPane, getMenuBar, getMostRecentFocusOwner, getNormalBounds, getRootPane, getTitle, getUI, getUIClassID, getWarningString, hide, isClosable, isClosed, isFocusCycleRoot, isIcon, isIconifiable, isMaximizable, isMaximum, isResizable, isRootPaneCheckingEnabled, isSelected, moveToBack, moveToFront, pack, paintComponent, paramString, remove, removeInternalFrameListener, reshape, restoreSubcomponentFocus, setClosable, setClosed, setContentPane, setDefaultCloseOperation, setDesktopIcon, setFocusCycleRoot, setFrameIcon, setGlassPane, setIcon, setIconifiable, setJMenuBar, setLayer, setLayer, setLayeredPane, setLayout, setMaximizable, setMaximum, setMenuBar, setNormalBounds, setResizable, setRootPane, setRootPaneCheckingEnabled, setSelected, setTitle, setUI, show, toBack, toFront, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FLIP_HORIZONTAL

public static final int FLIP_HORIZONTAL
Horizontal direction to flip an image.

See Also:
Constant Field Values

FLIP_VERTICAL

public static final int FLIP_VERTICAL
Vertical direction to flip an image.

See Also:
Constant Field Values

ROTATE_CW_90

public static final int ROTATE_CW_90
ROTATE IMAGE 90 DEGREE CLOCKWISE.

See Also:
Constant Field Values

ROTATE_CCW_90

public static final int ROTATE_CCW_90
ROTATE IMAGE COUNTER CLOCKWISE 90 DEGREE.

See Also:
Constant Field Values
Constructor Detail

DefaultImageView

public DefaultImageView(ViewManager theView)
Constructs an ImageView.

Parameters:
theView - the main HDFView.

DefaultImageView

public DefaultImageView(ViewManager theView,
                        java.lang.Boolean _isTransposed)
Constructs an ImageView.

Parameters:
theView - the main HDFView.
Method Detail

getImage

public java.awt.Image getImage()
Description copied from interface: ImageView
returns the image displayed in this imageView

Specified by:
getImage in interface ImageView

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

dispose

public void dispose()
Description copied from interface: DataView
Disposes of this dataobserver.

Specified by:
dispose in interface DataView

getDataObject

public HObject getDataObject()
Description copied from interface: DataView
returns the data object displayed in this data viewer

Specified by:
getDataObject in interface DataView

getImageByteData

public byte[] getImageByteData()
Description copied from interface: ImageView
returns the byte array of the image data

Specified by:
getImageByteData in interface ImageView

getSelectedData

public java.lang.Object getSelectedData()
Returns the selected data values.

Specified by:
getSelectedData in interface ImageView
Returns:
the selected data object.

getSelectedArea

public java.awt.Rectangle getSelectedArea()
returns the selected area of the image

Specified by:
getSelectedArea in interface ImageView
Returns:
the rectangle of the selected image area.

isTrueColor

public boolean isTrueColor()
Specified by:
isTrueColor in interface ImageView
Returns:
true if the image is a truecolor image.

isPlaneInterlace

public boolean isPlaneInterlace()
Specified by:
isPlaneInterlace in interface ImageView
Returns:
true if the image interlace is plance interlace.

setImage

public void setImage(java.awt.Image img)
Description copied from interface: ImageView
sets the image

Specified by:
setImage in interface ImageView

getPalette

public byte[][] getPalette()
Description copied from interface: ImageView
returns the palette of the image

Specified by:
getPalette in interface ImageView

setPalette

public void setPalette(byte[][] pal)
Description copied from interface: ImageView
sets the image palette

Specified by:
setPalette in interface ImageView

createIndexedImage

public static java.awt.Image createIndexedImage(byte[] imageData,
                                                byte[][] palette,
                                                int w,
                                                int h)
Creates a RGB indexed image of 256 colors.

Parameters:
imageData - the byte array of the image data.
palette - the color lookup table.
w - the width of the image.
h - the height of the image.
Returns:
the image.

createTrueColorImage

public static java.awt.Image createTrueColorImage(byte[] imageData,
                                                  boolean planeInterlace,
                                                  int w,
                                                  int h)
Creates a true color image.

DirectColorModel is used to construct the image from raw data. The DirectColorModel model is similar to an X11 TrueColor visual, which has the following parameters:

            Number of bits:        32
            Red mask:              0x00ff0000
            Green mask:            0x0000ff00
            Blue mask:             0x000000ff
            Alpha mask:            0xff000000
            Color space:           sRGB
            isAlphaPremultiplied:  False
            Transparency:          Transparency.TRANSLUCENT
            transferType:          DataBuffer.TYPE_INT
        

The data may be arranged in one of two ways: by pixel or by plane. In both cases, the dataset will have a dataspace with three dimensions, height, width, and components.

For HDF4, the interlace modes specify orders for the dimensions as:

           INTERLACE_PIXEL = [width][height][pixel components]
           INTERLACE_PLANE = [pixel components][width][height]
       

For HDF5, the interlace modes specify orders for the dimensions as:

           INTERLACE_PIXEL = [height][width][pixel components]
           INTERLACE_PLANE = [pixel components][height][width]
       

Parameters:
imageData - the byte array of the image data.
planeInterlace - flag if the image is plane intelace.
w - the width of the image.
h - the height of the image.
Returns:
the image.