utilities
Class Position

java.lang.Object
  extended by utilities.Position
All Implemented Interfaces:
IBoardConstants

public class Position
extends Object
implements IBoardConstants

Position.java Created: Fri Nov 22 12:23:16 2002

Version:
Author:
Phil Ventura

Field Summary
 
Fields inherited from interface utilities.IBoardConstants
SQUARE_SIZE
 
Constructor Summary
Position(Integer row, Integer col)
          Creates a Position object
Position(Point pt)
          Creates a Position object based on a given Point
 
Method Summary
 boolean equals(Object obj)
          Tests to see if the given object has the same row and column values as this position
 Point getCenterLocation()
          Coverts Position to a Point
 Integer getCol()
          Returns the column of this position
 Integer getRow()
          Returns the row of this position
 int hashCode()
          Generates a hashcode so that two position objects with the same row and column values will have the same hashcode
 Point toPoint()
          Coverts Position to a Point
 String toString()
          Returns a string representation of this Position
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Position

public Position(Integer row,
                Integer col)
Creates a Position object

Parameters:
row - the index of the row, assumes counting starting at 0
col - the index of the column, assumes counting starting at 0

Position

public Position(Point pt)
Creates a Position object based on a given Point

Parameters:
pt - a Point to be translated to a row/column position
Method Detail

getRow

public Integer getRow()
Returns the row of this position

Returns:
the row index for this position

getCol

public Integer getCol()
Returns the column of this position

Returns:
the column index for this position

toString

public String toString()
Returns a string representation of this Position

Overrides:
toString in class Object
Returns:
This position as a string
See Also:
Object.toString()

toPoint

public Point toPoint()
Coverts Position to a Point

Returns:
the Point that corresponds to this position (upper-left hand corner of bounding box)

getCenterLocation

public Point getCenterLocation()
Coverts Position to a Point

Returns:
the Point that corresponds to this position (upper-left hand corner of bounding box)

hashCode

public int hashCode()
Generates a hashcode so that two position objects with the same row and column values will have the same hashcode

Overrides:
hashCode in class Object
Returns:
the hashcode of the position
See Also:
Object.hashCode()

equals

public boolean equals(Object obj)
Tests to see if the given object has the same row and column values as this position

Overrides:
equals in class Object
Parameters:
obj - the object to test for equivalence
Returns:
true if this object is equal to the object that's passed in
See Also:
Object.equals(java.lang.Object)