Package dev.roanh.gmark.util
Class GraphPanel.Node
java.lang.Object
dev.roanh.gmark.util.GraphPanel.Node
- Enclosing class:
- GraphPanel<V,
E>
Object that holds both data on the actual
graph node and data required to properly
visualise the node.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprivate UniqueGraph.GraphNode<V,
E> The actual graph node associated with this node.private Point
The current location of this node.private static final int
The radius of graph nodes in pixels.private Ellipse2D.Double
The shape of this node. -
Constructor Summary
ModifierConstructorDescriptionprivate
Node
(UniqueGraph.GraphNode<V, E> data) Constructs a new node with the given associated graph data. -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
Checks if the given point is contained within the circle representing this node.private void
move
(int dx, int dy) Moves this node by the given distance values relative to its current position.private void
paint
(Graphics2D g) Renders this node with the given graphics context.
-
Field Details
-
RADIUS
private static final int RADIUSThe radius of graph nodes in pixels.- See Also:
-
shape
The shape of this node. -
data
The actual graph node associated with this node. -
location
The current location of this node.
-
-
Constructor Details
-
Node
Constructs a new node with the given associated graph data. The node given a random x-coordinate between 0 and 800 and a random y-coordinate between 0 and 600.- Parameters:
data
- The graph node this node visualises.
-
-
Method Details
-
move
private void move(int dx, int dy) Moves this node by the given distance values relative to its current position.- Parameters:
dx
- Relative x-axis displacement.dy
- Relative y-axis displacement.
-
contains
Checks if the given point is contained within the circle representing this node.- Parameters:
point
- The point to test.- Returns:
- True if the given point is contained within this node.
-
paint
Renders this node with the given graphics context.- Parameters:
g
- The graphics to use to render this node.
-