public class TileSet extends java.lang.Object implements Shareable, java.lang.Cloneable
Each tile can be accessed either by its (n,m) grid position (Ex: 4th column and 3rd row, where columns and rows start at zero) or by its sequential position (ex: 23rd tile, where the first tile is top left at position 0). The universal tile is assigned position -1.
Here is an example of a 5 by 6 tile set:
5 columns
00 01 02 03 04 6
05 06 07 08 09
10 11 12 13 14 r
15 16 17 18 19 o
20 21 22 23 24 w
25 26 27 28 29 s
Tile| Constructor and Description |
|---|
TileSet()
Constructs a new TileSet containing only the universe tile.
|
TileSet(int nCol,
int nRow,
Rectangle region)
Constructs a TileSet with nRow x nCol tiles of the specified size.
|
| Modifier and Type | Method and Description |
|---|---|
int |
addElement(K2DElement elem)
Adds an element to the tile that should contain it.
|
void |
clearTile(Tile tile) |
java.lang.Object |
clone() |
void |
close()
Resets the current tile set.
|
Tile |
findTileContaining(Point coord)
Finds the tile containing the specified coordinate.
|
Tile |
findTileContaining(Point coord,
boolean keepIt)
Finds the tile containing the specified coordinate.
|
java.util.Vector<Tile> |
findTilesContaining(OrientedRectangle rect)
Finds the tiles containing (completely or partially) the specified rectangle.
|
java.util.Vector<Tile> |
findTilesContaining(OrientedRectangle rect,
boolean keepIt)
Finds the tiles containing (completely or partially) the specified rectangle.
|
java.util.Vector<Tile> |
findTilesContaining(Rectangle rect,
boolean keepIt)
Finds the tiles containing (completely or partially) the specified rectangle.
|
java.util.Vector<Tile> |
findTilesContaining(java.util.Vector<Tile> result,
OrientedRectangle rect,
boolean keepIt)
Finds the tiles containing (completely or partially) the specified rectangle.
|
java.util.Vector<Tile> |
findTilesContaining(java.util.Vector<Tile> result,
Rectangle rect,
boolean keepIt)
Finds the tiles containing (completely or partially) the specified rectangle.
|
java.util.Enumeration<Tile> |
getAllTiles()
Gets an enumeration containing all the tiles of this tileSet.
|
Rectangle |
getBounds()
Gets the bounds of this tile set
|
int |
getElementCount()
Gets the number of elements in this tile set.
|
int |
getLoadedTileCount()
Gets the number of loaded tiles in this tile set.
|
int |
getNbCol()
Gets the number of columns
|
int |
getNbRow()
Gets the number of rows
|
Tile |
getTile(int pos)
Returns the tile at position n if it exists
|
Tile |
getTile(int col,
int row)
Returns the specified tile if it exists
|
Rectangle.Double |
getTileRegion(int pos)
Calculates the region occupied by the specified tile.
|
Rectangle.Double |
getTileRegion(int col,
int row)
Calculates the region occupied by the specified tile.
|
protected Tile |
initTile(int col,
int row) |
void |
removeAllElements()
Removes all the tiles from this tile set.
|
boolean |
removeElement(K2DElement elem)
Removes the specified element.
|
K2DElement |
removeElement(long elementId)
Removes the element that has the specified id
|
void |
setTile(Tile tile)
Sets the tile specified in parameter in the tileSet.
|
Shareable |
share() |
void |
unloadTile(Tile tile) |
void |
validateTiling(K2DElement[] elements) |
public TileSet()
public TileSet(int nCol,
int nRow,
Rectangle region)
nCol - the number of columnsnRow - the number of rowsregion - the region of this tile setpublic void close()
removeAllElements()public void removeAllElements()
public Tile getTile(int col, int row)
col - the column indexrow - the row indexpublic Tile getTile(int pos)
pos - the position of the tilepublic java.util.Enumeration<Tile> getAllTiles()
public Rectangle.Double getTileRegion(int col, int row)
col - Column of the tilerow - Row of the tilepublic Rectangle.Double getTileRegion(int pos)
pos - Sequential position of the tileprotected Tile initTile(int col, int row)
public int getElementCount()
public int addElement(K2DElement elem)
elem - the element to be added.public boolean removeElement(K2DElement elem)
elem - the element to be removed.public void clearTile(Tile tile)
public void unloadTile(Tile tile)
public K2DElement removeElement(long elementId)
elementId - the id of the element to be removedpublic Tile findTileContaining(Point coord)
coord - the coordinatepublic Tile findTileContaining(Point coord, boolean keepIt)
coord - the coordinatekeepIt - if true adds the new Tile instance to the tile set in memorypublic java.util.Vector<Tile> findTilesContaining(OrientedRectangle rect)
rect - the corresponding rectangle.public java.util.Vector<Tile> findTilesContaining(Rectangle rect, boolean keepIt)
rect - the rectamglekeepIt - if true adds the new Tile instance to the tile set in memorypublic java.util.Vector<Tile> findTilesContaining(OrientedRectangle rect, boolean keepIt)
rect - the rectanglekeepIt - if true adds the new Tile instance to the tile set in memorypublic java.util.Vector<Tile> findTilesContaining(java.util.Vector<Tile> result, Rectangle rect, boolean keepIt)
result - the Vector object to initialize and returnrect - the rectanglekeepIt - if true adds the new Tile instance to the tile set in memorypublic java.util.Vector<Tile> findTilesContaining(java.util.Vector<Tile> result, OrientedRectangle rect, boolean keepIt)
result - the Vector object to initialize and returnrect - the rectanglekeepIt - if true adds the new Tile instance to the tile set in memorypublic int getNbCol()
public int getNbRow()
public Rectangle getBounds()
public void setTile(Tile tile)
tile - the tile.public java.lang.Object clone()
clone in class java.lang.Objectpublic void validateTiling(K2DElement[] elements)
public int getLoadedTileCount()