|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.strangelight.misc.hex.HexGrid.Location
A single hexagonal cell location.
Constructor Summary | |
HexGrid.Location(int column,
int diagonal)
constructs a new HexGrid.Location object representing an hexagonal cell at the given coordinates. |
Method Summary | |
boolean |
equals(java.lang.Object location)
tests if two HexGrid.Location objects represent the same location. |
float |
geomDistanceTo(HexGrid.Location the_location)
gets the geometric (Cartesian) distance between this HexGrid.Location and another HexGrid.Location .
|
java.awt.geom.Point2D.Float |
getCenterPoint()
get the center point of this cell as a Point2D.Float
object. |
int |
getColumn()
the column number of this cell. |
int |
getDiagonal()
the diagonal number of this cell. |
HexGrid.Location |
getNeighbor(HexDirection direction)
gets the HexGrid.Location which is adjacent to this HexGrid.Location in the given direction. |
HexGrid.Location |
getNeighborClosestTo(HexGrid.Location target)
I can't believe I'm writing code when I'm this stoned... |
HexPath |
getShortestPathTo(HexGrid.Location target)
gets a HexPath which most closely approximates a straight line between this HexGrid.Location and the target. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public HexGrid.Location(int column, int diagonal)
diagonal
- the cell diagonal. Numbers increase to the South (HexDirection.S
).column
- the cell column. Numbers increase to the East (HexDirection.NE
and HexDirection.SE
).Method Detail |
public java.lang.String toString()
toString
in class java.lang.Object
public int getDiagonal()
public int getColumn()
public java.awt.geom.Point2D.Float getCenterPoint()
Point2D.Float
object.
Point2D.Float
object.public boolean equals(java.lang.Object location)
equals
in class java.lang.Object
true
if and only if this cell and
location
have the same coordinates, and thus
represent the same cell on our grid.
java.lang.ClassCastException
- if location
is not a
HexGrid.Location
object.public float geomDistanceTo(HexGrid.Location the_location)
HexGrid.Location
and another HexGrid.Location
.
Distances are computed from the HexGrid.Location
s'
center-points.
the_location
- the other HexGrid.Location
to which
to compute the distance.
getCenterPoint()
public HexPath getShortestPathTo(HexGrid.Location target)
target
- the other HexGrid.Location
to which to
find a path.
A.getShortestPathTo(B)
will contain the same cells
as B.getShortestPathTo(A)
.public HexGrid.Location getNeighborClosestTo(HexGrid.Location target)
this
and which is closer to
target
than this
is.
target
- a HexGrid.Location that we want to get closer to.
this
and which is closer to target
than
this
is.(Returns this
if and only if
target.equals
(this)
).public HexGrid.Location getNeighbor(HexDirection direction)
direction
- the HexDirection
from which to fetch
the adjacent cell.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |