public class ArrayTileGrid extends TileGrid
An ArrayTileGrid is a type of TileGrid that stores its tile data in a rectangular two-dimensional array. An ArrayTileGrid's memory usage, and the time needed to iterate through the set of its tile locations, are both proportional to the number of its columns multiplied by the number of its rows.
Constructor and Description |
---|
ArrayTileGrid(int numColumns,
int numRows,
int tileWidth,
int tileHeight)
Constructs an ArrayTileGrid with all of its grid cells unoccupied by
tiles, and with none of its tiles set to be flipped or rotated.
|
ArrayTileGrid(int leftmostColumn,
int rightmostColumn,
int topmostRow,
int bottommostRow,
int tileWidth,
int tileHeight)
Constructs an ArrayTileGrid with all of its grid cells unoccupied by
tiles, and with none of its tiles set to be flipped or rotated.
|
Modifier and Type | Method and Description |
---|---|
java.util.List<java.awt.Rectangle> |
cover()
Returns a list of non-overlapping rectangles that collectively overlap or
"cover" all and only the grid cells in this TileGrid that are occupied by
tiles.
|
int |
getBottommostRow()
Returns the index of this TileGrid's bottommost row.
|
int |
getLeftmostColumn()
Returns the index of this TileGrid's leftmost column.
|
int |
getRightmostColumn()
Returns the index of this TileGrid's rightmost column.
|
Drawable |
getTile(int column,
int row)
Returns the tile at the specified location in this TileGrid, or null if
there is none.
|
double |
getTileAngle(int column,
int row)
Returns the angle by which the tile at the specified location in this
TileGrid is rotated, or 0 if the location is outside the bounds of this
TileGrid.
|
java.util.Set<java.awt.Point> |
getTileLocations()
Returns an unmodifiable Set view of the locations in this TileGrid that
are occupied by tiles.
|
boolean |
getTileXFlip(int column,
int row)
Returns whether the tile at the specified location in this TileGrid is
flipped horizontally, or false if the location is outside the bounds of
this TileGrid.
|
boolean |
getTileYFlip(int column,
int row)
Returns whether the tile at the specified location in this TileGrid is
flipped vertically, or false if the location is outside the bounds of
this TileGrid.
|
int |
getTopmostRow()
Returns the index of this TileGrid's topmost row.
|
boolean |
setTile(int column,
int row,
Drawable tile)
Sets the tile at the specified location in this TileGrid to the specified
Drawable.
|
boolean |
setTileAngle(int column,
int row,
double angle)
Sets to the specified value the angle by which the tile at the specified
location in this TileGrid is rotated.
|
boolean |
setTileXFlip(int column,
int row,
boolean xFlip)
Sets whether the tile at the specified location in this TileGrid is
flipped horizontally.
|
boolean |
setTileYFlip(int column,
int row,
boolean yFlip)
Sets whether the tile at the specified location in this TileGrid is
flipped vertically.
|
coverObjects, coverPoints, draw, draw, draw, draw, draw, draw, getTileHeight, getTileWidth
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getRenderableRegion
public ArrayTileGrid(int numColumns, int numRows, int tileWidth, int tileHeight)
numColumns
- The number of this ArrayTileGrid's columns. Column
indices will range from 0 to numColumns - 1.numRows
- The number of this ArrayTileGrid's rows. Row indices will
range from 0 to numRows - 1.tileWidth
- The width in pixels of each of this ArrayTileGrid's
tilestileHeight
- The height in pixels of each of this ArrayTileGrid's
tilespublic ArrayTileGrid(int leftmostColumn, int rightmostColumn, int topmostRow, int bottommostRow, int tileWidth, int tileHeight)
leftmostColumn
- The index of this ArrayTileGrid's leftmost columnrightmostColumn
- The index of this ArrayTileGrid's rightmost columntopmostRow
- The index of this ArrayTileGrid's topmost rowbottommostRow
- The index of this ArrayTileGrid's bottommost rowtileWidth
- The width in pixels of each of this ArrayTileGrid's
tilestileHeight
- The height in pixels of each of this ArrayTileGrid's
tilespublic final int getLeftmostColumn()
TileGrid
getLeftmostColumn
in class TileGrid
public final int getRightmostColumn()
TileGrid
getRightmostColumn
in class TileGrid
public final int getTopmostRow()
TileGrid
getTopmostRow
in class TileGrid
public final int getBottommostRow()
TileGrid
getBottommostRow
in class TileGrid
public final java.util.Set<java.awt.Point> getTileLocations()
TileGrid
getTileLocations
in class TileGrid
public final Drawable getTile(int column, int row)
TileGrid
public final boolean setTile(int column, int row, Drawable tile)
TileGrid
public final boolean getTileXFlip(int column, int row)
TileGrid
getTileXFlip
in class TileGrid
column
- The location's column indexrow
- The location's row indexpublic final boolean setTileXFlip(int column, int row, boolean xFlip)
TileGrid
setTileXFlip
in class TileGrid
column
- The location's column indexrow
- The location's row indexxFlip
- Whether the tile at the specified location should be flipped
horizontallypublic final boolean getTileYFlip(int column, int row)
TileGrid
getTileYFlip
in class TileGrid
column
- The location's column indexrow
- The location's row indexpublic final boolean setTileYFlip(int column, int row, boolean yFlip)
TileGrid
setTileYFlip
in class TileGrid
column
- The location's column indexrow
- The location's row indexyFlip
- Whether the tile at the specified location should be flipped
verticallypublic final double getTileAngle(int column, int row)
TileGrid
getTileAngle
in class TileGrid
column
- The location's column indexrow
- The location's row indexpublic final boolean setTileAngle(int column, int row, double angle)
TileGrid
setTileAngle
in class TileGrid
column
- The location's column indexrow
- The location's row indexangle
- The angle in degrees by which the tile at the specified
location should be rotatedpublic final java.util.List<java.awt.Rectangle> cover()
TileGrid