fr.esrf.tangoatk.widget.util.jdraw
Class JDrawEditor

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
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.ComponentListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener
Direct Known Subclasses:
TangoSynopticHandler

public class JDrawEditor
extends javax.swing.JComponent
implements java.awt.event.MouseMotionListener, java.awt.event.MouseListener, java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.ComponentListener

The graph editor/viewer component.

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 CREATE_AXIS
          Creation mode of the editor
static int CREATE_BAR
          Creation mode of the editor
static int CREATE_CLIPBOARD
          Creation mode of the editor
static int CREATE_ELLIPSE
          Creation mode of the editor
static int CREATE_IMAGE
          Creation mode of the editor
static int CREATE_LABEL
          Creation mode of the editor
static int CREATE_LINE
          Creation mode of the editor
static int CREATE_POLYLINE
          Creation mode of the editor
static int CREATE_RECTANGLE
          Creation mode of the editor
static int CREATE_RRECTANGLE
          Creation mode of the editor
static int CREATE_SLIDER
          Creation mode of the editor
static int CREATE_SPLINE
          Creation mode of the editor
static int CREATE_SWINGOBJECT
          Creation mode of the editor
static int MODE_EDIT
          Editor is in classic edition mode
static int MODE_EDIT_GROUP
          Group edition mode, this is a restricted edition mode (no undo possible)
static int MODE_LIB
          Library mode, allow only selection and clipboard
static int MODE_PLAY
          Play mode, play object according to their value , in this mode no contextual menu is displayed
 
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
JDrawEditor(int mode)
          Contruct a JDraw editor in the specified mode.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void addEditorListener(JDrawEditorListener l)
          Add an JDrawEditor listener.
 void addObject(JDObject o)
          Add an object to the drawing.
 void addToMenu(javax.swing.JMenuItem newItem)
           
 void alignbottomSelection()
          Align selection to bottom
 void alignleftSelection()
          Align selection to left
 void alignrightSelection()
          Align selection to right
 void aligntopSelection()
          Align selection to top
 void backSelection()
          send selected object to background
 boolean canRedo()
          Get redo state
 boolean canUndo()
          Get undo state
 void clearEditorListener()
          Clears the JDrawEditor listener list.
 void clearObjects()
          Clear all object
 void clearUndo()
          Clear the undo buffer
 void componentHidden(java.awt.event.ComponentEvent e)
           
 void componentMoved(java.awt.event.ComponentEvent e)
           
 void componentResized(java.awt.event.ComponentEvent e)
           
 void componentShown(java.awt.event.ComponentEvent e)
           
 void computePreferredSize()
          Compute the optimal size of the components and trigger sizeChanged()
 void convertToPolyline()
          Convert the selected objects to JDPolyline.
 void copySelection()
          Copy selection to clipboard
 void create(int what)
          Sets the editor in creation mode.
 void create(int what, java.lang.String param)
          Sets the editor in creation mode.
 void cutSelection()
          Move the selection to clipboard
 void deleteSelection()
          Delete selection from the draw
 void frontSelection()
          bring selected object to foreground
 void generateJavaClasses(java.lang.String dirName)
          Generates java classes from the selection.
 int getClipboardLength()
          Get number of object inside the clipboard
 java.util.Vector getClipboardObjects()
          Used for read only purpose , vector should not be modified by this way.
 java.lang.String getFileName()
          Gets the name of the last loaded file
 int getGridSize()
          Returns the current gid size.
 java.util.Vector getInteractiveObjects()
          Return all object that have the "User interaction" flag enabled.
 java.lang.String getLastActionName()
          Get name of the last action
 java.awt.Dimension getMinimumSize()
           
 int getMode()
          Returns the mode of the editor.
 boolean getNeedToSaveState()
          Returns true if the drawing has been modofied and need to be saved
 java.lang.String getNextActionName()
          Get name of the action that can be redone
 JDObject getObjectAt(int idx)
          Get the JDObject at the specified position.
 int getObjectNumber()
          Get number of object
 java.util.Vector getObjects()
          Used for read only purpose , vector should not be modified by this way.
 java.util.Vector getObjectsByName(java.lang.String name, boolean recurseGroup)
          Returns all objects having the given name present in the drawing area.
 java.util.Vector getObjectsOfClass(java.lang.Class theClass)
          Retunrs all objects of the specified class present in the drawing area.
 java.awt.Dimension getPreferredSize()
           
 java.util.Vector getSelectedObjects()
          Used for read only purpose , vector should not be modified by this way.
 int getSelectionLength()
          Get number of selected object
 int getZoomFactor()
          Returns the zoom factor value.
 int getZoomFactorPercent()
          Get the zoom factor in percent
 void groupSelection()
          group selected objects
 void initPlayer()
          Inits the player, This function should be called only if you want to build dynamicaly a graph with addObject().
 void instantSave(java.lang.String defaultDir)
          Save the current drawing to the file (Ask for filename if no filename has been previously set)
 boolean isAlignToGrid()
          Determines whether object and control point are aligned to the grid.
 boolean isAutoZoom()
          Returns true is auto zoom is enabled, false otherwise.
 boolean isGridVisible()
          Determines whether the grid is visible.
 boolean isSelected(JDObject obj)
          Determine wheter the specifed object is selected.
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
 void loadFile(java.lang.String fileName)
          Load a jdraw grpahics file into the editor Trigger valueChanged() if a file is selected to be loaded.
protected  void loadFromStream(java.io.InputStreamReader inp)
          Load a jdraw grpahics input stream reader into the editor.
 void lowerObject()
          Move down selected object.
 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 mousePressedEditorB1(java.awt.event.MouseEvent e)
           
 void mousePressedEditorB3(java.awt.event.MouseEvent e)
           
 void mousePressedPlayerB1(java.awt.event.MouseEvent e)
           
 void mousePressedPlayerB3(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void paint(java.awt.Graphics g)
           
 void paintObjects(java.awt.Graphics g)
          Paints all JDObjects of the components.
 void paintSelection(java.awt.Graphics g)
          Paints selection area and control points.
 void pasteClipboard(int x, int y)
          Paste the selection at the specified pos.
 void raiseObject()
          Raise selected object.
 void redo()
          Redo last canceled action
 void removeEditorListener(JDrawEditorListener l)
          Remove an JDrawEditor listener.
 void repaint(java.awt.Rectangle r)
          Repaint the specified rectangle.
 void saveFile(java.lang.String fileName)
          Save the current drawing to a file.
 void scaleSelection(double rx, double ry)
          Scale selection around the selection center.
 void selectAll()
          Select all object
 void selectNotVisible()
          Select non visible items
 void selectObject(JDObject obj)
          Select the specified object.
 void selectObjects(JDObject[] objs)
          Selects all specified objects.
 void setAlignToGrid(boolean b)
          When enabled, all moved control points and objects will be aligned to the grid.
 void setAutoZoom(boolean b)
          Sets the auto zoom.
 void setAutoZoomFactor(double ratio)
          Sets the initial autoZoom factor.
 void setGridSize(int size)
          Sets the grid step size.
 void setGridVisible(boolean b)
          Shows or hide the grid.
 void setPreferredSize(java.awt.Dimension d)
           
 void setStatusLabel(javax.swing.JLabel label)
          Sets the status label where are printed creation information.
 void setTranslation(int x, int y)
          Set a global translation for the drawing area
 void setZoomFactor(int z)
          Sets the zoom factor.
 void showBrowserWindow()
          Shows the object browser
 void showGroupEditorWindow()
          Shows the group editor dialog
 void showGroupJavaWindow()
          Shows the java generation file selection box
 void showOpenDialog(java.lang.String defaultDir)
          Show the file selection box and call loadFile if a file is selected.
 void showPropertyWindow()
          Shows the property window
 void showSaveDialog(java.lang.String defaultDir)
          Show the file selection box and call saveFile if a file is selected.
 void showTransformWindow()
          Shows the property window
 void translateSelection(int x, int y)
          Translate selected Object
 void undo()
          Undo the last action
 void ungroupSelection()
          ungroup selected object
 void unselectAll()
          Unselect all object
 void unselectObject(JDObject obj)
          Unselect the specified object.
 void zoomIn()
          Zoom In the graph
 void zoomOut()
          Zoom Out the graph
 
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

MODE_EDIT

public static final int MODE_EDIT
Editor is in classic edition mode

See Also:
Constant Field Values

MODE_EDIT_GROUP

public static final int MODE_EDIT_GROUP
Group edition mode, this is a restricted edition mode (no undo possible)

See Also:
Constant Field Values

MODE_PLAY

public static final int MODE_PLAY
Play mode, play object according to their value , in this mode no contextual menu is displayed

See Also:
Constant Field Values

MODE_LIB

public static final int MODE_LIB
Library mode, allow only selection and clipboard

See Also:
Constant Field Values

CREATE_RECTANGLE

public static final int CREATE_RECTANGLE
Creation mode of the editor

See Also:
Constant Field Values

CREATE_LINE

public static final int CREATE_LINE
Creation mode of the editor

See Also:
Constant Field Values

CREATE_ELLIPSE

public static final int CREATE_ELLIPSE
Creation mode of the editor

See Also:
Constant Field Values

CREATE_POLYLINE

public static final int CREATE_POLYLINE
Creation mode of the editor

See Also:
Constant Field Values

CREATE_LABEL

public static final int CREATE_LABEL
Creation mode of the editor

See Also:
Constant Field Values

CREATE_SPLINE

public static final int CREATE_SPLINE
Creation mode of the editor

See Also:
Constant Field Values

CREATE_CLIPBOARD

public static final int CREATE_CLIPBOARD
Creation mode of the editor

See Also:
Constant Field Values

CREATE_RRECTANGLE

public static final int CREATE_RRECTANGLE
Creation mode of the editor

See Also:
Constant Field Values

CREATE_IMAGE

public static final int CREATE_IMAGE
Creation mode of the editor

See Also:
Constant Field Values

CREATE_SWINGOBJECT

public static final int CREATE_SWINGOBJECT
Creation mode of the editor

See Also:
Constant Field Values

CREATE_AXIS

public static final int CREATE_AXIS
Creation mode of the editor

See Also:
Constant Field Values

CREATE_BAR

public static final int CREATE_BAR
Creation mode of the editor

See Also:
Constant Field Values

CREATE_SLIDER

public static final int CREATE_SLIDER
Creation mode of the editor

See Also:
Constant Field Values
Constructor Detail

JDrawEditor

public JDrawEditor(int mode)
Contruct a JDraw editor in the specified mode.

Parameters:
mode - Mode of the editor
See Also:
MODE_EDIT, MODE_EDIT_GROUP, MODE_PLAY
Method Detail

setGridVisible

public void setGridVisible(boolean b)
Shows or hide the grid.

Parameters:
b - True to show the grid, false otherwise.

isGridVisible

public boolean isGridVisible()
Determines whether the grid is visible.


setGridSize

public void setGridSize(int size)
Sets the grid step size.

Parameters:
size - Grid size (pixel)

getGridSize

public int getGridSize()
Returns the current gid size.

See Also:
setGridSize(int)

setAlignToGrid

public void setAlignToGrid(boolean b)
When enabled, all moved control points and objects will be aligned to the grid.

Parameters:
b - True to align object to grid , false otherwise.

isAlignToGrid

public boolean isAlignToGrid()
Determines whether object and control point are aligned to the grid.

See Also:
setAlignToGrid(boolean), setGridSize(int)

getMode

public int getMode()
Returns the mode of the editor.


selectObject

public void selectObject(JDObject obj)
Select the specified object. Does not fire selectionChanged().

Parameters:
obj - Object to be selected.

unselectObject

public void unselectObject(JDObject obj)
Unselect the specified object. Does not fire selectionChanged().

Parameters:
obj - Object to be deselected.

isSelected

public boolean isSelected(JDObject obj)
Determine wheter the specifed object is selected.

Parameters:
obj - JDObject
See Also:
selectObject(fr.esrf.tangoatk.widget.util.jdraw.JDObject), unselectObject(fr.esrf.tangoatk.widget.util.jdraw.JDObject)

selectObjects

public void selectObjects(JDObject[] objs)
Selects all specified objects.

Parameters:
objs - Array of JDObject to be selected.

getObjectNumber

public int getObjectNumber()
Get number of object


getObjectAt

public JDObject getObjectAt(int idx)
Get the JDObject at the specified position.

Parameters:
idx - Object index.

getObjects

public java.util.Vector getObjects()
Used for read only purpose , vector should not be modified by this way.


getSelectedObjects

public java.util.Vector getSelectedObjects()
Used for read only purpose , vector should not be modified by this way.


getClipboardObjects

public java.util.Vector getClipboardObjects()
Used for read only purpose , vector should not be modified by this way.


unselectAll

public void unselectAll()
Unselect all object


selectAll

public void selectAll()
Select all object


selectNotVisible

public void selectNotVisible()
Select non visible items


create

public void create(int what)
Sets the editor in creation mode.

Parameters:
what - Object to be created
See Also:
create(int,String), CREATE_RECTANGLE, CREATE_LINE, CREATE_ELLIPSE, CREATE_POLYLINE, CREATE_LABEL, CREATE_SPLINE, CREATE_CLIPBOARD, CREATE_RRECTANGLE, CREATE_IMAGE, CREATE_SWINGOBJECT, CREATE_AXIS, CREATE_BAR, CREATE_SLIDER

create

public void create(int what,
                   java.lang.String param)
Sets the editor in creation mode.

Parameters:
what - Object to be created
param - Optional parameters (used for JDSwingObject className)
See Also:
create(int)

getSelectionLength

public int getSelectionLength()
Get number of selected object


getClipboardLength

public int getClipboardLength()
Get number of object inside the clipboard


showPropertyWindow

public void showPropertyWindow()
Shows the property window


showTransformWindow

public void showTransformWindow()
Shows the property window


showBrowserWindow

public void showBrowserWindow()
Shows the object browser


showGroupEditorWindow

public void showGroupEditorWindow()
Shows the group editor dialog


generateJavaClasses

public void generateJavaClasses(java.lang.String dirName)
                         throws java.io.IOException
Generates java classes from the selection.

Throws:
java.io.IOException
See Also:
JDGroup.generateJavaClass(java.io.FileWriter)

showGroupJavaWindow

public void showGroupJavaWindow()
Shows the java generation file selection box


copySelection

public void copySelection()
Copy selection to clipboard


pasteClipboard

public void pasteClipboard(int x,
                           int y)
Paste the selection at the specified pos.

Parameters:
x - Up left corner x coordinate
y - Up left corner y coordinate

scaleSelection

public void scaleSelection(double rx,
                           double ry)
Scale selection around the selection center.

Parameters:
rx - Horizontal sace ratio.
ry - Vertical sace ratio.

cutSelection

public void cutSelection()
Move the selection to clipboard


deleteSelection

public void deleteSelection()
Delete selection from the draw


showSaveDialog

public void showSaveDialog(java.lang.String defaultDir)
Show the file selection box and call saveFile if a file is selected. Trigger valueChanged() if a file is selected to be saved.

Parameters:
defaultDir - default directory
See Also:
saveFile(java.lang.String)

saveFile

public void saveFile(java.lang.String fileName)
              throws java.io.IOException
Save the current drawing to a file.

Parameters:
fileName - File name
Throws:
java.io.IOException - Exception containing error message when failed.

instantSave

public void instantSave(java.lang.String defaultDir)
Save the current drawing to the file (Ask for filename if no filename has been previously set)


loadFromStream

protected void loadFromStream(java.io.InputStreamReader inp)
                       throws java.io.IOException
Load a jdraw grpahics input stream reader into the editor. Available only for play mode. The .jlx and .g files are not supported. This method is only called by TangoSynopticHandler which is in fact in Play mode.

Parameters:
InputStreamReader - inp opened for the synoptic resource
Throws:
java.io.IOException - Exception containing error message when failed.
See Also:
JDrawEditorListener.valueChanged()

loadFile

public void loadFile(java.lang.String fileName)
              throws java.io.IOException
Load a jdraw grpahics file into the editor Trigger valueChanged() if a file is selected to be loaded.

Parameters:
fileName - File name
Throws:
java.io.IOException - Exception containing error message when failed.
See Also:
JDrawEditorListener.valueChanged()

showOpenDialog

public void showOpenDialog(java.lang.String defaultDir)
Show the file selection box and call loadFile if a file is selected. Trigger valueChanged() if a file is selected to be loaded.

Parameters:
defaultDir - default directory
See Also:
JDrawEditorListener.valueChanged(), loadFile(java.lang.String)

frontSelection

public void frontSelection()
bring selected object to foreground


backSelection

public void backSelection()
send selected object to background


groupSelection

public void groupSelection()
group selected objects


ungroupSelection

public void ungroupSelection()
ungroup selected object


zoomIn

public void zoomIn()
Zoom In the graph


zoomOut

public void zoomOut()
Zoom Out the graph


getZoomFactorPercent

public int getZoomFactorPercent()
Get the zoom factor in percent


getZoomFactor

public int getZoomFactor()
Returns the zoom factor value.

See Also:
getZoomFactorPercent()

setZoomFactor

public void setZoomFactor(int z)
Sets the zoom factor. Does not have effect if autoZoom is enabled.

Parameters:
z - ZoomFactor ( -1=33% , 0=50% , 1=100% , 2=200% )
See Also:
setAutoZoomFactor(double)

setAutoZoom

public void setAutoZoom(boolean b)
Sets the auto zoom. When auto zoom is enabled, the drawing area follows the window size. This works only in MODE_PLAY.

Parameters:
b - True to enable auto zoom, false otherwise.
See Also:
setAutoZoomFactor(double)

setAutoZoomFactor

public void setAutoZoomFactor(double ratio)
Sets the initial autoZoom factor. This allows to start the player (PLAY_MOE) with an arbitrary size.

Parameters:
ratio - Zoom factor

isAutoZoom

public boolean isAutoZoom()
Returns true is auto zoom is enabled, false otherwise.

See Also:
setAutoZoom(boolean)

translateSelection

public void translateSelection(int x,
                               int y)
Translate selected Object


canUndo

public boolean canUndo()
Get undo state


canRedo

public boolean canRedo()
Get redo state


getLastActionName

public java.lang.String getLastActionName()
Get name of the last action


getNextActionName

public java.lang.String getNextActionName()
Get name of the action that can be redone


undo

public void undo()
Undo the last action


redo

public void redo()
Redo last canceled action


clearUndo

public void clearUndo()
Clear the undo buffer


aligntopSelection

public void aligntopSelection()
Align selection to top


alignleftSelection

public void alignleftSelection()
Align selection to left


alignbottomSelection

public void alignbottomSelection()
Align selection to bottom


alignrightSelection

public void alignrightSelection()
Align selection to right


addEditorListener

public void addEditorListener(JDrawEditorListener l)
Add an JDrawEditor listener.

Parameters:
l - Editor listener.
See Also:
JDrawEditorListener

removeEditorListener

public void removeEditorListener(JDrawEditorListener l)
Remove an JDrawEditor listener.

Parameters:
l - Editor listener.
See Also:
JDrawEditorListener

clearEditorListener

public void clearEditorListener()
Clears the JDrawEditor listener list.

See Also:
JDrawEditorListener

getNeedToSaveState

public boolean getNeedToSaveState()
Returns true if the drawing has been modofied and need to be saved


getFileName

public java.lang.String getFileName()
Gets the name of the last loaded file


addObject

public void addObject(JDObject o)
Add an object to the drawing. If you want to add dynamcaly object to this editor (in PLAY_MODE) , You should call initPlayer() after all objects are inserted.

See Also:
initPlayer()

clearObjects

public void clearObjects()
Clear all object


setTranslation

public void setTranslation(int x,
                           int y)
Set a global translation for the drawing area


computePreferredSize

public void computePreferredSize()
Compute the optimal size of the components and trigger sizeChanged()


setPreferredSize

public void setPreferredSize(java.awt.Dimension d)
Overrides:
setPreferredSize in class javax.swing.JComponent

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class javax.swing.JComponent

getMinimumSize

public java.awt.Dimension getMinimumSize()
Overrides:
getMinimumSize in class javax.swing.JComponent

initPlayer

public void initPlayer()
Inits the player, This function should be called only if you want to build dynamicaly a graph with addObject(). Call it after all objects are inserted in the Editor. The call to this function is not absolutly needed. Call it only if you want to PLAY JDSwingObject or if you want to animate objects.

See Also:
addObject(fr.esrf.tangoatk.widget.util.jdraw.JDObject)

getObjectsOfClass

public java.util.Vector getObjectsOfClass(java.lang.Class theClass)
Retunrs all objects of the specified class present in the drawing area.

Parameters:
theClass - JDObject subclass

getObjectsByName

public java.util.Vector getObjectsByName(java.lang.String name,
                                         boolean recurseGroup)
Returns all objects having the given name present in the drawing area.

Parameters:
name - JDObject name (Case sensitive)
recurseGroup - true to perform a deep search whithin group, false otherwise.

convertToPolyline

public void convertToPolyline()
Convert the selected objects to JDPolyline.


raiseObject

public void raiseObject()
Raise selected object.


lowerObject

public void lowerObject()
Move down selected object.


getInteractiveObjects

public java.util.Vector getInteractiveObjects()
Return all object that have the "User interaction" flag enabled.


setStatusLabel

public void setStatusLabel(javax.swing.JLabel label)
Sets the status label where are printed creation information.

Parameters:
label - Label

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener

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

mousePressedEditorB1

public void mousePressedEditorB1(java.awt.event.MouseEvent e)

mousePressedEditorB3

public void mousePressedEditorB3(java.awt.event.MouseEvent e)

mousePressedPlayerB1

public void mousePressedPlayerB1(java.awt.event.MouseEvent e)

mousePressedPlayerB3

public void mousePressedPlayerB3(java.awt.event.MouseEvent e)

mousePressed

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

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
Specified by:
componentResized in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
Specified by:
componentShown in interface java.awt.event.ComponentListener

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
Specified by:
componentHidden in interface java.awt.event.ComponentListener

actionPerformed

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

paintObjects

public void paintObjects(java.awt.Graphics g)
Paints all JDObjects of the components.

Parameters:
g - Graphics

paintSelection

public void paintSelection(java.awt.Graphics g)
Paints selection area and control points.

Parameters:
g - Graphics

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class javax.swing.JComponent

repaint

public void repaint(java.awt.Rectangle r)
Repaint the specified rectangle.

Overrides:
repaint in class javax.swing.JComponent
Parameters:
r - Rectangle to be repainted ('not zoomed' coordinates).

addToMenu

public void addToMenu(javax.swing.JMenuItem newItem)