simtools.diagram
Class DiagramComponent

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by simtools.diagram.DiagramComponent
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
Direct Known Subclasses:
ShapesContainer.ShapesComponent, TestComponent

public abstract class DiagramComponent
extends javax.swing.JComponent
implements javax.swing.Scrollable, java.awt.print.Printable, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.awt.event.ActionListener

This class is an abstract diagram with editor functions such as zoom, grid, multiple selection, resize, copy/cut/paste, ... and a link capabilty betwwen the elements of the diagram

Version:
1.1 2001
Author:
Claude Cazenave, Jean-Baptiste Lièvremont
See Also:
Serialized Form

Nested Class Summary
static interface DiagramComponent.ContextualDrawing
          An interface for additional drawing to be performed in specific context
static interface DiagramComponent.ContextualDrawingProvider
          An interface implemented by diagram elements which provide a ContextualDrawing when mouse button 2 is pressed on them while they are selected
 
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  DiagramAction _action
          diagram action listener
protected  java.awt.Rectangle _autoScrollRect
          a rectangle used to increase the diagram size automatically when the mouse is near the right or the bottom of the diagram
protected  javax.swing.undo.CompoundEdit _compoundEdit
          This attribute is used by classes who need to register several undoable edits once for all (e.g translation and resize)
protected  DiagramConnection _connection
          current link during linking operation
protected static java.awt.BasicStroke _dashStroke
          a stroked used to display the selection rectangle
protected static java.awt.Color _defaultColor
          the default color
protected static java.awt.BasicStroke _defaultStroke
          the default stroke
protected  boolean _dragging
          true if dragging operation is in use
protected  java.awt.Point _dragPoint
          coordiantes of the dragging start point
protected static java.awt.Color _gridColor
          the grid color
protected  java.lang.String _headerTitle
          Deprecated. Use _param.headerTitle
protected  DiagramConnector _inputConnector
          current link input during linking operation
protected  boolean _linking
          true if linking operation is in use
protected  javax.swing.event.EventListenerList _listenerList
          List of listeners, used by undo/redo feature
protected  DiagramConnector _outputConnector
          current link ouput during linking operation
protected  DiagramParameters _param
          diagram parameters (zoom, grid,...)
protected  javax.swing.JPopupMenu _popup
          diagram popup menu called when the right mouse buttom is clicked
protected  boolean _printSelectionOnly
          Do we print just the diagram selection or everything?
protected  int _resizeWay
          resize way : N = 1, NE =2 , ...
protected  DiagramSelection _selection
          diagram selection
protected static java.awt.Color _selectionColor
          the selection color
protected  java.awt.Dimension _size
          the diagram size
protected  boolean _translating
          true if translation operation is in use
protected  UndoHandler _undoHandler
          The UndoHandler catches undoable edits and sends them to the UndoManager
protected  javax.swing.undo.UndoManager _undoManager
           
protected  boolean autofit
          If autofit is true, the diagram shall automatically fill up all the space when put in a JViewPort If autofit is false, the diagram Default is true
protected  boolean canEdit
          Can we edit the diagram Default is true
protected  DiagramComponent.ContextualDrawing contextualDrawing
          The current contextual drawing
protected  boolean fullScreen
          Full screen variable is true when this mode is active
protected  java.awt.GraphicsDevice fullScreenDevice
           
protected  javax.swing.JFrame fullScreenFrame
           
protected  boolean hasBeenModified
          This attribute is true whenever the diagam component has been modified since last backup
protected  java.awt.Container 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
DiagramComponent(DiagramParameters param)
          Creates a new diagram
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void addUndoableEventListener(javax.swing.event.UndoableEditListener listener)
          Adds an UndoableEditListener to the list of event listeners, to provide the component with undo/redo features.
 void adjust()
          Adjusts the diagram size to take into account components at the left of the left margin or upper the top margin
 void align()
          Aligns the selection on the grid
protected  double computePrintScaleFactor(java.awt.print.PageFormat pf)
          Computes the scale factor between parameter space and paper coordinates
protected abstract  void copyAt(java.util.Vector v, int x, int y)
          To copy a list of diagram elements at the given coordinates
protected abstract  DiagramConnection createConnection(DiagramConnector input, int x, int y)
          This method is called to create a new link
 void createSelection()
          Creates a default diagram selection
 void disableEditing(boolean s)
          Enable/disable diagram editing
protected abstract  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 abstract  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 drawDiagram(java.awt.Graphics2D g2)
          Paints the diagram itself
protected abstract  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
 void drawDiagramWithHeader(java.awt.Graphics2D g2)
          Paints the diagram and a header
protected  void drawHeader(java.awt.Graphics2D g2)
           
 void executeClipboardPaste()
          Pastes the clipbaord content into the diagram
 void executeConnectionCreation()
          Starts the creation of a link between a selected connector (input of the link) and a ouput connector to be selected later
 void executeNewElement()
          Starts the creation of a new element This implementation creates nothing
 void executeSelectAll()
          Select all the shapes
 void executeSelectConnectors()
          Select the connectors connected to the selected elements This implementation selectes nothing
 void executeSelectionCopy()
          Puts a copy of the selection into the clipbaord
 void executeSelectionCut()
          Cuts the selection and put a copy into the clipbaord
 void executeSelectionDelete()
          Erases the selection
 void fireUndoableEditUpdate(javax.swing.event.UndoableEditEvent event)
          Notify all UndoableEditListener that an UndoableEditEvent has happened.
 DiagramAction getAction()
          Gets the diagram action listener
 DiagramComponent.ContextualDrawing getContextualDrawing()
          Gets the current contextual drawing element
 int getDiagramHeight()
          Gets the diagram start height
 java.awt.Point getDiagramMaxPoint(java.awt.Graphics2D g2)
          Gets max size of the diagram if printed
 DiagramSelection getDiagramSelection()
          Gets the selection
 int getDiagramWidth()
          Gets the diagram start width
 int getGrid()
          Gets the diagram grid step
 boolean getGridDisplay()
          Gets the diagram grid display status
 int getHeaderHeight()
          Gets the diagram header height for printing
protected abstract  void getMin(java.awt.Point p)
          Gets the coordinates ot the element at the top left of the diagram
 java.lang.String getName()
          Gets the name of the diagram
 DiagramParameters getParameters()
          Get the diagram parameters
 javax.swing.JPopupMenu getPopupMenu()
          Gets the diagram popup menu
 java.awt.Dimension getPreferredScrollableViewportSize()
          Returns the preferred display size of a Canvas.
 int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
          Returns the amount for a block inrecment, which is the height or width of visibleRect, based on orientation.
 boolean getScrollableTracksViewportHeight()
          Returns false to indicate that the height of the viewport does not determine the height of the table, unless the preferred height of the canvas is smaller than the viewports height.
 boolean getScrollableTracksViewportWidth()
          Returns false to indicate that the width of the viewport does not determine the width of the table, unless the preferred width of the canvas is smaller than the viewports width.
 int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
          Returns the amount to increment when scrolling.
 java.util.Vector getSelection()
          Gets the selection elements
 DiagramConnector getSelectionConnector()
          Gets a connector form the selection If the first element in the selection is a connector then return this connector else return null.
 UndoHandler getUndoHandler()
           
 int getXMargin()
          Gets the diagram left and right margin
 int getYMargin()
          Gets the diagram top and bottom margin
 double getZoom()
          Gets the diagram zoom factor
 boolean hasBeenModified()
           
 boolean hasHeader()
          If we have a valid header
 boolean isAutofit()
           
 boolean isEditingDisbled()
          Check if diagram editing is disabled
 boolean isFullScreen()
           
static boolean isMouseButton2(java.awt.event.MouseEvent e)
           
 boolean isSelectionEmpty()
          Checks if selection is empty
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
           
 void paint(java.awt.Graphics g)
          Paints the diagram according to zoom and grid This methods setup the transformation, draw the grid and the call the drawDiagram method.
protected abstract  void performConnection(DiagramConnection c, DiagramConnector input, DiagramConnector output)
          This method is called to connect a new link to its output connector
 int print(java.awt.Graphics g, java.awt.print.PageFormat pf, int pnum)
           
 void printDiagram(java.awt.Graphics2D g2)
          Paints the diagram itself
protected abstract  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
protected  void registerActions()
           
 void removeUndoableEventListener(javax.swing.event.UndoableEditListener listener)
          Removes an UndoableEditListener from the list of event listeners.
 void repaint(java.awt.Rectangle r)
           
 void repaint(java.awt.Rectangle r, boolean withMargins)
           
protected  void resizeEnd()
          This method is called at the end of the resize of the selection i.e when the mouse is released
 void setAction(DiagramAction act)
          Sets the diagram action listener Only one action listener is allowed
 void setAutofit(boolean autofit)
           
 void setContextualDrawing(DiagramComponent.ContextualDrawing cd)
          Install a new contextual drawing element
 void setDiagramSize(int w, int h)
          Sets the diagram start size
 void setFullScreen(boolean fullScreenState)
          Use this function with "false" as argument to exit full screen mode.
 void setFullScreen(java.awt.GraphicsDevice device)
          Use this method with a valid graphics device to enter full screen mode.
 void setGrid(int grid)
          Sets the diagram grid step
 void setGridDisplay(boolean state)
          Sets the diagram grid display status
 void setHasBeenModified(boolean hasBeenModified)
          Set the diagram modification status
 void setHeader(java.lang.String header)
          Sets the header for this diagram component
 void setHeaderHeight(int h)
          Sets the diagram header height for printing
 void setMargin(int x, int y)
          Sets the diagram margins
 void setName(java.lang.String name)
          Sets the name of the diagram
 void setPopupMenu(javax.swing.JPopupMenu menu)
          Sets the digram popup menu
 void setSelectionPrintMode(boolean selectionOnly)
          Sets the print mode
 void setZoom(double scale)
          Sets the diagram zoom factor
 java.lang.String toString()
          Gets the name of the diagram
protected abstract  void translate(int x, int y)
          Abstract method to translate the diagram elements
protected abstract  void translateConnection(DiagramConnection c, int dx, int dy)
          This method is called to move the end of the link after creation
protected  void translationEnd()
          This method is called at the end of the transaltion of the selection i.e when the mouse is released
 
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, 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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_dashStroke

protected static java.awt.BasicStroke _dashStroke
a stroked used to display the selection rectangle


_defaultStroke

protected static java.awt.BasicStroke _defaultStroke
the default stroke


_gridColor

protected static java.awt.Color _gridColor
the grid color


_selectionColor

protected static java.awt.Color _selectionColor
the selection color


_defaultColor

protected static java.awt.Color _defaultColor
the default color


_size

protected java.awt.Dimension _size
the diagram size


_autoScrollRect

protected java.awt.Rectangle _autoScrollRect
a rectangle used to increase the diagram size automatically when the mouse is near the right or the bottom of the diagram


_dragging

protected boolean _dragging
true if dragging operation is in use


_dragPoint

protected java.awt.Point _dragPoint
coordiantes of the dragging start point


_linking

protected boolean _linking
true if linking operation is in use


_translating

protected boolean _translating
true if translation operation is in use


_resizeWay

protected int _resizeWay
resize way : N = 1, NE =2 , ...


_connection

protected DiagramConnection _connection
current link during linking operation


_inputConnector

protected DiagramConnector _inputConnector
current link input during linking operation


_outputConnector

protected DiagramConnector _outputConnector
current link ouput during linking operation


_selection

protected DiagramSelection _selection
diagram selection


_printSelectionOnly

protected boolean _printSelectionOnly
Do we print just the diagram selection or everything?


_param

protected DiagramParameters _param
diagram parameters (zoom, grid,...)


_action

protected DiagramAction _action
diagram action listener


_popup

protected javax.swing.JPopupMenu _popup
diagram popup menu called when the right mouse buttom is clicked


_headerTitle

protected java.lang.String _headerTitle
Deprecated. Use _param.headerTitle

autofit

protected boolean autofit
If autofit is true, the diagram shall automatically fill up all the space when put in a JViewPort If autofit is false, the diagram Default is true


canEdit

protected boolean canEdit
Can we edit the diagram Default is true


fullScreen

protected boolean fullScreen
Full screen variable is true when this mode is active


fullScreenDevice

protected java.awt.GraphicsDevice fullScreenDevice

fullScreenFrame

protected javax.swing.JFrame fullScreenFrame

windowedModeParent

protected java.awt.Container windowedModeParent

_listenerList

protected transient javax.swing.event.EventListenerList _listenerList
List of listeners, used by undo/redo feature


_undoHandler

protected transient UndoHandler _undoHandler
The UndoHandler catches undoable edits and sends them to the UndoManager


_undoManager

protected transient javax.swing.undo.UndoManager _undoManager

_compoundEdit

protected transient javax.swing.undo.CompoundEdit _compoundEdit
This attribute is used by classes who need to register several undoable edits once for all (e.g translation and resize)


contextualDrawing

protected DiagramComponent.ContextualDrawing contextualDrawing
The current contextual drawing

See Also:
DiagramComponent.ContextualDrawing

hasBeenModified

protected transient boolean hasBeenModified
This attribute is true whenever the diagam component has been modified since last backup

Constructor Detail

DiagramComponent

public DiagramComponent(DiagramParameters param)
Creates a new diagram

Parameters:
the - diagram parameters
Method Detail

disableEditing

public void disableEditing(boolean s)
Enable/disable diagram editing

Parameters:
s - true to disable editing

isEditingDisbled

public boolean isEditingDisbled()
Check if diagram editing is disabled

Returns:
true if editing is disabled

getParameters

public DiagramParameters getParameters()
Get the diagram parameters


setPopupMenu

public void setPopupMenu(javax.swing.JPopupMenu menu)
Sets the digram popup menu

Parameters:
menu - the new popup menu

getPopupMenu

public javax.swing.JPopupMenu getPopupMenu()
Gets the diagram popup menu

Returns:
the popup menu or null if none

setAction

public void setAction(DiagramAction act)
Sets the diagram action listener Only one action listener is allowed

Parameters:
act - the listener

getAction

public DiagramAction getAction()
Gets the diagram action listener

Returns:
the listener

createSelection

public void createSelection()
Creates a default diagram selection


getName

public java.lang.String getName()
Gets the name of the diagram

Overrides:
getName in class java.awt.Component
Returns:
the name

hasBeenModified

public boolean hasBeenModified()
Returns:
true if the diagram has been modified since its last backup

setName

public void setName(java.lang.String name)
Sets the name of the diagram

Overrides:
setName in class java.awt.Component
Parameters:
name - the name

setHasBeenModified

public void setHasBeenModified(boolean hasBeenModified)
Set the diagram modification status


toString

public java.lang.String toString()
Gets the name of the diagram

Overrides:
toString in class java.awt.Component
Returns:
the name

isAutofit

public boolean isAutofit()
Returns:

setAutofit

public void setAutofit(boolean autofit)
Parameters:
autofit -

getXMargin

public int getXMargin()
Gets the diagram left and right margin

Returns:
the margin

getYMargin

public int getYMargin()
Gets the diagram top and bottom margin

Returns:
the margin

setMargin

public void setMargin(int x,
                      int y)
Sets the diagram margins

Parameters:
x - the left and right margin
y - the top and bottom margin

getHeaderHeight

public int getHeaderHeight()
Gets the diagram header height for printing

Returns:
the height

setHeaderHeight

public void setHeaderHeight(int h)
Sets the diagram header height for printing

Parameters:
h - the height

setDiagramSize

public void setDiagramSize(int w,
                           int h)
Sets the diagram start size

Parameters:
w - the width
h - the height

getDiagramWidth

public int getDiagramWidth()
Gets the diagram start width

Returns:
the width

getDiagramHeight

public int getDiagramHeight()
Gets the diagram start height

Returns:
the height

setGrid

public void setGrid(int grid)
Sets the diagram grid step

Parameters:
grid - the step (if =0 then no grid)

setGridDisplay

public void setGridDisplay(boolean state)
Sets the diagram grid display status

Parameters:
state - =true to display the grid

getGrid

public int getGrid()
Gets the diagram grid step

Returns:
the step (if =0 then no grid)

getGridDisplay

public boolean getGridDisplay()
Gets the diagram grid display status

Returns:
true if the gris is displayed

setZoom

public void setZoom(double scale)
Sets the diagram zoom factor

Parameters:
scale - the scale factor

getZoom

public double getZoom()
Gets the diagram zoom factor

Returns:
the scale factor

adjust

public void adjust()
Adjusts the diagram size to take into account components at the left of the left margin or upper the top margin


align

public void align()
Aligns the selection on the grid


paint

public void paint(java.awt.Graphics g)
Paints the diagram according to zoom and grid This methods setup the transformation, draw the grid and the call the drawDiagram method.

Overrides:
paint in class javax.swing.JComponent
Parameters:
g - the current graphics

repaint

public void repaint(java.awt.Rectangle r)
Overrides:
repaint in class javax.swing.JComponent

repaint

public void repaint(java.awt.Rectangle r,
                    boolean withMargins)

drawDiagram

protected void drawDiagram(java.awt.Graphics2D g2)
Paints the diagram itself

Parameters:
g2 - the current graphics

drawHeader

protected void drawHeader(java.awt.Graphics2D g2)

printDiagram

public void printDiagram(java.awt.Graphics2D g2)
Paints the diagram itself

Parameters:
g2 - the current graphics

getDiagramMaxPoint

public java.awt.Point getDiagramMaxPoint(java.awt.Graphics2D g2)
Gets max size of the diagram if printed

Parameters:
g2 - the current graphics
Returns:
the diagram right/bottom corner coordinates

setHeader

public void setHeader(java.lang.String header)
Sets the header for this diagram component

Parameters:
header - The diagram header to print

hasHeader

public boolean hasHeader()
If we have a valid header


setSelectionPrintMode

public void setSelectionPrintMode(boolean selectionOnly)
Sets the print mode

Parameters:
selectionOnly - If true, will print only the selection

drawDiagramWithHeader

public void drawDiagramWithHeader(java.awt.Graphics2D g2)
Paints the diagram and a header

Parameters:
g2 - the current graphics

executeNewElement

public void executeNewElement()
Starts the creation of a new element This implementation creates nothing


executeSelectAll

public void executeSelectAll()
Select all the shapes


executeSelectConnectors

public void executeSelectConnectors()
Select the connectors connected to the selected elements This implementation selectes nothing


executeConnectionCreation

public void executeConnectionCreation()
Starts the creation of a link between a selected connector (input of the link) and a ouput connector to be selected later


executeSelectionCut

public void executeSelectionCut()
Cuts the selection and put a copy into the clipbaord


executeSelectionDelete

public void executeSelectionDelete()
Erases the selection


executeSelectionCopy

public void executeSelectionCopy()
Puts a copy of the selection into the clipbaord


executeClipboardPaste

public void executeClipboardPaste()
Pastes the clipbaord content into the diagram


isSelectionEmpty

public boolean isSelectionEmpty()
Checks if selection is empty

Returns:
true if it is empty

getSelection

public java.util.Vector getSelection()
Gets the selection elements

Returns:
a vector of elements

getDiagramSelection

public DiagramSelection getDiagramSelection()
Gets the selection

Returns:
the diagram selection

getSelectionConnector

public DiagramConnector getSelectionConnector()
Gets a connector form the selection If the first element in the selection is a connector then return this connector else return null.

Returns:
the connector or null

translate

protected abstract void translate(int x,
                                  int y)
Abstract method to translate the diagram elements

Parameters:
x - translation value along the X axis
y - translation value along the Y axis

getMin

protected abstract void getMin(java.awt.Point p)
Gets the coordinates ot the element at the top left of the diagram

Parameters:
p - the coordinates to be compared with the elements coordinates and to be modified if an element has lower coordinates

copyAt

protected abstract void copyAt(java.util.Vector v,
                               int x,
                               int y)
To copy a list of diagram elements at the given coordinates

Parameters:
v - a vector of diagram elements
x - the x coordinate destination
y - the y coordinate destination

drawDiagramElements

protected abstract 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

Parameters:
g2 - the current graphics
pMax - the coordinates of the elements at the bottom right

printDiagramElements

protected abstract 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

Parameters:
g2 - the current graphics
pMax - the coordinates of the elements at the bottom right

drawClipboardElements

protected abstract 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

Parameters:
g2 - the current graphics
pMax - the coordinates of the elements at the bottom right

drawConnection

protected abstract 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

Parameters:
g2 - the current graphics
pMax - the coordinates of the elements at the bottom right

createConnection

protected abstract DiagramConnection createConnection(DiagramConnector input,
                                                      int x,
                                                      int y)
This method is called to create a new link

Parameters:
input - the input connector
x - the end link x coordinate
y - the end link y coordinate

translateConnection

protected abstract void translateConnection(DiagramConnection c,
                                            int dx,
                                            int dy)
This method is called to move the end of the link after creation

Parameters:
c - the link
dx - the end link move along x axis
dy - the end link moce along y axis

performConnection

protected abstract void performConnection(DiagramConnection c,
                                          DiagramConnector input,
                                          DiagramConnector output)
This method is called to connect a new link to its output connector

Parameters:
c - the link
input - the input connector
output - the output connector

translationEnd

protected void translationEnd()
This method is called at the end of the transaltion of the selection i.e when the mouse is released


resizeEnd

protected void resizeEnd()
This method is called at the end of the resize of the selection i.e when the mouse is released


mouseClicked

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

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

mousePressed

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

mouseReleased

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

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

mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener

actionPerformed

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

computePrintScaleFactor

protected double computePrintScaleFactor(java.awt.print.PageFormat pf)
Computes the scale factor between parameter space and paper coordinates

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

print

public int print(java.awt.Graphics g,
                 java.awt.print.PageFormat pf,
                 int pnum)
          throws java.awt.print.PrinterException
Specified by:
print in interface java.awt.print.Printable
Throws:
java.awt.print.PrinterException

getPreferredScrollableViewportSize

public java.awt.Dimension getPreferredScrollableViewportSize()
Returns the preferred display size of a Canvas.

Specified by:
getPreferredScrollableViewportSize in interface javax.swing.Scrollable
Returns:
a Dimension object containing the preferred size

getScrollableUnitIncrement

public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
                                      int orientation,
                                      int direction)
Returns the amount to increment when scrolling.

Specified by:
getScrollableUnitIncrement in interface javax.swing.Scrollable
Parameters:
visibleRect - The view area visible within the viewport
orientation - Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
direction - Less than zero to scroll up/left, greater than zero for down/right.
Returns:
The "unit" increment for scrolling in the specified direction
See Also:
JScrollBar.setUnitIncrement(int)

getScrollableBlockIncrement

public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
                                       int orientation,
                                       int direction)
Returns the amount for a block inrecment, which is the height or width of visibleRect, based on orientation.

Specified by:
getScrollableBlockIncrement in interface javax.swing.Scrollable
Parameters:
visibleRect - The view area visible within the viewport
orientation - Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
direction - Less than zero to scroll up/left, greater than zero for down/right.
Returns:
The "block" increment for scrolling in the specified direction.
See Also:
JScrollBar.setBlockIncrement(int)

getScrollableTracksViewportWidth

public boolean getScrollableTracksViewportWidth()
Returns false to indicate that the width of the viewport does not determine the width of the table, unless the preferred width of the canvas is smaller than the viewports width. In other words: ensure that the canvas is never smaller than its viewport.

Specified by:
getScrollableTracksViewportWidth in interface javax.swing.Scrollable
Returns:
false
See Also:
Scrollable.getScrollableTracksViewportWidth()

getScrollableTracksViewportHeight

public boolean getScrollableTracksViewportHeight()
Returns false to indicate that the height of the viewport does not determine the height of the table, unless the preferred height of the canvas is smaller than the viewports height. In other words: ensure that the canvas is never smaller than its viewport.

Specified by:
getScrollableTracksViewportHeight in interface javax.swing.Scrollable
Returns:
false
See Also:
Scrollable.getScrollableTracksViewportHeight()

registerActions

protected void registerActions()

isFullScreen

public boolean isFullScreen()
Returns:
Returns the fullScreen status.

setFullScreen

public void setFullScreen(boolean fullScreenState)
Use this function with "false" as argument to exit full screen mode. When using "true" as argument, this methods only works if a graphics device was previously specified using the other setFullScreen method.

Parameters:
fullScreen - The fullScreen mode to set.

setFullScreen

public void setFullScreen(java.awt.GraphicsDevice device)
Use this method with a valid graphics device to enter full screen mode. Use null as argument to exit full screen mode.


addUndoableEventListener

public void addUndoableEventListener(javax.swing.event.UndoableEditListener listener)
Adds an UndoableEditListener to the list of event listeners, to provide the component with undo/redo features.

Parameters:
listener -

removeUndoableEventListener

public void removeUndoableEventListener(javax.swing.event.UndoableEditListener listener)
Removes an UndoableEditListener from the list of event listeners.

Parameters:
listener -
See Also:
addUndoableEventListener(UndoableEditListener)

fireUndoableEditUpdate

public void fireUndoableEditUpdate(javax.swing.event.UndoableEditEvent event)
Notify all UndoableEditListener that an UndoableEditEvent has happened.

Parameters:
event -

getUndoHandler

public UndoHandler getUndoHandler()
Returns:
Returns the UndoHandler associated with this component

setContextualDrawing

public void setContextualDrawing(DiagramComponent.ContextualDrawing cd)
Install a new contextual drawing element

Parameters:
cd - the element

getContextualDrawing

public DiagramComponent.ContextualDrawing getContextualDrawing()
Gets the current contextual drawing element

Returns:
the element or null if none installed

isMouseButton2

public static boolean isMouseButton2(java.awt.event.MouseEvent e)