Class GraphPanel.Node

java.lang.Object
dev.roanh.gmark.util.GraphPanel.Node
Enclosing class:
GraphPanel<V,E>

private class GraphPanel.Node extends Object
Object that holds both data on the actual graph node and data required to properly visualise the node.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    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.
    The shape of this node.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Constructs a new node with the given associated graph data.
  • Method Summary

    Modifier and Type
    Method
    Description
    private boolean
    contains(Point point)
    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
    Renders this node with the given graphics context.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • RADIUS

      private static final int RADIUS
      The radius of graph nodes in pixels.
      See Also:
    • shape

      private Ellipse2D.Double shape
      The shape of this node.
    • data

      private UniqueGraph.GraphNode<V,E> data
      The actual graph node associated with this node.
    • location

      private Point location
      The current location of this node.
  • Constructor Details

    • Node

      private Node(UniqueGraph.GraphNode<V,E> data)
      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

      private boolean contains(Point point)
      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

      private void paint(Graphics2D g)
      Renders this node with the given graphics context.
      Parameters:
      g - The graphics to use to render this node.