Class NetEditor
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
fr.esrf.tangoatk.widget.util.interlock.NetEditor
- All Implemented Interfaces:
MouseListener,MouseMotionListener,ImageObserver,MenuContainer,Serializable,EventListener
- Direct Known Subclasses:
DjNetViewer,ItlkNetEditor
Network Editor component class. This class can be subclassed to create specific editor
or viewer (not editable) component.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intEditor is in bubble creation modestatic final intEditor is in link creation modestatic final intSelection mode (no creation)static final intEditor is in text creation mode (Free label)Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a NetEditor listener.booleanAdd a NetObject to the editor.booleancanRedo()booleancanUndo()voidClears the NetEditor listener list.voidClear all object in the editor.voidAsk the editor to recompute it size.voidcopy current selection to the clipboardcreateBubbleObject(int x, int y) Called when the editor adds a bubble object to the network.voidmove selection to clipbaordvoiddelete current selectionbooleanReturns true if Anti-Aliased fonts are used, false otherwisebooleangetNetObjectAt(int i) Returns the NetObject at the specified index.intbooleanReturns true is this NetEditor is editable.booleanReturns true if the editor is displaying arrow with link.voidLoad a Network file (net or xpss format) into the editor.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidnewAll()Clear the whole editor.Clipbaord remains unchanged.voidPaint the component.voidpaintLinks(Graphics2D g2) Paint link of the scheme.voidPaint object of the scheme.voidpaste clipboardvoidredo()Redo last canceled actionvoidRemove a NetEditor listener.voidremoveObject(NetObject obj) Remove a NetObject from the editor.voidsaveCurrent(String defaultDir) Save the current scheme.voidsaveNetFile(String fileName) Save the editor content to a net file.voidSelect all objects in the editor.voidsetAntialiasFont(boolean b) Sets anti aliased font usage.voidsetCreateMode(int type) Sets editor in creation mode.voidsetEditable(boolean b) Sets the specified boolean to indicate whether or not this NetEditor should be editable.voidsetFileExtension(String ext) Sets the file extension for this editor.voidSets the grid size of this NetEditor.voidsetMoveableBubble(boolean b) Allow the user to move bubble object even when the editor is not editablevoidSets the global option dialog.voidSets the object properties dialog.voidsetShowArrow(boolean b) Draws arrow with link.voidshowOpenFileDialog(String defaultDir, NetFileFilter filter) Show the file selection box and call loadFile if a file is selected.voidDisplay the global option dialogvoidshowSaveFileDialog(String defaultDir, NetFileFilter filter) Show the file selection box and call saveNetFile if a file is selected.voidundo()Undo the last actionvoidUnselect all objects in the editor.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, getBaseline, getBaselineResizeBehavior, 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, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, 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, updateUIMethods 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, transferFocusDownCycle, validate, validateTreeMethods 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, getAccessibleContext, 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, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
CREATE_NONE
public static final int CREATE_NONESelection mode (no creation)- See Also:
-
CREATE_BUBBLE
public static final int CREATE_BUBBLEEditor is in bubble creation mode- See Also:
-
CREATE_TEXT
public static final int CREATE_TEXTEditor is in text creation mode (Free label)- See Also:
-
CREATE_LINK
public static final int CREATE_LINKEditor is in link creation mode- See Also:
-
-
Constructor Details
-
NetEditor
public NetEditor()Contruct a Network Editor. It is preferable to use the constructor that gets the parent Frame else all dialogs will appear at the center of screen instead of the center of the parent component. -
NetEditor
Contruct a Network Editor.- Parameters:
parent- Parent frame
-
-
Method Details
-
setEditable
public void setEditable(boolean b) Sets the specified boolean to indicate whether or not this NetEditor should be editable. When set to false, it paints objects according to their color and they cannot be selected ,copied, deleted or moved.- Parameters:
b- the boolean to be set- See Also:
-
isEditable
-
isEditable
public boolean isEditable()Returns true is this NetEditor is editable.- Returns:
- Mode value
- See Also:
-
setFileExtension
Sets the file extension for this editor.- Parameters:
ext- File extension
-
getFileExtension
- Returns:
- the file extension of this editor
-
loadFile
Load a Network file (net or xpss format) into the editor. Trigger sizeChanged() and valueChanged() on success.- Parameters:
fileName- filename to load- Throws:
IOException- in case of failure (Contains the error message)- See Also:
-
showOpenFileDialog
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 directoryfilter- File filter, if null is specified a file filter is created with the file extension.- See Also:
-
saveNetFile
Save the editor content to a net file.- Parameters:
fileName- filename to save- Throws:
IOException- in case of failure
-
showSaveFileDialog
Show the file selection box and call saveNetFile if a file is selected. Trigger valueChanged() if a file is selected to be saved.- Parameters:
defaultDir- default directoryfilter- File filter, if null is specified a file filter is created with the default file extension.- See Also:
-
saveCurrent
Save the current scheme.- Parameters:
defaultDir- default directory for filebox if no filename has been set.- See Also:
-
setAntialiasFont
public void setAntialiasFont(boolean b) Sets anti aliased font usage. Performance can be lower on certain system when using AA fonts.- Parameters:
b- True to use Anti-Aliased font
-
getAntialiasFont
public boolean getAntialiasFont()Returns true if Anti-Aliased fonts are used, false otherwise- Returns:
- Anti-Aliased fonts usage
-
unselectAll
public void unselectAll()Unselect all objects in the editor. Does not repaint. -
selectAll
public void selectAll()Select all objects in the editor. Does not repaint. -
newAll
public void newAll()Clear the whole editor.Clipbaord remains unchanged. -
setShowArrow
public void setShowArrow(boolean b) Draws arrow with link.- Parameters:
b- True to enable arrow.
-
isShowingArrow
public boolean isShowingArrow()Returns true if the editor is displaying arrow with link.- Returns:
- arrow mode
-
setCreateMode
public void setCreateMode(int type) Sets editor in creation mode. Does not have any effects if the editor is not editable. To create bubble object, createBubbleObject() is called.- Parameters:
type- Type of object to be created- See Also:
-
createBubbleObject
Called when the editor adds a bubble object to the network. It you override this function , Do not return an Object which override NetObject, else the editor will reconvert them to NetObject during clipboard , undo or file loading operation. This function is provided to customize the editor and create bubbles with a set of extensions and various default value. If null is returned no object is added to the network.- Parameters:
x- X coordinates (GRID coordinates)y- Y coordinates (GRID coordinates)- Returns:
- Created NetObject or null to ignore
- See Also:
-
cutSelection
public void cutSelection()move selection to clipbaord -
copySelection
public void copySelection()copy current selection to the clipboard -
pasteSelection
public void pasteSelection()paste clipboard -
deleteSelection
public void deleteSelection()delete current selection -
canUndo
public boolean canUndo()- Returns:
- undo state
-
getUndoActionName
- Returns:
- the name of the last action performed
-
getRedoActionName
- Returns:
- the name of the last action undone
-
canRedo
public boolean canRedo()- Returns:
- redo state
-
undo
public void undo()Undo the last action -
redo
public void redo()Redo last canceled action -
addEditorListener
Add a NetEditor listener.- Parameters:
l- Editor listener.- See Also:
-
removeEditorListener
Remove a NetEditor listener.- Parameters:
l- Editor listener.- See Also:
-
clearEditorListener
public void clearEditorListener()Clears the NetEditor listener list.- See Also:
-
getNeedToSaveState
public boolean getNeedToSaveState()- Returns:
- true if the scheme has been modified and need to be saved
-
computePreferredSize
public void computePreferredSize()Ask the editor to recompute it size. -
getFileName
- Returns:
- the file name of the last laoded/saved net/xpss file
-
getNetObjectAt
Returns the NetObject at the specified index.- Parameters:
i- Object index- Returns:
- NetObject
-
removeObject
Remove a NetObject from the editor.- Parameters:
obj- Object to be removed
-
addObject
Add a NetObject to the editor.- Parameters:
obj- Object to be added- Returns:
- true if the object has been succesfully added.
-
clearObjects
public void clearObjects()Clear all object in the editor. -
getNetObjectNumber
public int getNetObjectNumber()- Returns:
- the number of NetObject in the editor
-
showOptionDialog
public void showOptionDialog()Display the global option dialog -
setNetEditorDialog
Sets the global option dialog. Allows to build a customized Editor option dialog.- Parameters:
dlg- NetEditor dialog
-
setNetObjectDialog
Sets the object properties dialog. Allows to build a custoimized Object editon dialog.- Parameters:
dlg- NetObjectDlg Dialog
-
setMoveableBubble
public void setMoveableBubble(boolean b) Allow the user to move bubble object even when the editor is not editable- Parameters:
b- Moveable flag
-
getParentFrame
- Returns:
- the parent frame or null
-
setGridSize
Sets the grid size of this NetEditor.- Parameters:
d- Grid dimension
-
getGridSize
- Returns:
- current grid size.
-
mouseDragged
- Specified by:
mouseDraggedin interfaceMouseMotionListener
-
mouseMoved
- Specified by:
mouseMovedin interfaceMouseMotionListener
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseExited
- Specified by:
mouseExitedin interfaceMouseListener
-
mouseClickedB3
-
mouseClickedB1
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener
-
mousePressedB1
-
mousePressedB3
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener
-
paintLinks
Paint link of the scheme. Called by paint() before paintObjects(). You can override it to custom the link painting. Here is an example code for painting all links (Note that this code not handle link selection when the editor is editable):public void paintLinks(Graphics2D g2) { g2.setColor(Color.black); for (int i = 0; i < getNetObjectNumber() ; i++) { NetObject o = getNetObjectAt(i); for (int j = 0; j < o.getChildrenNumber() ; j++ ) { o.paintLink(g2,o.getChildAt(j),true); } } }- Parameters:
g2- Graphics object- See Also:
-
paintObjects
Paint object of the scheme. Called by paint() after paintLinks(). You can override it to custom the object painting.public void paintObjects(Graphics2D g2) { for (int i = 0; i < getNetObjectNumber() ; i++) getNetObjectAt(i).paint(g2); }- Parameters:
g2- Graphics object- See Also:
-
paint
Paint the component. It is not recommended to override paint(). If you want to custom link and object painting , it is preferable to override paintLinks() and paintObjects().- Overrides:
paintin classJComponent- Parameters:
g- Graphics object- See Also:
-