public class SwingGraphDrawer extends javax.swing.JComponent implements GraphDrawer
javax.swing.JComponent.AccessibleJComponentlistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW| Constructor and Description |
|---|
SwingGraphDrawer(GraphComponentDrawer componentDrawer) |
| Modifier and Type | Method and Description |
|---|---|
void |
addMouseListener(MouseEventListener listener)
Add a mouse listener which then receives mouse events.
|
void |
addPopupMenu(Position position,
java.util.Collection<PopupItem> entries)
Creates a popup menu at the given position, using the given popup-items as entires.
|
void |
addSelectionListener(SelectionEventListener listener)
Add a selection listener which then receives selection events when the user selects multiple nodes at once by
drawing a rectangle around the nodes to select.
|
void |
drawGraph(Graph graph,
DrawingFrame frame)
Draws the given graph on the screen.
|
Graph |
getCurrentGraph()
Get the currently drawn graph.
|
boolean |
isReadyForInteractions()
Returns whether the drawing is ready for interactions, or whether the graph is still being drawn.
|
void |
moveNode(Node node,
Position newPosition)
Move the given node to a new position.
|
protected void |
paintComponent(java.awt.Graphics g) |
void |
redraw()
Redraws the entire graph, without setting a new graph or a new drawing frame.
|
void |
redrawNodes(java.util.Collection<Node> nodes)
Redraws the given nodes, as well as all edges connected to those nodes.
|
void |
removeMouseListener(MouseEventListener listener)
Remove a previously added mouse listener.
|
void |
removeSelectionListener(SelectionEventListener listener)
Remove a previously added selection listener.
|
void |
resetNodeBackgroundColor(Node node)
Resets the given node's background color to the previously used color.
|
void |
setIntermediateLayout(IntermediateLayout intermediateLayout)
Set the intermediate layout to be used by the graph drawer.
|
void |
setNodeBackgroundColor(Node node,
Color color)
Set the background color of a given node to the given color.
|
void |
setNodeShape(Node node,
Shape shape)
Set the shape of a given node to the given shape.
|
void |
setPreferredSize(java.awt.Dimension preferredSize) |
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUIadd, 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, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, 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, transferFocusUpCycleclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddPopupMenu, getSizepublic SwingGraphDrawer(GraphComponentDrawer componentDrawer)
public void drawGraph(Graph graph, DrawingFrame frame)
GraphDrawerGraphDrawingAlgorithm or by manually specifying
reasonable positions. The graph will be drawn as is, without changing any positions to e.g. fit on screen.drawGraph in interface GraphDrawergraph - The graph to draw.frame - The drawing frame which was used for laying out the graph.public Graph getCurrentGraph()
GraphDrawergetCurrentGraph in interface GraphDrawerpublic boolean isReadyForInteractions()
GraphDrawerisReadyForInteractions in interface GraphDrawerpublic void moveNode(Node node, Position newPosition)
GraphDrawermoveNode in interface GraphDrawernode - The node to move in the drawing.newPosition - The new position to move the node to.public void addMouseListener(MouseEventListener listener)
GraphDraweraddMouseListener in interface GraphDrawerlistener - The listener to add.public void removeMouseListener(MouseEventListener listener)
GraphDrawerremoveMouseListener in interface GraphDrawerlistener - The listener to remove.public void addSelectionListener(SelectionEventListener listener)
GraphDraweraddSelectionListener in interface GraphDrawerlistener - The listener to add.public void removeSelectionListener(SelectionEventListener listener)
GraphDrawerremoveSelectionListener in interface GraphDrawerlistener - The listener to add.public void setIntermediateLayout(IntermediateLayout intermediateLayout)
GraphDrawersetIntermediateLayout in interface GraphDrawerintermediateLayout - The intermediate layout to be used.public void setPreferredSize(java.awt.Dimension preferredSize)
setPreferredSize in class javax.swing.JComponentpublic void addPopupMenu(Position position, java.util.Collection<PopupItem> entries)
GraphDraweraddPopupMenu in interface GraphDrawerposition - The position of the new popup menu within the GraphDrawer item.entries - The entries of the new menu. For each entry, a new item with the given description and on-click handler
is created. Optionally, a group may be defined. However, graph drawers are not obliged to consider
this group.public void setNodeBackgroundColor(Node node, Color color)
GraphDrawerGraphDrawer.redrawNodes(Collection) to
force the updates to appear on screen.setNodeBackgroundColor in interface GraphDrawernode - The node of which to set the background color.color - The color to which to set the node's background color.public void resetNodeBackgroundColor(Node node)
GraphDrawerGraphDrawer.redrawNodes(Collection) to
force the updates to appear on screen.resetNodeBackgroundColor in interface GraphDrawernode - The node to reset the background color of.public void setNodeShape(Node node, Shape shape)
GraphDrawerGraphDrawer.redrawNodes(Collection) to
force the updates to appear on screen.setNodeShape in interface GraphDrawernode - The node of which to set the shape.shape - The shape to which to set the node.public void redraw()
GraphDrawerredraw in interface GraphDrawerpublic void redrawNodes(java.util.Collection<Node> nodes)
GraphDrawerGraphDrawer.redraw() depending on the specific implementation. Forces any
updates to shapes or colors which were made to appear, as well as updates to the content of nodes.redrawNodes in interface GraphDrawernodes - The nodes which need to be redrawn.protected void paintComponent(java.awt.Graphics g)
paintComponent in class javax.swing.JComponent