wyvern.lib
Class Point

java.lang.Object
  extended bywyvern.lib.Point

public class Point
extends java.lang.Object

Represents an (x, y) point in a map.

Version:
1.0, Mar 5, 2002
Author:
Steve Yegge

Field Summary
 int x
           
 int y
           
 
Constructor Summary
Point()
          Constructs a new Point
Point(int x, int y)
          Constructs a new Point
Point(Point p)
          Constructs a new Point by copying the coordinates from an existing Point.
Point(java.awt.Point p)
          Constructs a new Point by copying the coordinates from an existing java.awt.Point.
Point(Point p, Point offset)
          Constructs a new Point by copying the coordinates from an existing POint, and then adding the offsets stored in another Point.
 
Method Summary
static int comparePoints(Point a, Point b)
          Utility: compares the points to see which one is less (by the game standards: first check Y, then X).
 boolean equals(int x, int y)
          Returns true if this Point equals another coordinate pair.
 boolean equals(java.lang.Object obj)
          Returns true if this Point equals another one.
static Point get(int x, int y)
          Shorthand for PointCache.getPoint ( x, y )
 int getX()
          Returns X coordinate.
 int getY()
          Returns Y coordinate.
 int hashCode()
          Returns a hashcode for this point.
 void setValues(Point p)
          Sets values to those of the passed Point.
 void setX(int x)
          Sets X coordinate.
 void setY(int y)
          Sets Y coordinate.
 java.lang.String toString()
          Formats the (x, y) coordinates.
 void translate(int x, int y)
          Translates the point by the given offets.
 void translate(Point offset)
          Translates the point by the given offets.
 int x()
          Returns X coordinate.
 int y()
          Returns Y coordinate.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public int x

y

public int y
Constructor Detail

Point

public Point()
Constructs a new Point


Point

public Point(int x,
             int y)
Constructs a new Point


Point

public Point(Point p)
Constructs a new Point by copying the coordinates from an existing Point.


Point

public Point(Point p,
             Point offset)
Constructs a new Point by copying the coordinates from an existing POint, and then adding the offsets stored in another Point.

Parameters:
p - the Point with the starting (x, y)
offset - a Point containing values to add to p's x and y

Point

public Point(java.awt.Point p)
Constructs a new Point by copying the coordinates from an existing java.awt.Point.

Method Detail

get

public static Point get(int x,
                        int y)
Shorthand for PointCache.getPoint ( x, y )


getX

public int getX()
Returns X coordinate.


getY

public int getY()
Returns Y coordinate.


x

public int x()
Returns X coordinate.


y

public int y()
Returns Y coordinate.


setX

public void setX(int x)
Sets X coordinate.

Parameters:
x - new x coordinate

setY

public void setY(int y)
Sets Y coordinate.

Parameters:
y - new Y coordinate

setValues

public void setValues(Point p)
Sets values to those of the passed Point.


toString

public java.lang.String toString()
Formats the (x, y) coordinates.


translate

public void translate(int x,
                      int y)
Translates the point by the given offets.


translate

public void translate(Point offset)
Translates the point by the given offets.

Parameters:
offset - the (x, y) offsets by which to translate this Point

hashCode

public int hashCode()
Returns a hashcode for this point.


equals

public boolean equals(java.lang.Object obj)
Returns true if this Point equals another one.


equals

public final boolean equals(int x,
                            int y)
Returns true if this Point equals another coordinate pair.

Parameters:
x - x to compare
y - y to compare
Returns:
true if our x and y are equal to the passed x and y

comparePoints

public static int comparePoints(Point a,
                                Point b)
Utility: compares the points to see which one is less (by the game standards: first check Y, then X).

Parameters:
a - first point
b - second point
Returns:
-1 if a < b, 0 if they're the same, 1 if a > b.