Class Point

java.lang.Object
  |
  +--Point

public class Point
extends Object

Point data structure


Field Summary
 double cost
          a double representing the cost of the this point
 Point ptr
          Pointer to anothor point
 
Constructor Summary
Point(double x, double y)
          Constructs a new Point with the specified doubles as the x and y coordinates.
 
Method Summary
static double distance(Point a, Point b)
          Computes the distance between two points
 void drawCircle(Graphics page, Color c, Rectangle rect, double size)
          Draws a circle at this Point.
static void drawDottedLine(Graphics page, Color c, Rectangle rect, Point start, Point end, int n, int total)
          Draws a dotted line between the two specified points.
static void drawPath(Point p, Point q, Graphics2D page, Color c, Rectangle rect)
          Draws a line between two points
static void drawVertex(Point p, Graphics page, Color c, int size, Rectangle rect)
          Draws a point
static Point midPoint(Point a, Point b)
          Gets the midpoint between two points.
static double ScaleDistance(Point a, Point b, int width, int height)
          Scales the distance between two points according to the specified width and height.
static void SetMaxes(double mx, double my)
          Sets the maximum y and x coordinates for all the points.
 String toString()
          Creates a string representation of a Point along with it's cost
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cost

public double cost
a double representing the cost of the this point

ptr

public Point ptr
Pointer to anothor point
Constructor Detail

Point

public Point(double x,
             double y)
Constructs a new Point with the specified doubles as the x and y coordinates. The cost field is initialized to the max value for a double. The ptr field is null.
Parameters:
x - the x-coordinate of the Point
y - the y-coordinate of the Point
Method Detail

toString

public String toString()
Creates a string representation of a Point along with it's cost
Overrides:
toString in class Object
Returns:
a String, for example: "(0.567, 0.432) 0.999".

SetMaxes

public static void SetMaxes(double mx,
                            double my)
Sets the maximum y and x coordinates for all the points. Used to make sure Points used fit in a component when calling scaling and drawing methods. The default values are 1.0.
Parameters:
mx - maximum x-coordinate
my - maximum y_coordinate
See Also:
ScaleDistance(Point, Point, int, int)

drawPath

public static void drawPath(Point p,
                            Point q,
                            Graphics2D page,
                            Color c,
                            Rectangle rect)
Draws a line between two points
Parameters:
p - first point
q - second point
page - used to paint on the component
c - color of the path
rect - a Rectangle that specifies the area that the component spans
See Also:
drawVertex(Point, java.awt.Graphics, java.awt.Color, int, java.awt.Rectangle)

drawDottedLine

public static void drawDottedLine(Graphics page,
                                  Color c,
                                  Rectangle rect,
                                  Point start,
                                  Point end,
                                  int n,
                                  int total)
Draws a dotted line between the two specified points.
Parameters:
page - used to paint on the component
c - color of the circle
rect - a Rectangle that specifies the area that the component spans
start - point that the dotted line starts at
end - point that the dotted line starts at
n - how many of the dotted lines to draw out of the total
total - total number of dotted lines between the two points
See Also:
drawCircle(java.awt.Graphics, java.awt.Color, java.awt.Rectangle, double)

drawVertex

public static void drawVertex(Point p,
                              Graphics page,
                              Color c,
                              int size,
                              Rectangle rect)
Draws a point
Parameters:
p - point to be drawn
page - used to paint on the component
c - color of the point
size - the size of the point
rect - a Rectangle that specifies the area that the component spans
See Also:
drawPath(Point, Point, java.awt.Graphics2D, java.awt.Color, java.awt.Rectangle)

ScaleDistance

public static double ScaleDistance(Point a,
                                   Point b,
                                   int width,
                                   int height)
Scales the distance between two points according to the specified width and height.
Parameters:
a - first point
b - second point
width - the width to be scaled by
height - the height to be scaled by
Returns:
a double for the scaled distance
See Also:
distance(Point, Point), Visualization.drawCircle(java.awt.Graphics, java.awt.Color, java.awt.Rectangle, Point, double)

drawCircle

public void drawCircle(Graphics page,
                       Color c,
                       Rectangle rect,
                       double size)
Draws a circle at this Point.
Parameters:
page - used to paint on the component
c - color of the circle
rect - a Rectangle that specifies the area that the component spans
size - the diameter of the circle
See Also:
drawDottedLine(java.awt.Graphics, java.awt.Color, java.awt.Rectangle, Point, Point, int, int)

distance

public static double distance(Point a,
                              Point b)
Computes the distance between two points
Parameters:
a - first point
b - second point
Returns:
a double for the distance
See Also:
ScaleDistance(Point, Point, int, int)

midPoint

public static Point midPoint(Point a,
                             Point b)
Gets the midpoint between two points.
Parameters:
a - first point
b - second point
Returns:
a point as the midpoint


Visualization of Graph Algorithms

Author: Paul Simbi
Started by: Kevin Wayne
2002