Package dev.roanh.gmark.util
Class GraphPanel.Edge
java.lang.Object
dev.roanh.gmark.util.GraphPanel.Edge
- Enclosing class:
- GraphPanel<V,
E>
Object that holds both data on the actual
graph edge and data required to properly
visualise the edge.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprivate UniqueGraph.GraphEdge<V,
E> The actual graph edge this edge is associated with.private GraphPanel<V,
E>.Node The source node for this edge.private GraphPanel<V,
E>.Node The target node for this edge.private UniqueGraph.GraphEdge<V,
E> The edge going in the opposite direction if it exists.private static final int
The size of the arrow heads for the directed edges. -
Constructor Summary
ModifierConstructorDescriptionprivate
Edge
(GraphPanel<V, E>.Node source, GraphPanel<V, E>.Node target, UniqueGraph.GraphEdge<V, E> data) Constructs a new edge with the given source node, target node and associated graph edge. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
drawArrowHead
(Graphics2D g, double x1, double y1, double x2, double y2) Draws the arrow head for a directed edge at the given location and with the given graphics context.private void
paint
(Graphics2D g) Renders this edge using the given graphics context.
-
Field Details
-
UNIT
private static final int UNITThe size of the arrow heads for the directed edges.- See Also:
-
source
The source node for this edge. -
target
The target node for this edge. -
data
The actual graph edge this edge is associated with. -
twin
The edge going in the opposite direction if it exists.
-
-
Constructor Details
-
Edge
private Edge(GraphPanel<V, E>.Node source, GraphPanel<V, E>.Node target, UniqueGraph.GraphEdge<V, E> data) Constructs a new edge with the given source node, target node and associated graph edge.- Parameters:
source
- The source node for this edge.target
- The target node for this edge.data
- The graph edge this edge visualises.
-
-
Method Details
-
paint
Renders this edge using the given graphics context.- Parameters:
g
- The graphics context to use.
-
drawArrowHead
Draws the arrow head for a directed edge at the given location and with the given graphics context. Note: the arrow head is automatically offset from the center of the target node based on the radius of the node.- Parameters:
g
- The graphics context to use.x1
- The x-coordinate of the source node of the edge the arrow head belongs to.y1
- The y-coordinate of the source node of the edge the arrow head belongs to.x2
- The x-coordinate of the target node of the edge the arrow head belongs to.y2
- The y-coordinate of the target node of the edge the arrow head belongs to.
-