public class Diagram
extends javax.swing.JPanel
This class displays the workflow diagram.
A diagram node is built for each workflow node and the relationships attached to it. The entering and leaving relationships are ordered based on the destination and origin. This removes as much line interferance as possible without reorganizing the nodes. Each line is routed using the vertical and horizontal channels between each row and column. The node postions are then calculated based on the channels size. The paint code draws each line absed on the channels it goes through.
javax.swing.JPanel.AccessibleJPanel
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
protected java.util.Hashtable |
channels |
protected java.util.Hashtable |
channelSet |
protected int |
columnCount |
protected int[] |
columns |
protected DiagramConfiguration |
configuration |
protected static int[] |
curvePoints |
protected static int |
DASH_LENGTH |
protected static int |
GAP_LENGTH |
protected static int |
LINE_NEGATIVE |
protected static int |
LINE_NORMAL |
protected static int |
LINE_SELECTED |
protected java.util.TreeSet |
lines |
protected java.util.Vector |
listeners |
protected java.util.Hashtable |
nodeIndex |
protected java.util.TreeSet |
nodes |
protected java.awt.Dimension |
preferredSize |
protected int |
rowCount |
protected int[] |
rows |
protected WorkflowEntity |
selection |
protected Workflow |
workflow |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
Diagram(Workflow workflow)
Constructs a diagram object to display a workflow
|
Modifier and Type | Method and Description |
---|---|
void |
addDiagramListener(DiagramListener listener)
Adds a listener to the diagram
|
void |
buildDiagram()
Builds the diagram based on the current workflow and configuration.
|
protected DiagramWorkflowNode |
createDiagramNode(WorkflowNode node,
int imageScale)
Creates a workflow node
|
protected void |
drawArrow(java.awt.Graphics g,
int x,
int y,
int state)
Draws an right pointing arrow at the end of a line
|
protected void |
drawLine(java.awt.Graphics g,
WorkflowRelationship rel)
Draws a line representing the relationship.
|
protected void |
drawLine(java.awt.Graphics g,
WorkflowRelationship rel,
int x1,
int y1,
int x2,
int y2,
int state)
Draws a line.
|
protected void |
drawLineSegment(java.awt.Graphics g,
int x1,
int y1,
int x2,
int y2,
boolean dashed)
Draws a line segment.
|
protected void |
fireListeners(DiagramEvent e)
Fires an event for all the listeners
|
protected DiagramLineChannel |
getChannel(int index,
int orientation,
int position)
Returns channel for a given index,orientation and position creating it if
necessary
|
java.awt.image.BufferedImage |
getImage()
Gets the image of the workflow diagram.
|
protected java.awt.Color |
getLineColor(int state)
Returns the line color for the line state
|
protected java.lang.Object |
getNodeKey(int row,
int column)
Returns a unique key for the node based on its location
|
protected java.awt.Point |
getPoint(int x,
int y)
Returns the row and column within the diagram for a given x,y value.
|
java.awt.Dimension |
getPreferredSize()
Returns the preferred size - this is the diagram size
|
protected java.awt.Point[] |
getSegments(Line line)
Returns the list of segments the line is be drawn in.
|
protected boolean |
isStraight(int fromRow,
int fromColumn,
int toRow,
int toColumn)
Returns true if a line can be run straight between the positions and
false otherwise
|
protected void |
paintComponent(java.awt.Graphics g)
Paints the components
|
void |
removeDiagramListener(DiagramListener listener)
Removes a listener from the diagram
|
void |
selectNode(WorkflowEntity node,
boolean state)
Sets the selection state of a node.
|
void |
setConfiguration(DiagramConfiguration configuration)
Sets the configuration for the diagram
|
void |
setSelection(WorkflowEntity selection)
Sets the current selection for the diagram.
|
void |
setWorkflow(Workflow workflow)
Sets a new workflow
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, 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
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, validateTree
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, 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, transferFocusBackward, transferFocusUpCycle
protected java.util.TreeSet nodes
protected java.util.Hashtable channels
protected java.util.Hashtable nodeIndex
protected int rowCount
protected int columnCount
protected Workflow workflow
protected java.awt.Dimension preferredSize
protected DiagramConfiguration configuration
protected java.util.Hashtable channelSet
protected java.util.TreeSet lines
protected WorkflowEntity selection
protected java.util.Vector listeners
protected int[] rows
protected int[] columns
protected static final int DASH_LENGTH
protected static final int GAP_LENGTH
protected static final int LINE_NORMAL
protected static final int LINE_NEGATIVE
protected static final int LINE_SELECTED
protected static final int[] curvePoints
public Diagram(Workflow workflow)
workflow
- The workflow to displaypublic void setWorkflow(Workflow workflow)
workflow
- The workflow to displaypublic void setConfiguration(DiagramConfiguration configuration)
configuration
- The configuration objectpublic void setSelection(WorkflowEntity selection)
selection
- The new selectionpublic void selectNode(WorkflowEntity node, boolean state)
node
- The node to selectstate
- The selection stateprotected java.awt.Point getPoint(int x, int y)
x
- The x locationy
- The y locationpublic void buildDiagram()
protected DiagramWorkflowNode createDiagramNode(WorkflowNode node, int imageScale)
node
- The workflow nodeimageScale
- The scaling for the imagepublic java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
protected DiagramLineChannel getChannel(int index, int orientation, int position)
index
- The channel indexorientation
- The channel orientationposition
- The channel poisitonprotected boolean isStraight(int fromRow, int fromColumn, int toRow, int toColumn)
fromRow
- The originating rowfromColumn
- The origination columntoRow
- The destination rowtoColumn
- The destination columnprotected java.lang.Object getNodeKey(int row, int column)
protected void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
g
- The graphics contextprotected void drawLine(java.awt.Graphics g, WorkflowRelationship rel)
Draws a line representing the relationship. There are 3 basic lines that can be drawn.
A horizontal line between 2 nodes A 3 segement line between 2 nodes in different rows A 5 segement line between 2 nodes with intervening nodes <pre>
g
- The graphics contextrel
- The relationshipprotected void drawLine(java.awt.Graphics g, WorkflowRelationship rel, int x1, int y1, int x2, int y2, int state)
g
- The graphics contextrel
- The workflow relationship the line belongs tox1
- The x coordinate of the line starty1
- The y coordinate of the line startx2
- The x coordinate of the line endy2
- The y coordinate of the line endstate
- The state of the line to be drawnprotected void drawLineSegment(java.awt.Graphics g, int x1, int y1, int x2, int y2, boolean dashed)
g
- The graphics contextx1
- The x coordinate of the line starty1
- The y coordinate of the line startx2
- The x coordinate of the line endy2
- The y coordinate of the line enddashed
- True if a dashed line being drawnprotected void drawArrow(java.awt.Graphics g, int x, int y, int state)
g
- The graphics contextx
- The x coordinate of the arrow pointy
- The y coordinate of the arrow pointstate
- The state of the line being drawnprotected java.awt.Color getLineColor(int state)
state
- The state of the line being drawnprotected java.awt.Point[] getSegments(Line line)
line
- The line to be drawnpublic java.awt.image.BufferedImage getImage()
public void addDiagramListener(DiagramListener listener)
listener
- The diagram listenerpublic void removeDiagramListener(DiagramListener listener)
listener
- The diagram listenerprotected void fireListeners(DiagramEvent e)
e
- The workflow edit event