Savarese Software Research Corporation

com.savarese.spatial
Class GenericPoint<Coord extends java.lang.Comparable<? super Coord>>

java.lang.Object
  extended by com.savarese.spatial.GenericPoint<Coord>
All Implemented Interfaces:
Point<Coord>

public class GenericPoint<Coord extends java.lang.Comparable<? super Coord>>
extends java.lang.Object
implements Point<Coord>

A Point implementation supporting k dimensions.


Constructor Summary
GenericPoint(Coord x, Coord y)
          Two-dimensional convenience constructor.
GenericPoint(Coord x, Coord y, Coord z)
          Three-dimensional convenience constructor.
GenericPoint(Coord x, Coord y, Coord z, Coord w)
          Four-dimensional convenience constructor.
GenericPoint(int dimensions)
          Constructs a GenericPoint with the specified dimensions.
 
Method Summary
 java.lang.Object clone()
          Returns a copy of the point.
 boolean equals(java.lang.Object obj)
          Returns true if the specified object is equal to the GenericPoint.
 Coord getCoord(int dimension)
          Returns the value of the coordinate for the specified dimension.
 int getDimensions()
          Returns the number of dimensions of the point.
 int hashCode()
          Returns the hash code value for this point.
 void setCoord(int dimension, Coord value)
          Sets the value of the coordinate for the specified dimension.
 java.lang.String toString()
          Returns a string representation of the point, listing its coordinate values in order.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GenericPoint

public GenericPoint(int dimensions)
Constructs a GenericPoint with the specified dimensions.

Parameters:
dimensions - The number of dimensions in the point. Must be greater than 0.

GenericPoint

public GenericPoint(Coord x,
                    Coord y)
Two-dimensional convenience constructor.

Parameters:
x - The coordinate value of the first dimension.
y - The coordinate value of the second dimension.

GenericPoint

public GenericPoint(Coord x,
                    Coord y,
                    Coord z)
Three-dimensional convenience constructor.

Parameters:
x - The coordinate value of the first dimension.
y - The coordinate value of the second dimension.
z - The coordinate value of the third dimension.

GenericPoint

public GenericPoint(Coord x,
                    Coord y,
                    Coord z,
                    Coord w)
Four-dimensional convenience constructor.

Parameters:
x - The coordinate value of the first dimension.
y - The coordinate value of the second dimension.
z - The coordinate value of the third dimension.
w - The coordinate value of the fourth dimension.
Method Detail

setCoord

public void setCoord(int dimension,
                     Coord value)
              throws java.lang.ArrayIndexOutOfBoundsException
Sets the value of the coordinate for the specified dimension.

Parameters:
dimension - The dimension (starting from 0) of the coordinate value to set.
value - The new value of the coordinate.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the dimension is outside of the range [0,getDimensions()-1].

getCoord

public Coord getCoord(int dimension)
Returns the value of the coordinate for the specified dimension.

Specified by:
getCoord in interface Point<Coord extends java.lang.Comparable<? super Coord>>
Parameters:
dimension - The dimension (starting from 0) of the coordinate value to retrieve.
Returns:
The value of the coordinate for the specified dimension.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the dimension is outside of the range [0,getDimensions()-1].

getDimensions

public int getDimensions()
Returns the number of dimensions of the point.

Specified by:
getDimensions in interface Point<Coord extends java.lang.Comparable<? super Coord>>
Returns:
The number of dimensions of the point.

hashCode

public int hashCode()
Returns the hash code value for this point.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code value for this point.

equals

public boolean equals(java.lang.Object obj)
Returns true if the specified object is equal to the GenericPoint.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The object to test for equality.
Returns:
true if the specified object is equal to the GenericPoint, false if not.

clone

public java.lang.Object clone()
Returns a copy of the point.

Overrides:
clone in class java.lang.Object
Returns:
A copy of the point.

toString

public java.lang.String toString()
Returns a string representation of the point, listing its coordinate values in order.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of the point.

Savarese Software Research Corporation

Copyright © 2001-2005 Daniel F. Savarese
Copyright © 2006-2010 Savarese Software Research Corporation