rle.core.board
Class RLPoint

java.lang.Object
  extended by java.awt.geom.Point2D
      extended by rle.core.board.RLPoint
All Implemented Interfaces:
java.lang.Cloneable

public final class RLPoint
extends java.awt.geom.Point2D

Immutable object for specifying single locations on the Board.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.geom.Point2D
java.awt.geom.Point2D.Double, java.awt.geom.Point2D.Float
 
Field Summary
 int x
          The immutable x coordinate.
 int y
          The immutable y coordinate.
 
Constructor Summary
RLPoint(int x, int y)
           
 
Method Summary
static RLPoint add(RLPoint p1, RLPoint p2)
          Return an RLPoint representing the sums of x and y's in p1 and p2.
 double distance(RLPoint p)
          Return the distance to another point.
 boolean equals(java.lang.Object o)
           
 double getX()
          Returns the X coordinate of this Point2D in double precision.
 double getY()
          Returns the Y coordinate of this Point2D in double precision.
 int hashCode()
           
static RLPoint point(int x, int y)
          Returns an RLPoint which may be from a cache.
 void setLocation(double x, double y)
          Throws an exception, because RLPoints are immutable.
static RLPoint subtract(RLPoint p1, RLPoint p2)
          Return an RLPoint representing the difference of x and y's in p1 and p2.
 java.lang.String toString()
           
 
Methods inherited from class java.awt.geom.Point2D
clone, distance, distance, distance, distanceSq, distanceSq, distanceSq, setLocation
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public final int x
The immutable x coordinate.


y

public final int y
The immutable y coordinate.

Constructor Detail

RLPoint

public RLPoint(int x,
               int y)
Method Detail

point

public static RLPoint point(int x,
                            int y)
Returns an RLPoint which may be from a cache. This should be used in ultra-performance intensive operations where excess object creation is undesirable. Currently, the cache dimension is 500x200, and is lazily filled. Note that for RLPoints outside this range, a new RLPoint will always be returned.


add

public static RLPoint add(RLPoint p1,
                          RLPoint p2)
Return an RLPoint representing the sums of x and y's in p1 and p2. The new point is supplied by calling point(x1+x2,y1+y2).


subtract

public static RLPoint subtract(RLPoint p1,
                               RLPoint p2)
Return an RLPoint representing the difference of x and y's in p1 and p2. The new point is supplied by calling point(x1-x2,y1-y2).


distance

public double distance(RLPoint p)
Return the distance to another point.


getX

public double getX()
Returns the X coordinate of this Point2D in double precision.

Specified by:
getX in class java.awt.geom.Point2D
Returns:
the X coordinate of this Point2D.
Since:
1.2

getY

public double getY()
Returns the Y coordinate of this Point2D in double precision.

Specified by:
getY in class java.awt.geom.Point2D
Returns:
the Y coordinate of this Point2D.
Since:
1.2

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.awt.geom.Point2D

hashCode

public int hashCode()
Overrides:
hashCode in class java.awt.geom.Point2D

setLocation

public void setLocation(double x,
                        double y)
Throws an exception, because RLPoints are immutable.

Specified by:
setLocation in class java.awt.geom.Point2D

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object