jabble
Class Point

java.lang.Object
  extended by jabble.Point

public abstract class Point
extends java.lang.Object

Represent a point on a Grid. A point on a grid is determined by either a point identifier (a unique number given to each point on a grid) or the position within the grid (specified by the location along each direction).

Points can be retrieved from a Grid in different ways: iterators, Grid.pointAt, etc...


Constructor Summary
Point()
           
 
Method Summary
abstract  boolean equals(java.lang.Object obj)
          A Point is only equal to another Point if they are both on the same Grid and are at the same coordinates.
abstract  Grid getGrid()
          Returns the Grid on which the Point is defined.
abstract  int getLocation(int dirIndex)
          Returns the location of the Point along the direction correspondent to the index.
abstract  boolean isBlack()
          True if the Point would be a "black square" on a chess board.
abstract  boolean isInBlackHole()
           
abstract  boolean isOnBoundary()
          True if the Point is on an edge or a face of the Grid.
abstract  boolean isOnInnerBoundary()
           
abstract  boolean isOnLowerOuterBoundary(int dirIndex)
          True if the Point is on the left edge or a face of the Grid along the given direction.
abstract  boolean isOnOuterBoundary()
           
abstract  boolean isOnOuterBoundary(int dirIndex)
          True if the Point is on an edge or a face of the Grid along the given direction.
abstract  boolean isOnUpperOuterBoundary(int dirIndex)
          True if the Point is on the right edge or a face of the Grid along the given direction.
abstract  Point neighborAt(int dirIndex, int distance)
          Returns a point walking along a direction at a certain distance.
abstract  Point nextPoint(int dirIndex)
          Returns the next point along the given direction, or null if it doesn't exist.
abstract  Point previousPoint(int dirIndex)
          Returns the previous point along the given direction, or null if it doesn't exist.
abstract  void setInBlackHole(boolean inBlackHole)
           
 java.lang.String toString()
          Displays the coordinates of the Point
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Point

public Point()
Method Detail

getGrid

public abstract Grid getGrid()
Returns the Grid on which the Point is defined.

Returns:
The Grid object.

setInBlackHole

public abstract void setInBlackHole(boolean inBlackHole)

isInBlackHole

public abstract boolean isInBlackHole()

isOnBoundary

public abstract boolean isOnBoundary()
True if the Point is on an edge or a face of the Grid.

Returns:
true if the location along any direction is 0 or directionSize - 1.

isOnInnerBoundary

public abstract boolean isOnInnerBoundary()

isOnOuterBoundary

public abstract boolean isOnOuterBoundary()

isOnOuterBoundary

public abstract boolean isOnOuterBoundary(int dirIndex)
True if the Point is on an edge or a face of the Grid along the given direction.

Parameters:
dirIndex - the direction along which to test
Returns:
true if the location along dirIndex is 0 or directionSize - 1.

isOnLowerOuterBoundary

public abstract boolean isOnLowerOuterBoundary(int dirIndex)
True if the Point is on the left edge or a face of the Grid along the given direction.

Parameters:
dirIndex - the direction along which to test
Returns:
true if the location along dirIndex is 0.

isOnUpperOuterBoundary

public abstract boolean isOnUpperOuterBoundary(int dirIndex)
True if the Point is on the right edge or a face of the Grid along the given direction.

Parameters:
dirIndex - the direction along which to test
Returns:
true if the location along dirIndex is directionSize - 1.

isBlack

public abstract boolean isBlack()
True if the Point would be a "black square" on a chess board. The origin is black, and so is every point is an even number of even locations along the grid directions. For example: [0, 0, 0], [122, 24, 96], [13, 71, 0] are all blacks. [1, 0, 0], [123, 24, 17], [14, 23, 74] are white.

Returns:
true if Point is black, false if white

getLocation

public abstract int getLocation(int dirIndex)
Returns the location of the Point along the direction correspondent to the index.

Parameters:
dirIndex - The index of the direction as defined by the order given in the Grid constructor.
Returns:
The location along the direction.

nextPoint

public abstract Point nextPoint(int dirIndex)
Returns the next point along the given direction, or null if it doesn't exist.

Parameters:
dirIndex - The direction along which to look for the next point (0 for the first, 1 for the second, ...)
Returns:
The next point along the direction, or null

previousPoint

public abstract Point previousPoint(int dirIndex)
Returns the previous point along the given direction, or null if it doesn't exist.

Parameters:
dirIndex - The direction along which to look for the previous point (0 for the first, 1 for the second, ...)
Returns:
Returns the previous point along the given direction, or null if it doesn't exist.

neighborAt

public abstract Point neighborAt(int dirIndex,
                                 int distance)
Returns a point walking along a direction at a certain distance. The distance can be both positive or negative.

Parameters:
dirIndex - the direction along which to look for the point
distance - the number of steps to move along the direction; negative number will move in the opposite direction
Returns:
Returns the point along the given direction at the given distance, or null if it doesn't exist.

equals

public abstract boolean equals(java.lang.Object obj)
A Point is only equal to another Point if they are both on the same Grid and are at the same coordinates.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The object on which to do the comparison
Returns:
true if they are the same Point

toString

public java.lang.String toString()
Displays the coordinates of the Point

Overrides:
toString in class java.lang.Object
Returns:
The coordinate of the point (i.e. "[12, 23, 34]")