public interface GraphDrawer
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.
|
default void |
addPopupMenu(Position position,
java.util.Map<java.lang.String,java.util.function.Consumer<GraphDrawer>> entries)
Creates a popup menu at the given position, using the given map for the entries.
|
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.
|
java.awt.Dimension |
getSize()
Get the size of the graph drawer in pixels.
|
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.
|
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 drawGraph(Graph graph, DrawingFrame frame)
GraphDrawingAlgorithm
or by manually specifying
reasonable positions. The graph will be drawn as is, without changing any positions to e.g. fit on screen.graph
- The graph to draw.frame
- The drawing frame which was used for laying out the graph.Graph getCurrentGraph()
boolean isReadyForInteractions()
void moveNode(Node node, Position newPosition)
node
- The node to move in the drawing.newPosition
- The new position to move the node to.void addMouseListener(MouseEventListener listener)
listener
- The listener to add.void removeMouseListener(MouseEventListener listener)
listener
- The listener to remove.void addSelectionListener(SelectionEventListener listener)
listener
- The listener to add.void removeSelectionListener(SelectionEventListener listener)
listener
- The listener to add.void setIntermediateLayout(IntermediateLayout intermediateLayout)
intermediateLayout
- The intermediate layout to be used.java.awt.Dimension getSize()
default void addPopupMenu(Position position, java.util.Map<java.lang.String,java.util.function.Consumer<GraphDrawer>> entries)
position
- 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 String key as description
and the given Consumer as on-click-action is created. The Consumer is passed the GraphDrawer item.void addPopupMenu(Position position, java.util.Collection<PopupItem> entries)
position
- 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.void setNodeBackgroundColor(Node node, Color color)
redrawNodes(Collection)
to
force the updates to appear on screen.node
- The node of which to set the background color.color
- The color to which to set the node's background color.void resetNodeBackgroundColor(Node node)
redrawNodes(Collection)
to
force the updates to appear on screen.node
- The node to reset the background color of.void setNodeShape(Node node, Shape shape)
redrawNodes(Collection)
to
force the updates to appear on screen.node
- The node of which to set the shape.shape
- The shape to which to set the node.void redraw()
void redrawNodes(java.util.Collection<Node> nodes)
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.nodes
- The nodes which need to be redrawn.