Class ImprovedJGraph<NodeType,NodeData extends INodeData<NodeType>,EdgeType,EdgeData extends IEdgeData<EdgeType>>
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
org.jgraph.JGraph
de.saar.chorus.jgraph.improvedjgraph.ImprovedJGraph<NodeType,NodeData,EdgeType,EdgeData>
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible,Scrollable
- Direct Known Subclasses:
ImprovedJGraphAdapter
public abstract class ImprovedJGraph<NodeType,NodeData extends INodeData<NodeType>,EdgeType,EdgeData extends IEdgeData<EdgeType>>
extends org.jgraph.JGraph
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.jgraph.JGraph
org.jgraph.JGraph.EmptySelectionModel, org.jgraph.JGraph.GraphSelectionRedirectorNested 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 TypeFieldDescriptionprotected intprotected Set<org.jgraph.graph.DefaultEdge>protected Stringprotected Fontprotected Set<org.jgraph.graph.DefaultGraphCell>Fields inherited from class org.jgraph.JGraph
antiAliased, ANTIALIASED_PROPERTY, autoResizeGraph, bendable, cloneable, connectable, CROSS_GRID_MODE, disconnectable, disconnectOnMove, DOT_GRID_MODE, dragEnabled, dropEnabled, edgeLabelsMovable, editable, EDITABLE_PROPERTY, editClickCount, enabled, GRAPH_LAYOUT_CACHE_PROPERTY, GRAPH_MODEL_PROPERTY, graphLayoutCache, graphModel, GRID_COLOR_PROPERTY, GRID_SIZE_PROPERTY, GRID_VISIBLE_PROPERTY, gridColor, gridEnabled, gridMode, gridSize, gridVisible, HANDLE_COLOR_PROPERTY, HANDLE_SIZE_PROPERTY, handleColor, handleSize, highlightColor, INVOKES_STOP_CELL_EDITING_PROPERTY, invokesStopCellEditing, IS_MAC, isJumpToDefaultPort, isMoveIntoGroups, isMoveOutOfGroups, LINE_GRID_MODE, LOCKED_HANDLE_COLOR_PROPERTY, lockedHandleColor, marquee, MARQUEE_HANDLER_PROPERTY, marqueeColor, minimumMove, moveable, moveBelowZero, PORTS_SCALED_PROPERTY, PORTS_VISIBLE_PROPERTY, portsScaled, portsVisible, previewInvalidNullPorts, scale, SCALE_PROPERTY, SELECTION_MODEL_PROPERTY, selectionEnabled, SELECTIONENABLED_PROPERTY, selectionModel, selectionRedirector, sizeable, tolerance, VERSION, xorEnabledFields 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 TypeMethodDescriptionorg.jgraph.graph.DefaultEdgeaddEdge(EdgeData data, org.jgraph.graph.DefaultGraphCell src, org.jgraph.graph.DefaultGraphCell tgt) Adds a new edge to the graph (and the underlying model).org.jgraph.graph.DefaultGraphCellAdds a new node to the graph (and the underlying model).static <E,T> void addToMapList(Map<E, List<T>> map, E key, T nVal) Generic method that handles maps from an Object to a list of objects and ads a new entry to the value list with the specified object key.voidclear()Remove all nodes and edges in the graph.voidGo through all the edges of the graph and record the adjacency matrix in the "parents" and "children" maps.abstract voidintcomputeNodeHeight(org.jgraph.graph.DefaultGraphCell node) Computes the height of the label of a node.intcomputeNodeWidth(org.jgraph.graph.DefaultGraphCell node) Computes the width of the label of a node.protected abstract org.jgraph.graph.AttributeMapprotected abstract org.jgraph.graph.AttributeMaporg.jgraph.graph.DefaultGraphCellfindNodeOrEdgeAt(int x, int y) Return the node at the mouse position (x,y).List<org.jgraph.graph.DefaultGraphCell>getChildren(org.jgraph.graph.DefaultGraphCell node) getEdgeData(org.jgraph.graph.DefaultEdge edge) Get the edge data of an edge cell.Set<org.jgraph.graph.DefaultEdge>getEdges()Get all edges of the graph.List<org.jgraph.graph.DefaultEdge>getInEdges(org.jgraph.graph.DefaultGraphCell node) Compute the incoming edges for a node.getName()Get the name (= ID) of the graph.getNodeData(org.jgraph.graph.DefaultGraphCell node) Get the node data of a node cell.org.jgraph.graph.DefaultGraphCellgetNodeForName(String name) Look up the node with the specified name.Set<org.jgraph.graph.DefaultGraphCell>getNodes()Get all nodes of the graph.List<org.jgraph.graph.DefaultEdge>getOutEdges(org.jgraph.graph.DefaultGraphCell node) Compute the outgoing edges for a node.List<org.jgraph.graph.DefaultGraphCell>getParents(org.jgraph.graph.DefaultGraphCell node) org.jgraph.graph.DefaultGraphCellgetRelativeRightSibling(org.jgraph.graph.DefaultGraphCell node, Collection<org.jgraph.graph.DefaultGraphCell> subgraph) Returns the right sibling of a given node (if there is one).List<org.jgraph.graph.DefaultEdge>Return all edges of the graph in a sortedList.org.jgraph.graph.DefaultGraphCellgetSourceNode(org.jgraph.graph.DefaultEdge edge) Returns the source node of an edge.org.jgraph.graph.DefaultGraphCellgetTargetNode(org.jgraph.graph.DefaultEdge edge) Returns the target node of and edge.Overrides thegetToolTipTextmethod ofJComponent.booleanisForest()Determines whether or not this graph is a forest.booleanbooleanisLeaf(org.jgraph.graph.DefaultGraphCell node) booleanisRelativeLeaf(org.jgraph.graph.DefaultGraphCell node, Collection<org.jgraph.graph.DefaultGraphCell> subgraph) booleanisRelativeRoot(org.jgraph.graph.DefaultGraphCell node, Collection<org.jgraph.graph.DefaultGraphCell> subgraph) booleanisRoot(org.jgraph.graph.DefaultGraphCell node) voidSet the name (= ID) of the dominance graph.wccs()Methods inherited from class org.jgraph.JGraph
addGraphSelectionListener, addSampleData, addSelectionCell, addSelectionCells, cancelEditing, clearSelection, cloneCells, convertValueToString, createBounds, fireValueChanged, fromScreen, fromScreen, getAttributes, getCellBounds, getCellBounds, getCenterPoint, getDefaultPortForCell, getDescendants, getEdgeLabelsMovable, getEditClickCount, getEditingCell, getFirstCellForLocation, getGraphLayoutCache, getGridColor, getGridMode, getGridSize, getHandleColor, getHandleSize, getHighlightColor, getImage, getInvokesStopCellEditing, getLeafViewAt, getLockedHandleColor, getMarqueeColor, getMarqueeHandler, getMinimumMove, getModel, getNextCellForLocation, getNextSelectableViewAt, getNextViewAt, getNextViewAt, getNextViewAt, getNextViewAt, getPortForLocation, getPortViewAt, getPortViewAt, getPreferredScrollableViewportSize, getRoots, getRoots, getScale, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectionCell, getSelectionCellAt, getSelectionCells, getSelectionCells, getSelectionCount, getSelectionModel, getTolerance, getTopmostViewAt, getUI, getUIClassID, graphDidChange, isAntiAliased, isAutoResizeGraph, isBendable, isCellEditable, isCellSelected, isCloneable, isConnectable, isDisconnectable, isDisconnectOnMove, isDragEnabled, isDropEnabled, isEditable, isEditing, isGridEnabled, isGridVisible, isJumpToDefaultPort, isMoveable, isMoveBelowZero, isMoveIntoGroups, isMoveOutOfGroups, isPortsScaled, isPortsVisible, isPreviewInvalidNullPorts, isSelectionEmpty, isSelectionEnabled, isSizeable, isXorEnabled, main, order, paramString, removeGraphSelectionListener, removeSelectionCell, scrollCellToVisible, scrollPointToVisible, setAntiAliased, setAutoResizeGraph, setBendable, setCloneable, setConnectable, setDisconnectable, setDisconnectOnMove, setDragEnabled, setDropEnabled, setEdgeLabelsMovable, setEditable, setEditClickCount, setGraphLayoutCache, setGridColor, setGridEnabled, setGridMode, setGridSize, setGridVisible, setHandleColor, setHandleSize, setHighlightColor, setInvokesStopCellEditing, setJumpToDefaultPort, setLockedHandleColor, setMarqueeColor, setMarqueeHandler, setMinimumMove, setModel, setMoveable, setMoveBelowZero, setMoveIntoGroups, setMoveOutOfGroups, setPortsScaled, setPortsVisible, setPreviewInvalidNullPorts, setScale, setScale, setSelectionCell, setSelectionCells, setSelectionEnabled, setSelectionModel, setSizeable, setTolerance, setUI, setXorEnabled, snap, snap, snap, startEditingAtCell, stopEditing, toScreen, toScreen, updateAutoSize, updateUIMethods 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, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, 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, updateMethods 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, 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, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface javax.accessibility.Accessible
getAccessibleContext
-
Field Details
-
nodes
-
edges
-
nameToNode
-
parents
-
children
-
name
-
nodeFont
-
edgeOrder
-
edgeCounter
protected int edgeCounter
-
-
Constructor Details
-
ImprovedJGraph
public ImprovedJGraph()
-
-
Method Details
-
clear
public void clear()Remove all nodes and edges in the graph. -
addNode
Adds a new node to the graph (and the underlying model). The attributes of the new node are computed automatically from the node data.- Parameters:
data- the data for the new node.- Returns:
- a new DefaultGraphCell object in this graph.
-
defaultNodeAttributes
-
addEdge
public org.jgraph.graph.DefaultEdge addEdge(EdgeData data, org.jgraph.graph.DefaultGraphCell src, org.jgraph.graph.DefaultGraphCell tgt) Adds a new edge to the graph (and the underlying model). The edge goes from the 0-th port of the node src to the 0-th port of the node tgt. The style attributes of the new edge are computed automatically from the edge data.- Parameters:
data- the data for the new edge.src- the node cell at which the edge should start.tgt- the node cell at which the edge should end.- Returns:
- a new DefaultEdge object in this graph.
-
defaultEdgeAttributes
-
getNodes
Get all nodes of the graph.- Returns:
- the set of all nodes.
-
getEdges
Get all edges of the graph.- Returns:
- the set of all edges.
-
computeNodeWidth
public int computeNodeWidth(org.jgraph.graph.DefaultGraphCell node) Computes the width of the label of a node. This is based oncomputeTextWidth, and is subject to the same caveats.- Parameters:
node- the node whose width we want to know- Returns:
- the width of node in pixels, or 30 if this can't be determined.
- See Also:
-
computeTextWidth
-
computeNodeHeight
public int computeNodeHeight(org.jgraph.graph.DefaultGraphCell node) Computes the height of the label of a node. This is based oncomputeTextHeight, and is subject to the same caveats.- Parameters:
node- the node whose height we want to know- Returns:
- the height of node in pixels, or 30 if this can't be determined.
- See Also:
-
computeTextHeight
-
computeLayout
public abstract void computeLayout() -
getNodeData
Get the node data of a node cell.- Parameters:
node-- Returns:
- the node data.
-
getEdgeData
Get the edge data of an edge cell.- Parameters:
edge-- Returns:
- the edge data.
-
getNodeForName
Look up the node with the specified name.- Parameters:
name-- Returns:
- that node.
-
getToolTipText
Overrides thegetToolTipTextmethod ofJComponent.- Overrides:
getToolTipTextin classorg.jgraph.JGraph
-
findNodeOrEdgeAt
public org.jgraph.graph.DefaultGraphCell findNodeOrEdgeAt(int x, int y) Return the node at the mouse position (x,y).- Parameters:
x-y-- Returns:
- reference to the node cell; null if there is no node at the position.
-
isRoot
public boolean isRoot(org.jgraph.graph.DefaultGraphCell node) -
isRelativeRoot
public boolean isRelativeRoot(org.jgraph.graph.DefaultGraphCell node, Collection<org.jgraph.graph.DefaultGraphCell> subgraph) -
isLeaf
public boolean isLeaf(org.jgraph.graph.DefaultGraphCell node) -
isRelativeLeaf
public boolean isRelativeLeaf(org.jgraph.graph.DefaultGraphCell node, Collection<org.jgraph.graph.DefaultGraphCell> subgraph) -
computeAdjacency
public void computeAdjacency()Go through all the edges of the graph and record the adjacency matrix in the "parents" and "children" maps. -
addToMapList
Generic method that handles maps from an Object to a list of objects and ads a new entry to the value list with the specified object key. If the map does not contain the key yet, it is added.- Type Parameters:
E- the key typeT- the type of the list elements- Parameters:
map- the mapkey- the key to which list the new value shall be addednVal- the new value
-
getSortedEdges
Return all edges of the graph in a sortedList.- Returns:
- the edges sorted by their order of inserting
-
setName
Set the name (= ID) of the dominance graph. This name could e.g. be displayed in the window title. -
getName
Get the name (= ID) of the graph. -
getInEdges
Compute the incoming edges for a node. The returned list lists the complete edges (with types). The list is sorted before returning by theEdgeSortingComparator- Parameters:
node- the node whose in-edges we want- Returns:
- the list of its in-edges.
-
getSourceNode
public org.jgraph.graph.DefaultGraphCell getSourceNode(org.jgraph.graph.DefaultEdge edge) Returns the source node of an edge.- Parameters:
edge- the edge- Returns:
- the edge's source node
-
getTargetNode
public org.jgraph.graph.DefaultGraphCell getTargetNode(org.jgraph.graph.DefaultEdge edge) Returns the target node of and edge.- Parameters:
edge- the edge- Returns:
- the edge's target node
-
getOutEdges
Compute the outgoing edges for a node. The returned list lists the complete edges (with types). The list is sorted before returning by theEdgeSortingComparator- Parameters:
node- the node to compute the outgoing edges for- Returns:
- the sorted list of out-edges
-
isForest
public boolean isForest()Determines whether or not this graph is a forest. TODO Consider possible cycles here!!- Returns:
- true if this graph is a forest.
-
isForest
-
getChildren
- Returns:
- Returns the children.
-
getParents
- Returns:
- Returns the parents.
-
getRelativeRightSibling
public org.jgraph.graph.DefaultGraphCell getRelativeRightSibling(org.jgraph.graph.DefaultGraphCell node, Collection<org.jgraph.graph.DefaultGraphCell> subgraph) Returns the right sibling of a given node (if there is one). If the node has more than one parent, then the method returns null.- Parameters:
node- the node (the left sibling)- Returns:
- the right sibling, or null if there is none
-
wccs
-
getNodeFont
-