fr.esrf.tangoatk.widget.attribute
Class RawImageViewer

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 fr.esrf.tangoatk.widget.attribute.RawImageViewer
All Implemented Interfaces:
IAttributeStateListener, IErrorListener, IRawImageListener, java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class RawImageViewer
extends javax.swing.JPanel
implements IRawImageListener, java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

A high level class to display a TANGO image following Tango DEV_ENCODED specification and handle several image manipulation function.

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  JImage imagePanel
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
RawImageViewer()
          Create a new RawImageViewer
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
           
 void addRoiListener(IRoiListener l)
          Add the specified ROI Listener
 void clearModel()
          Removes all listener belonging to the viewer.
 void errorChange(ErrorEvent errorEvent)
           
 boolean getAutoZoom()
          Determines wheter this image viewer has auto zoom enabled.
 java.awt.Dimension getCurrentImageSize()
          Returns the current image size
 Gradient getGradient()
          Returns current colormap
 java.awt.Insets getImageMargin()
          Returns image margin.
 int getImageXCoord(int x)
          Converts the component horizontal coordinate to the image coordinate.
 int getImageYCoord(int y)
          Converts the component vertical coordinate to the image coordinate.
 java.awt.Rectangle getSelection()
          Return current floating rectangle selection
 int getSelectionMode()
          Returns the floating selection mode
 JLAxis getXAxis()
          Returns a handle to the x axis.
 JLAxis getYAxis()
          Return a handle to the Y axis.
 int getZoom()
          Return the current zoom factor index.
 boolean isAlignToGrid()
          Returns true is floating selection are aligned to grid
 boolean isBestFit()
          Returns true when best fit is on
 boolean isGradientVisible()
          Returns true when the gradient is visible.
 boolean isNegative()
          Returns true only if negative image is displayed
 boolean isSelectionEnabled()
          Returns true is floating selection is enabled
 boolean isShowingMenu()
          Returns true is the image viewer menu is displayed when clicking on the right mouse button.
 boolean isStatusLineVisible()
          Returns true when the status line is visible.
 boolean isToolbarVisible()
          Returns true when the toolbar is visible.
static void main(java.lang.String[] args)
           
 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 rawImageChange(RawImageEvent evt)
           
 void removeRoiListener(IRoiListener l)
          Remove the specified ROI Listener
 void setAlignToGrid(boolean b)
          Sets the align to grid mode for floating selection
 void setAutoZoom(boolean auto)
          Enables or disables the auto zoom.
 void setBestFit(boolean b)
          Displays the image using the whole color range.
 void setCrossCursor(boolean enable)
          Enable or disable the cross cursor.
 void setCrossCursorColor(java.awt.Color c)
          Set the cross cursor color.
 void setData(java.lang.String encFormat, byte[] rawData)
          Sets data to display.
 void setGradient(Gradient g)
          Sets the colormap
 void setGradientVisible(boolean b)
          Displays or hides the gradient (right panel).
 void setImageMargin(java.awt.Insets i)
          Sets the image margin.
 void setModel(IRawImage v)
          Sets the model.
 void setNegative(boolean b)
          Displays negative image when enabled
 void setSelection(java.awt.Rectangle r)
          Sets the floating selection.
 void setSelectionEnabled(boolean b)
          True is floating selection is enabled
 void setSelectionMode(int m)
          Sets the floating selection mode
 void setShowingMenu(boolean b)
          True to enable menu displayed when clicking on right mouse button.
 void setStatusLineVisible(boolean b)
          Displays or hides the status line (bottom panel).
 void setToolbarVisible(boolean b)
          Displays or hides the toolbar.
 void setZoom(int zoomIndex)
          Sets the image zoom factor.
 void stateChange(AttributeStateEvent evt)
           
 
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

imagePanel

protected JImage imagePanel
Constructor Detail

RawImageViewer

public RawImageViewer()
Create a new RawImageViewer

Method Detail

setData

public void setData(java.lang.String encFormat,
                    byte[] rawData)
Sets data to display.

Parameters:
rawData - Handle to data

setBestFit

public void setBestFit(boolean b)
Displays the image using the whole color range.

Parameters:
b - Best fit toggle

isBestFit

public boolean isBestFit()
Returns true when best fit is on

Returns:
Best fit state

setGradient

public void setGradient(Gradient g)
Sets the colormap

Parameters:
g - New gradient colormap

getGradient

public Gradient getGradient()
Returns current colormap

Returns:
Gradient object

setNegative

public void setNegative(boolean b)
Displays negative image when enabled

Parameters:
b - True for negtive image

isNegative

public boolean isNegative()
Returns true only if negative image is displayed

Returns:
True when negative

setToolbarVisible

public void setToolbarVisible(boolean b)
Displays or hides the toolbar.

Parameters:
b - True if toolbar is displayed

isToolbarVisible

public boolean isToolbarVisible()
Returns true when the toolbar is visible.

Returns:
Toolbar visible state

setStatusLineVisible

public void setStatusLineVisible(boolean b)
Displays or hides the status line (bottom panel).

Parameters:
b - True if status line is displayed

isStatusLineVisible

public boolean isStatusLineVisible()
Returns true when the status line is visible.

Returns:
Status line visible state

getZoom

public int getZoom()
Return the current zoom factor index.

See Also:
setZoom(int)

setZoom

public void setZoom(int zoomIndex)
Sets the image zoom factor. If you want to start you viewer with a fixed zoom factor, you have to call setZoom() before setModel().
 Possible zoomIndex values are:
   0 : 400%
   1 : 200%
   2 : 100%
   3 : 50%
   4 : 25%
   5 : 12.5%
 

Parameters:
zoomIndex - ZoomFactor index (see description).

setAutoZoom

public void setAutoZoom(boolean auto)
Enables or disables the auto zoom. When enabled, the image size (zoom) is automatically adjusted according to the component size. The calcul of the size is triggered by a call to setData() or imageChange().

Parameters:
auto - AutoZoom flag

getAutoZoom

public boolean getAutoZoom()
Determines wheter this image viewer has auto zoom enabled.

See Also:
setAutoZoom(boolean)

setAlignToGrid

public void setAlignToGrid(boolean b)
Sets the align to grid mode for floating selection

Parameters:
b - True to enable

isAlignToGrid

public boolean isAlignToGrid()
Returns true is floating selection are aligned to grid

Returns:
Align to grid

isShowingMenu

public boolean isShowingMenu()
Returns true is the image viewer menu is displayed when clicking on the right mouse button.

Returns:
True is menu is enabled

setShowingMenu

public void setShowingMenu(boolean b)
True to enable menu displayed when clicking on right mouse button.

Parameters:
b - True to enable the menu

addRoiListener

public void addRoiListener(IRoiListener l)
Add the specified ROI Listener

Parameters:
l - ROI listener

removeRoiListener

public void removeRoiListener(IRoiListener l)
Remove the specified ROI Listener

Parameters:
l - ROI listener

setSelection

public void setSelection(java.awt.Rectangle r)
Sets the floating selection.

Parameters:
r - Rectangle to select

getSelection

public java.awt.Rectangle getSelection()
Return current floating rectangle selection

Returns:
Selection rectangle, Null is returned when nothing is selected.

getImageMargin

public java.awt.Insets getImageMargin()
Returns image margin.

Returns:
Mergin

setImageMargin

public void setImageMargin(java.awt.Insets i)
Sets the image margin.

Parameters:
i - Image margin

setSelectionEnabled

public void setSelectionEnabled(boolean b)
True is floating selection is enabled

Parameters:
b - True to allow floating selection

isSelectionEnabled

public boolean isSelectionEnabled()
Returns true is floating selection is enabled

Returns:
True when floating selection is allowed

setCrossCursor

public void setCrossCursor(boolean enable)
Enable or disable the cross cursor.

Parameters:
enable - True to enable cross cursor, false otherwise.

setCrossCursorColor

public void setCrossCursorColor(java.awt.Color c)
Set the cross cursor color.

Parameters:
c - Cursor color
See Also:
setCrossCursor(boolean)

getSelectionMode

public int getSelectionMode()
Returns the floating selection mode

Returns:
0 when Line selection, 1 when rectangle selection

setSelectionMode

public void setSelectionMode(int m)
Sets the floating selection mode

Parameters:
m - 0 for Line selection, 1 fro rectangle selection

getXAxis

public JLAxis getXAxis()
Returns a handle to the x axis.


getYAxis

public JLAxis getYAxis()
Return a handle to the Y axis.


setGradientVisible

public void setGradientVisible(boolean b)
Displays or hides the gradient (right panel).

Parameters:
b - True if status line is displayed

isGradientVisible

public boolean isGradientVisible()
Returns true when the gradient is visible.


getImageXCoord

public int getImageXCoord(int x)
Converts the component horizontal coordinate to the image coordinate.

Parameters:
x - Component horizontal coordinate

getImageYCoord

public int getImageYCoord(int y)
Converts the component vertical coordinate to the image coordinate.

Parameters:
y - Component vertical coordinate

getCurrentImageSize

public java.awt.Dimension getCurrentImageSize()
Returns the current image size

Returns:
Current image size

actionPerformed

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

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
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

mouseEntered

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

mouseExited

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

mouseClicked

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

mouseReleased

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

mousePressed

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

errorChange

public void errorChange(ErrorEvent errorEvent)
Specified by:
errorChange in interface IErrorListener

stateChange

public void stateChange(AttributeStateEvent evt)
Specified by:
stateChange in interface IAttributeStateListener

rawImageChange

public void rawImageChange(RawImageEvent evt)
Specified by:
rawImageChange in interface IRawImageListener

setModel

public void setModel(IRawImage v)
Sets the model.

Parameters:
v - Value to assign to model.

clearModel

public void clearModel()
Removes all listener belonging to the viewer.


main

public static void main(java.lang.String[] args)