|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jtge.util.grid.Grid
Implements a grid.
Constructor Summary | |
Grid(int width,
int height,
IDirectionGroup directionGroup)
Create a grid. |
|
Grid(int width,
int height,
IDirectionGroup directionGroup,
ITorus torus)
Create a grid. |
Method Summary | |
java.util.Iterator |
adjacentIterator(Coordinate coordinate)
Create an iterator on coordinates around a given coordinate. |
java.util.Iterator |
adjacentTileIterator(Coordinate coordinate)
Create an iterator on tiles around a given coordinate. |
Coordinate |
getAdjacent(Coordinate coordinate,
IDirection direction)
returns the adjacent Coordinate given a Coordinate center and a Direction. Coordinate returned are always valid, an CoordinateOutOfBoundException is thrown if you asked for an impossible coordinate. |
int |
getHeight()
Retrieve the height. |
ITile |
getTile(Coordinate coordinate)
Retrieve the tile object at the supplied coordinate. |
int |
getWidth()
Retrieve the width. |
boolean |
isValid(Coordinate coordinate)
Checks if the coordinate supplied is valid for this grid. |
java.util.Iterator |
linearIterator()
Create an iterator on coordinates from the top left to the bottom right coordinate. |
java.util.Iterator |
linearTileIterator()
Create an iterator on tiles from the top left to the bottom right coordinate. |
void |
setTile(ITile tile,
Coordinate coordinate)
Assign the supplied tile to this grid.
If a tile is already present at |
int |
size()
Retrieve the maximum number of tiles this hexGrid can hold. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Grid(int width, int height, IDirectionGroup directionGroup, ITorus torus)
width
- the grid width in tilesheight
- the grid height in tilesdirectionGroup
- the direction group strategytorus
- the toruspublic Grid(int width, int height, IDirectionGroup directionGroup)
width
- the grid width in tilesheight
- the grid height in tilesdirectionGroup
- the direction group strategyMethod Detail |
public final int getWidth()
getWidth
in interface IGrid
public final int getHeight()
getHeight
in interface IGrid
public final int size()
size
in interface IGrid
public final void setTile(ITile tile, Coordinate coordinate)
If a tile is already present at coordinate()
for the current grid it gets replaced.
setTile
in interface IGrid
tile
- the tile to set in this gridcoordinate
- the coordinate to place the tile atpublic final ITile getTile(Coordinate coordinate)
getTile
in interface IGrid
coordinate
- the coordinate in the grid you want the tile for
public final boolean isValid(Coordinate coordinate)
isValid
in interface IGrid
coordinate
- the coordinate to test
public final Coordinate getAdjacent(Coordinate coordinate, IDirection direction)
getAdjacent
in interface IGrid
coordinate
- the coordinate from which the adjacent coordinate is calculated.direction
- the direction from which the adjacent coordinate is calculated.
public final java.util.Iterator adjacentIterator(Coordinate coordinate)
adjacentIterator
in interface IGrid
coordinate
- a coordinate
public final java.util.Iterator adjacentTileIterator(Coordinate coordinate)
adjacentTileIterator
in interface IGrid
coordinate
- a coordinate
public final java.util.Iterator linearIterator()
linearIterator
in interface IGrid
public final java.util.Iterator linearTileIterator()
linearTileIterator
in interface IGrid
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |