fr.esrf.tangoatk.widget.jdraw
Class TangoSynopticHandler

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by fr.esrf.tangoatk.widget.util.jdraw.JDrawEditor
                  extended by fr.esrf.tangoatk.widget.jdraw.TangoSynopticHandler
All Implemented Interfaces:
IAttributeStateListener, IBooleanScalarListener, IDevStateScalarListener, IDevStateSpectrumListener, IErrorListener, INumberScalarListener, IStateListener, IStatusListener, java.awt.event.ActionListener, java.awt.event.ComponentListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.WindowListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener
Direct Known Subclasses:
SynopticFileViewer

public class TangoSynopticHandler
extends JDrawEditor
implements IStateListener, IStatusListener, INumberScalarListener, IDevStateScalarListener, IBooleanScalarListener, IDevStateSpectrumListener, java.awt.event.WindowListener

TangoSynopticHandler is the base class used to display and animate any tango synoptic drawing made with the JDraw drawing tool "JDraw". The drawing file is browsed and a behaviour is attached to each drawing component according to the tango object which is associated with. While brawsing the drawing file the name of the graphical component determines the associated tango object: For example if inside the synoptic drawing a simple rectangle is given the name "eas/test-api/1" it will be associated to the tango device eas/test-api/1. The animation on the graphical component depends on the type of the Tango object (device, attribute, command) and the type of JDraw graphical component (simple graphical component, multi-state JDraw object, interactive JDraw object) Here are the default (state) animations provided :

In addition to the animation a default interaction behaviour is provided (reaction to mouse clicks). Here are the default interactions :

There are 4 extensions parsed by default :

Since:
ATKWidget-1.9.7
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
static int TOOL_TIP_NAME
          Displays device name within tooltip
static int TOOL_TIP_NONE
          Does not display tooltip
static int TOOL_TIP_STATE
          Displays device state within tooltip
static int TOOL_TIP_STATUS
          Displays device status within tooltip
 
Fields inherited from class fr.esrf.tangoatk.widget.util.jdraw.JDrawEditor
CREATE_AXIS, CREATE_BAR, CREATE_CLIPBOARD, CREATE_ELLIPSE, CREATE_IMAGE, CREATE_LABEL, CREATE_LINE, CREATE_POLYLINE, CREATE_RECTANGLE, CREATE_RRECTANGLE, CREATE_SLIDER, CREATE_SPLINE, CREATE_SWINGOBJECT, MODE_EDIT, MODE_EDIT_GROUP, MODE_LIB, MODE_PLAY
 
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
TangoSynopticHandler()
          Construct a TangoSynopticHandler (A JDrawEditor in MODE_PLAY).
TangoSynopticHandler(java.lang.String jdFileName)
          Construct a TangoSynopticHandler (A JDrawEditor in MODE_PLAY).
TangoSynopticHandler(java.lang.String jdFileName, ErrorHistory errh)
          Construct a TangoSynopticHandler (A JDrawEditor in MODE_PLAY).
TangoSynopticHandler(java.lang.String jdFileName, int ttMode)
          Construct a TangoSynopticHandler (A JDrawEditor in MODE_PLAY).
 
Method Summary
 void booleanScalarChange(BooleanScalarEvent evt)
           
 void devStateScalarChange(DevStateScalarEvent event)
           
 void devStateSpectrumChange(DevStateSpectrumEvent evt)
           
 void errorChange(ErrorEvent event)
           
 AttributeList getAttributeList()
          Returns a Handle to the global attribute list which is used internaly to monitor attributes.
 ErrorHistory getErrorHistoryWindow()
          Returns the current error history window
 java.lang.String getSynopticFileName()
          Returns the current synoptic filename.
 int getToolTipMode()
          Returns the current Tooltip Mode
protected  boolean isAttribute(java.lang.String s)
          Return true only if the given name matches a Tango attribute name.
protected  boolean isCommand(java.lang.String s)
          Return true only if the given name matches a Tango command name.
protected  boolean isDevice(java.lang.String devName)
          Return true only if the given name matches a Tango device name.
protected  boolean isSpectrumAttElement(java.lang.String s)
          Return true only if the given name matches a Tango attribute name followed by [index].
 void loadSynopticFromStream(java.io.InputStreamReader inp)
          Load a jdraw grpahics input stream into the drawing area.The JLoox and Loox files formats are not supported.
static void main(java.lang.String[] args)
           
 void numberScalarChange(NumberScalarEvent evt)
           
protected  void parseJdrawComponents()
          Parses JDraw components , detects tango entity name and attatch a model.
 void setErrorHistoryWindow(ErrorHistory errh)
          Sets the current error history window.
 void setSynopticFileName(java.lang.String jdFileName)
          Reads the Jdraw file, browses and parses the synoptic components.
 void setToolTipMode(int ttMode)
          Sets the current tooltip mode (device object only)
 void stateChange(AttributeStateEvent evt)
          change the color of the jdobj (bg or fg) according to the quality factor of the attribute If and Only If the JDobject is not a JDBar, or JDSlider and no color mapper is set for the JDobject and the "extension" QualityFactor is true
 void stateChange(StateEvent event)
           
 void statusChange(StatusEvent event)
           
 void windowActivated(java.awt.event.WindowEvent e)
           
 void windowClosed(java.awt.event.WindowEvent e)
           
 void windowClosing(java.awt.event.WindowEvent e)
           
 void windowDeactivated(java.awt.event.WindowEvent e)
           
 void windowDeiconified(java.awt.event.WindowEvent e)
           
 void windowIconified(java.awt.event.WindowEvent e)
           
 void windowOpened(java.awt.event.WindowEvent e)
           
 
Methods inherited from class fr.esrf.tangoatk.widget.util.jdraw.JDrawEditor
actionPerformed, addEditorListener, addObject, addToMenu, alignbottomSelection, alignleftSelection, alignrightSelection, aligntopSelection, backSelection, canRedo, canUndo, clearEditorListener, clearObjects, clearUndo, componentHidden, componentMoved, componentResized, componentShown, computePreferredSize, convertToPolyline, copySelection, create, create, cutSelection, deleteSelection, frontSelection, generateJavaClasses, getClipboardLength, getClipboardObjects, getFileName, getGridSize, getInteractiveObjects, getLastActionName, getMinimumSize, getMode, getNeedToSaveState, getNextActionName, getObjectAt, getObjectNumber, getObjects, getObjectsByName, getObjectsOfClass, getPreferredSize, getSelectedObjects, getSelectionLength, getZoomFactor, getZoomFactorPercent, groupSelection, initPlayer, instantSave, isAlignToGrid, isAutoZoom, isGridVisible, isSelected, keyPressed, keyReleased, keyTyped, loadFile, loadFromStream, lowerObject, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mousePressedEditorB1, mousePressedEditorB3, mousePressedPlayerB1, mousePressedPlayerB3, mouseReleased, paint, paintObjects, paintSelection, pasteClipboard, raiseObject, redo, removeEditorListener, repaint, saveFile, scaleSelection, selectAll, selectNotVisible, selectObject, selectObjects, setAlignToGrid, setAutoZoom, setAutoZoomFactor, setGridSize, setGridVisible, setPreferredSize, setStatusLabel, setTranslation, setZoomFactor, showBrowserWindow, showGroupEditorWindow, showGroupJavaWindow, showOpenDialog, showPropertyWindow, showSaveDialog, showTransformWindow, translateSelection, undo, ungroupSelection, unselectAll, unselectObject, zoomIn, zoomOut
 
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, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, 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, 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, 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

TOOL_TIP_NONE

public static final int TOOL_TIP_NONE
Does not display tooltip

See Also:
Constant Field Values

TOOL_TIP_STATE

public static final int TOOL_TIP_STATE
Displays device state within tooltip

See Also:
Constant Field Values

TOOL_TIP_STATUS

public static final int TOOL_TIP_STATUS
Displays device status within tooltip

See Also:
Constant Field Values

TOOL_TIP_NAME

public static final int TOOL_TIP_NAME
Displays device name within tooltip

See Also:
Constant Field Values
Constructor Detail

TangoSynopticHandler

public TangoSynopticHandler()
Construct a TangoSynopticHandler (A JDrawEditor in MODE_PLAY).

See Also:
JDrawEditor.MODE_PLAY

TangoSynopticHandler

public TangoSynopticHandler(java.lang.String jdFileName)
                     throws java.util.MissingResourceException,
                            java.io.FileNotFoundException,
                            java.lang.IllegalArgumentException
Construct a TangoSynopticHandler (A JDrawEditor in MODE_PLAY).

Parameters:
jdFileName - Filename of the JDraw (jdw) synptic to load.
Throws:
java.util.MissingResourceException
java.io.FileNotFoundException
java.lang.IllegalArgumentException
See Also:
setSynopticFileName(java.lang.String)

TangoSynopticHandler

public TangoSynopticHandler(java.lang.String jdFileName,
                            ErrorHistory errh)
                     throws java.util.MissingResourceException,
                            java.io.FileNotFoundException,
                            java.lang.IllegalArgumentException
Construct a TangoSynopticHandler (A JDrawEditor in MODE_PLAY).

Parameters:
jdFileName - Filename of the JDraw (jdw) synptic to load.
errh - ErrorHistory window which will receive errors.
Throws:
java.util.MissingResourceException
java.io.FileNotFoundException
java.lang.IllegalArgumentException
See Also:
setSynopticFileName(java.lang.String), ErrorHistory

TangoSynopticHandler

public TangoSynopticHandler(java.lang.String jdFileName,
                            int ttMode)
                     throws java.util.MissingResourceException,
                            java.io.FileNotFoundException,
                            java.lang.IllegalArgumentException
Construct a TangoSynopticHandler (A JDrawEditor in MODE_PLAY).

Parameters:
jdFileName - Filename of the JDraw (jdw) synptic to load.
ttMode - Tooltip mode
Throws:
java.util.MissingResourceException
java.io.FileNotFoundException
java.lang.IllegalArgumentException
See Also:
TOOL_TIP_NONE, TOOL_TIP_STATE, TOOL_TIP_STATUS, TOOL_TIP_NAME
Method Detail

getToolTipMode

public int getToolTipMode()
Returns the current Tooltip Mode

See Also:
setToolTipMode(int)

setToolTipMode

public void setToolTipMode(int ttMode)
Sets the current tooltip mode (device object only)

Parameters:
ttMode - Tooltip mode
See Also:
TOOL_TIP_NONE, TOOL_TIP_STATE, TOOL_TIP_STATUS, TOOL_TIP_NAME

getErrorHistoryWindow

public ErrorHistory getErrorHistoryWindow()
Returns the current error history window

See Also:
setErrorHistoryWindow(fr.esrf.tangoatk.widget.util.ErrorHistory)

setErrorHistoryWindow

public void setErrorHistoryWindow(ErrorHistory errh)
Sets the current error history window. Note that the error history window should be set before the jdraw file is parsed (before the call to the setSynopticFileName)


getSynopticFileName

public java.lang.String getSynopticFileName()
Returns the current synoptic filename.

See Also:
getSynopticFileName()

getAttributeList

public AttributeList getAttributeList()
Returns a Handle to the global attribute list which is used internaly to monitor attributes. This list is filled after setSynopticFileName() is called. To add an error listener to this list, you have to register it before loading a synoptic.

See Also:
setSynopticFileName(java.lang.String)

loadSynopticFromStream

public void loadSynopticFromStream(java.io.InputStreamReader inp)
                            throws java.io.IOException,
                                   java.util.MissingResourceException
Load a jdraw grpahics input stream into the drawing area.The JLoox and Loox files formats are not supported. This method allows to load a synoptic which is not necessarily a file on disk. This method is particularly used when the synoptic jdraw file is pakaged into the application jarfile and cannot be accessed as a separate file on the disk.

Parameters:
InputStreamReader - inp An InputStreamReader should be created by the application and passed to this method
Throws:
java.io.IOException - Exception when the inputStream cannot be accessed.
java.util.MissingResourceException - when the "jdraw" inputStream cannot be parsed.

setSynopticFileName

public void setSynopticFileName(java.lang.String jdFileName)
                         throws java.util.MissingResourceException,
                                java.io.FileNotFoundException,
                                java.lang.IllegalArgumentException
Reads the Jdraw file, browses and parses the synoptic components. The main purpose of this function is to attach Tango entity model to JDraw component.

Parameters:
jdFileName - Filename of the JDraw (jdw) synptic to load.
Throws:
java.util.MissingResourceException
java.io.FileNotFoundException
java.lang.IllegalArgumentException

parseJdrawComponents

protected void parseJdrawComponents()
Parses JDraw components , detects tango entity name and attatch a model. This method does not recurse group and use isDevice() , isAttribute() and isDevice() to detect entity name.

See Also:
isDevice(java.lang.String), isAttribute(java.lang.String), isCommand(java.lang.String)

isAttribute

protected boolean isAttribute(java.lang.String s)
Return true only if the given name matches a Tango attribute name.

Attribute name allowed syntax ( Can be preceded by tango: ):

   Full syntax: //hostName:portNumber/domain/family/member/attName
   Full syntax: //ipAddress:portNumber/domain/family/member/attName
   Short syntax: domain/family/member/attName
 

Parameters:
s - Attribute name

isSpectrumAttElement

protected boolean isSpectrumAttElement(java.lang.String s)
Return true only if the given name matches a Tango attribute name followed by [index].

Spectrum Attribute element allowed syntax ( Can be preceded by tango: ):

   Full syntax: //hostName:portNumber/domain/family/member/attName[xx]
   Full syntax: //ipAddress:portNumber/domain/family/member/attName[xx]
   Short syntax: domain/family/member/attName[xx]
 

Parameters:
s - Spectrum Attribute element

isCommand

protected boolean isCommand(java.lang.String s)
Return true only if the given name matches a Tango command name.

Command name allowed syntax ( Can be preceded by tango: ):

   Full syntax: //hostName:portNumber/domain/family/member/cmdName
   Full syntax: //ipAddress:portNumber/domain/family/member/cmdName
   Short syntax: domain/family/member/cmdName
 

Parameters:
s - Command name

isDevice

protected boolean isDevice(java.lang.String devName)
Return true only if the given name matches a Tango device name.

Device name allowed syntax ( Can be preceded by tango: ):

   Full syntax: //hostName:portNumber/domain/family/member
   Full syntax: //ipAddress:portNumber/domain/family/member
   Short syntax: domain/family/member
 

Parameters:
devName - Device name

windowClosed

public void windowClosed(java.awt.event.WindowEvent e)
Specified by:
windowClosed in interface java.awt.event.WindowListener

windowOpened

public void windowOpened(java.awt.event.WindowEvent e)
Specified by:
windowOpened in interface java.awt.event.WindowListener

windowClosing

public void windowClosing(java.awt.event.WindowEvent e)
Specified by:
windowClosing in interface java.awt.event.WindowListener

windowIconified

public void windowIconified(java.awt.event.WindowEvent e)
Specified by:
windowIconified in interface java.awt.event.WindowListener

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent e)
Specified by:
windowDeiconified in interface java.awt.event.WindowListener

windowActivated

public void windowActivated(java.awt.event.WindowEvent e)
Specified by:
windowActivated in interface java.awt.event.WindowListener

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent e)
Specified by:
windowDeactivated in interface java.awt.event.WindowListener

numberScalarChange

public void numberScalarChange(NumberScalarEvent evt)
Specified by:
numberScalarChange in interface INumberScalarListener

booleanScalarChange

public void booleanScalarChange(BooleanScalarEvent evt)
Specified by:
booleanScalarChange in interface IBooleanScalarListener

devStateSpectrumChange

public void devStateSpectrumChange(DevStateSpectrumEvent evt)
Specified by:
devStateSpectrumChange in interface IDevStateSpectrumListener

stateChange

public void stateChange(AttributeStateEvent evt)
change the color of the jdobj (bg or fg) according to the quality factor of the attribute If and Only If the JDobject is not a JDBar, or JDSlider and no color mapper is set for the JDobject and the "extension" QualityFactor is true

Specified by:
stateChange in interface IAttributeStateListener

errorChange

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

devStateScalarChange

public void devStateScalarChange(DevStateScalarEvent event)
Specified by:
devStateScalarChange in interface IDevStateScalarListener

stateChange

public void stateChange(StateEvent event)
Specified by:
stateChange in interface IStateListener

statusChange

public void statusChange(StatusEvent event)
Specified by:
statusChange in interface IStatusListener

main

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