simtools.shapes
Class ShapesContainer.ShapesComponent

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by simtools.diagram.DiagramComponent
                  extended by simtools.shapes.ShapesContainer.ShapesComponent
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable, java.util.EventListener, javax.swing.Scrollable, ShapeListener
Direct Known Subclasses:
ShapesContainer.ShapesComponent
Enclosing class:
ShapesContainer

public class ShapesContainer.ShapesComponent
extends DiagramComponent
implements ShapeListener

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class simtools.diagram.DiagramComponent
DiagramComponent.ContextualDrawing, DiagramComponent.ContextualDrawingProvider
 
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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.util.HashMap paintedAreas
          An hash table to gather the shape changed events
protected  java.util.Timer timer
          This timer is used to gather shape changed events and send them at a reasonable rate to Swing.
protected  java.lang.Object timerLock
           
 
Fields inherited from class simtools.diagram.DiagramComponent
_action, _autoScrollRect, _compoundEdit, _connection, _dashStroke, _defaultColor, _defaultStroke, _dragging, _dragPoint, _gridColor, _headerTitle, _inputConnector, _linking, _listenerList, _outputConnector, _param, _popup, _printSelectionOnly, _resizeWay, _selection, _selectionColor, _size, _translating, _undoHandler, _undoManager, autofit, canEdit, contextualDrawing, fullScreen, fullScreenDevice, fullScreenFrame, hasBeenModified, windowedModeParent
 
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.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ShapesContainer.ShapesComponent(DiagramParameters param)
           
 
Method Summary
 boolean canGroup()
           
 boolean canReGroup()
          Regroup action is possible when one of the selected shapes is contained into one of the recorded compound shapes
 boolean canUnGroup()
           
protected  double computePrintScaleFactor(java.awt.print.PageFormat pf)
          Computes the scale factor between parameter space and paper coordinates
protected  void copyAt(java.util.Vector v, int x, int y)
          To copy a list of diagram elements at the given coordinates
protected  DiagramConnection createConnection(DiagramConnector input, int x, int y)
          This method is called to create a new link
 void createSelection()
          Creates a default diagram selection
protected  void drawBounds(java.awt.Graphics2D g2, AbstractShape s)
           
protected  void drawBounds(java.awt.Graphics2D g2, DiagramSelectedShape dss)
           
protected  void drawClipboardElements(java.awt.Graphics2D g2, java.awt.Point pMax)
          This method is called by the drawDiagram method to perform the drawing of each clipboard elements
protected  void drawConnection(java.awt.Graphics2D g2, java.awt.Point pMax)
          This method is called by the drawDiagram method to perform the drawing of a new link
protected  void drawDiagramElements(java.awt.Graphics2D g2, java.awt.Point pMax)
          This method is called by the drawDiagram method to perform the drawing of each diagram elements
protected  void finalize()
          Override finalize to make sure we stop thread and remove all listeners
 void fireUndoableEditUpdate(javax.swing.event.UndoableEditEvent _e)
          Notify all UndoableEditListener that an UndoableEditEvent has happened.
 ShapesContainer getContainer()
           
protected  void getMin(java.awt.Point p)
          Gets the coordinates ot the element at the top left of the diagram
 java.awt.Shape getShapeAt(int ox, int oy)
           
 void group()
           
protected  void performConnection(DiagramConnection c, DiagramConnector input, DiagramConnector output)
          This method is called to connect a new link to its output connector
 void performCreate(AbstractShape shape)
           
protected  void printDiagramElements(java.awt.Graphics2D g2, java.awt.Point pMax)
          This method is called by the drawDiagram method to perform the printing of each diagram elements
 void redoGroup(CompoundShape cs, java.util.Vector shapesDeletedInCompoundShapes, java.util.Vector deletedFromOldCompounds)
          redo group operation
 void redoReGroup(java.util.Vector compoundShapes, java.util.Vector shapesDeletedInCompoundShapes)
          redo regroup operation
 void redoUngroup(CompoundShape compoundShape)
          redo ungroup operation
 void reGroup()
           
 void repaint()
           
 void resizeEnd()
          Overridden in order to handle Undo/Redo on resize events.
 void shapeChanged(AbstractShape shape, java.awt.Rectangle changedArea)
          A cyclic task ensures that repainted requests are not performed faster than an configurable parameter In addition, if several updates on a given shapes are performed during this configurable period then the painted area of that shape is growing if different rectangles of painting are required but the shape will be painted one time only
protected  void translate(int x, int y)
          Abstract method to translate the diagram elements
protected  void translateConnection(DiagramConnection c, int dx, int dy)
          This method is called to move the end of the link after creation
 void translationEnd()
          Overridden in order to handle Undo/Redo on translation events.
 void undoGroup(CompoundShape cs, java.util.Vector shapesDeletedInCompoundShapes, java.util.Vector deletedFromOldCompounds)
          undo group operation
 void undoReGroup(java.util.Vector compoundShapes, java.util.Vector shapesDeletedInCompoundShapes)
          undo regroup operation
 void undoUngroup(CompoundShape compoundShape)
          Undo ungroup operation
 void unGroup()
          unGroup operation
 
Methods inherited from class simtools.diagram.DiagramComponent
actionPerformed, addUndoableEventListener, adjust, align, disableEditing, drawDiagram, drawDiagramWithHeader, drawHeader, executeClipboardPaste, executeConnectionCreation, executeNewElement, executeSelectAll, executeSelectConnectors, executeSelectionCopy, executeSelectionCut, executeSelectionDelete, getAction, getContextualDrawing, getDiagramHeight, getDiagramMaxPoint, getDiagramSelection, getDiagramWidth, getGrid, getGridDisplay, getHeaderHeight, getName, getParameters, getPopupMenu, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelection, getSelectionConnector, getUndoHandler, getXMargin, getYMargin, getZoom, hasBeenModified, hasHeader, isAutofit, isEditingDisbled, isFullScreen, isMouseButton2, isSelectionEmpty, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, paint, print, printDiagram, registerActions, removeUndoableEventListener, repaint, repaint, setAction, setAutofit, setContextualDrawing, setDiagramSize, setFullScreen, setFullScreen, setGrid, setGridDisplay, setHasBeenModified, setHeader, setHeaderHeight, setMargin, setName, setPopupMenu, setSelectionPrintMode, setZoom, toString
 
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, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, setPreferredSize, 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, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

timer

protected java.util.Timer timer
This timer is used to gather shape changed events and send them at a reasonable rate to Swing.


timerLock

protected final java.lang.Object timerLock

paintedAreas

protected java.util.HashMap paintedAreas
An hash table to gather the shape changed events

Constructor Detail

ShapesContainer.ShapesComponent

public ShapesContainer.ShapesComponent(DiagramParameters param)
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Override finalize to make sure we stop thread and remove all listeners

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

getContainer

public ShapesContainer getContainer()

createSelection

public void createSelection()
Description copied from class: DiagramComponent
Creates a default diagram selection

Overrides:
createSelection in class DiagramComponent

canGroup

public boolean canGroup()

canUnGroup

public boolean canUnGroup()

canReGroup

public boolean canReGroup()
Regroup action is possible when one of the selected shapes is contained into one of the recorded compound shapes

Returns:

group

public void group()

undoGroup

public void undoGroup(CompoundShape cs,
                      java.util.Vector shapesDeletedInCompoundShapes,
                      java.util.Vector deletedFromOldCompounds)
undo group operation

Parameters:
shapes -

redoGroup

public void redoGroup(CompoundShape cs,
                      java.util.Vector shapesDeletedInCompoundShapes,
                      java.util.Vector deletedFromOldCompounds)
redo group operation

Parameters:
shapes -

unGroup

public void unGroup()
unGroup operation


undoUngroup

public void undoUngroup(CompoundShape compoundShape)
Undo ungroup operation

Parameters:
old - compound shape to restore

redoUngroup

public void redoUngroup(CompoundShape compoundShape)
redo ungroup operation

Parameters:
old - compound shape to restore

reGroup

public void reGroup()

undoReGroup

public void undoReGroup(java.util.Vector compoundShapes,
                        java.util.Vector shapesDeletedInCompoundShapes)
undo regroup operation

Parameters:
shapes -

redoReGroup

public void redoReGroup(java.util.Vector compoundShapes,
                        java.util.Vector shapesDeletedInCompoundShapes)
redo regroup operation

Parameters:
shapes -

translate

protected void translate(int x,
                         int y)
Description copied from class: DiagramComponent
Abstract method to translate the diagram elements

Specified by:
translate in class DiagramComponent
Parameters:
x - translation value along the X axis
y - translation value along the Y axis

getMin

protected void getMin(java.awt.Point p)
Description copied from class: DiagramComponent
Gets the coordinates ot the element at the top left of the diagram

Specified by:
getMin in class DiagramComponent
Parameters:
p - the coordinates to be compared with the elements coordinates and to be modified if an element has lower coordinates

copyAt

protected void copyAt(java.util.Vector v,
                      int x,
                      int y)
Description copied from class: DiagramComponent
To copy a list of diagram elements at the given coordinates

Specified by:
copyAt in class DiagramComponent
Parameters:
v - a vector of diagram elements
x - the x coordinate destination
y - the y coordinate destination

getShapeAt

public java.awt.Shape getShapeAt(int ox,
                                 int oy)

drawDiagramElements

protected void drawDiagramElements(java.awt.Graphics2D g2,
                                   java.awt.Point pMax)
Description copied from class: DiagramComponent
This method is called by the drawDiagram method to perform the drawing of each diagram elements

Specified by:
drawDiagramElements in class DiagramComponent
Parameters:
g2 - the current graphics
pMax - the coordinates of the elements at the bottom right

drawBounds

protected void drawBounds(java.awt.Graphics2D g2,
                          DiagramSelectedShape dss)

drawBounds

protected void drawBounds(java.awt.Graphics2D g2,
                          AbstractShape s)

drawClipboardElements

protected void drawClipboardElements(java.awt.Graphics2D g2,
                                     java.awt.Point pMax)
Description copied from class: DiagramComponent
This method is called by the drawDiagram method to perform the drawing of each clipboard elements

Specified by:
drawClipboardElements in class DiagramComponent
Parameters:
g2 - the current graphics
pMax - the coordinates of the elements at the bottom right

printDiagramElements

protected void printDiagramElements(java.awt.Graphics2D g2,
                                    java.awt.Point pMax)
Description copied from class: DiagramComponent
This method is called by the drawDiagram method to perform the printing of each diagram elements

Specified by:
printDiagramElements in class DiagramComponent
Parameters:
g2 - the current graphics
pMax - the coordinates of the elements at the bottom right

computePrintScaleFactor

protected double computePrintScaleFactor(java.awt.print.PageFormat pf)
Description copied from class: DiagramComponent
Computes the scale factor between parameter space and paper coordinates

Overrides:
computePrintScaleFactor in class DiagramComponent
Parameters:
pf - The PageFormat to se for printing
Returns:
The number by which to scale the Graphics so that parameter coordinates are correct.

drawConnection

protected void drawConnection(java.awt.Graphics2D g2,
                              java.awt.Point pMax)
Description copied from class: DiagramComponent
This method is called by the drawDiagram method to perform the drawing of a new link

Specified by:
drawConnection in class DiagramComponent
Parameters:
g2 - the current graphics
pMax - the coordinates of the elements at the bottom right

createConnection

protected DiagramConnection createConnection(DiagramConnector input,
                                             int x,
                                             int y)
Description copied from class: DiagramComponent
This method is called to create a new link

Specified by:
createConnection in class DiagramComponent
Parameters:
input - the input connector
x - the end link x coordinate
y - the end link y coordinate

translateConnection

protected void translateConnection(DiagramConnection c,
                                   int dx,
                                   int dy)
Description copied from class: DiagramComponent
This method is called to move the end of the link after creation

Specified by:
translateConnection in class DiagramComponent
Parameters:
c - the link
dx - the end link move along x axis
dy - the end link moce along y axis

performConnection

protected void performConnection(DiagramConnection c,
                                 DiagramConnector input,
                                 DiagramConnector output)
Description copied from class: DiagramComponent
This method is called to connect a new link to its output connector

Specified by:
performConnection in class DiagramComponent
Parameters:
c - the link
input - the input connector
output - the output connector

shapeChanged

public void shapeChanged(AbstractShape shape,
                         java.awt.Rectangle changedArea)
A cyclic task ensures that repainted requests are not performed faster than an configurable parameter In addition, if several updates on a given shapes are performed during this configurable period then the painted area of that shape is growing if different rectangles of painting are required but the shape will be painted one time only

Specified by:
shapeChanged in interface ShapeListener
See Also:
ShapeListener.shapeChanged(simtools.shapes.AbstractShape, java.awt.Rectangle)

repaint

public void repaint()
Overrides:
repaint in class java.awt.Component

translationEnd

public void translationEnd()
Overridden in order to handle Undo/Redo on translation events.

Overrides:
translationEnd in class DiagramComponent

resizeEnd

public void resizeEnd()
Overridden in order to handle Undo/Redo on resize events.

Overrides:
resizeEnd in class DiagramComponent

performCreate

public void performCreate(AbstractShape shape)

fireUndoableEditUpdate

public void fireUndoableEditUpdate(javax.swing.event.UndoableEditEvent _e)
Description copied from class: DiagramComponent
Notify all UndoableEditListener that an UndoableEditEvent has happened.

Overrides:
fireUndoableEditUpdate in class DiagramComponent