ncsa.hdf.view
Class DefaultImageView

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

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

Version:
2.4 9/6/2007
Author:
Peter X. Cao
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JInternalFrame
javax.swing.JInternalFrame.JDesktopIcon
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
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.
static long serialVersionUID
           
 
Fields inherited from class javax.swing.JInternalFrame
CONTENT_PANE_PROPERTY, FRAME_ICON_PROPERTY, GLASS_PANE_PROPERTY, IS_CLOSED_PROPERTY, IS_ICON_PROPERTY, IS_MAXIMUM_PROPERTY, IS_SELECTED_PROPERTY, LAYERED_PANE_PROPERTY, MENU_BAR_PROPERTY, ROOT_PANE_PROPERTY, TITLE_PROPERTY
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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 ncsa.hdf.view.DataView
DATAVIEW_IMAGE, DATAVIEW_TABLE, DATAVIEW_TEXT, DATAVIEW_UNKNOWN
 
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.util.HashMap map)
          Constructs an ImageView.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 java.awt.Image createIndexedImage(byte[] imageData, byte[][] palette, int w, int h)
          Creates a RGB indexed image of 256 colors.
 java.awt.Image createTrueColorImage(byte[] imageData, boolean planeInterlace, int w, int h)
          Creates a true color image.
 void dispose()
          Disposes this datao viewer
 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
addInternalFrameListener, doDefaultCloseAction, getAccessibleContext, getContentPane, getDefaultCloseOperation, getDesktopIcon, getDesktopPane, getFocusCycleRootAncestor, getFocusOwner, getFrameIcon, getGlassPane, getInternalFrameListeners, getJMenuBar, getLastCursor, getLayer, getLayeredPane, getMenuBar, getMostRecentFocusOwner, getNormalBounds, getRootPane, getTitle, getUI, getUIClassID, getWarningString, hide, isClosable, isClosed, isFocusCycleRoot, isIcon, isIconifiable, isMaximizable, isMaximum, isResizable, isSelected, moveToBack, moveToFront, pack, remove, removeInternalFrameListener, reshape, restoreSubcomponentFocus, setClosable, setClosed, setContentPane, setCursor, setDefaultCloseOperation, setDesktopIcon, setFocusCycleRoot, setFrameIcon, setGlassPane, setIcon, setIconifiable, setJMenuBar, setLayer, setLayer, setLayeredPane, setLayout, setMaximizable, setMaximum, setMenuBar, setNormalBounds, setResizable, setSelected, setTitle, setUI, show, toBack, toFront, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, 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, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values

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.util.HashMap map)
Constructs an ImageView.

Parameters:
theView - the main HDFView.
map - the properties on how to show the data. The map is used to allow applications to pass properties on how to display the data, such as, transposing data, showing data as character, applying bitmask, and etc. Predefined keys are listed at ViewProperties.DATA_VIEW_KEY.
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 this datao viewer

Specified by:
dispose in interface DataView
Overrides:
dispose in class javax.swing.JInternalFrame

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 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 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.