public abstract class TileGrid extends java.lang.Object implements Drawable
A TileGrid is a Drawable that displays a rectangular grid of other Drawables, called tiles. A TileGrid's tiles are assumed to all be rectangular, of equal width and equal height, and with their origins at their top left corners  though these requirements are not enforced. It is the responsibility of the creators and modifiers of a TileGrid to ensure that the TileGrid is not set as one of its own tiles, or otherwise involved in a hierarchy of composite Drawables containing an infinite loop.
A TileGrid's columns are labeled with indices that increase from left to right, and its rows are labeled with indices that increase from top to bottom. A TileGrid's leftmost and rightmost column indices, and its topmost and bottommost row indices, are specified upon its creation. A TileGrid's origin is the top left corner of its grid cell with column index 0 and row index 0 (or, if such a grid cell does not exist, where the top left corner of that grid cell would be if it existed).
Each cell in a TileGrid can be assigned at most one Drawable, which is the tile at that cell's location. A single Drawable can be set as the tile at multiple locations. Tiles at individual locations can also be set to be drawn flipped horizontally or vertically, or rotated in increments of 90 degrees. (Rotation assumes that tiles are square, but again, this is not enforced.) A TileGrid remembers the angle and flipped status of the tile at each location, even while there is no tile at that location.
Though a TileGrid's tiles can be flipped and rotated, a TileGrid itself cannot be flipped, rotated, or scaled via parameters of its draw() method; such parameters are simply ignored.
The computational time taken to draw a TileGrid is proportional to the number of its grid cells that are visible on screen, not to its total number of grid cells. This means that memory usage is the only factor limiting a TileGrid's size in practice.
The TileGrid class also contains the static methods coverObjects() and coverPoints(), which are useful for compactly representing the occupied regions of large grids of objects.
Constructor and Description 

TileGrid(int tileWidth,
int tileHeight)
Constructs a TileGrid 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 

abstract java.util.List<java.awt.Rectangle> 
cover()
Returns a list of nonoverlapping rectangles that collectively overlap or
"cover" all and only the grid cells in this TileGrid that are occupied by
tiles.

static java.util.List<java.awt.Rectangle> 
coverObjects(int x1,
int y1,
java.lang.Object[][] objects)
Returns a list of nonoverlapping rectangles that collectively overlap or
"cover" all and only the nonnull locations in the specified 2D object
array.

static java.util.List<java.awt.Rectangle> 
coverPoints(java.util.Set<java.awt.Point> points)
Returns a list of nonoverlapping rectangles that collectively overlap or
"cover" all and only the points in the specified set.

void 
draw(Graphics g,
int x,
int y)
Draws this Drawable's image to the specified Graphics context.

void 
draw(Graphics g,
int x,
int y,
boolean xFlip,
boolean yFlip,
double angle,
double alpha,
Filter filter)
Draws this Drawable's image to the specified Graphics context.

void 
draw(Graphics g,
int x,
int y,
double scale,
boolean xFlip,
boolean yFlip,
double alpha,
Filter filter)
Draws this Drawable's image to the specified Graphics context.

void 
draw(Graphics g,
int x,
int y,
int left,
int right,
int top,
int bottom)
Draws a rectangular region of this Drawable's image to the specified
Graphics context.

void 
draw(Graphics g,
int x,
int y,
int left,
int right,
int top,
int bottom,
boolean xFlip,
boolean yFlip,
double angle,
double alpha,
Filter filter)
Draws a rectangular region of this Drawable's image to the specified
Graphics context.

void 
draw(Graphics g,
int x,
int y,
int left,
int right,
int top,
int bottom,
double scale,
boolean xFlip,
boolean yFlip,
double alpha,
Filter filter)
Draws a rectangular region of this Drawable's image to the specified
Graphics context.

abstract int 
getBottommostRow()
Returns the index of this TileGrid's bottommost row.

abstract int 
getLeftmostColumn()
Returns the index of this TileGrid's leftmost column.

abstract int 
getRightmostColumn()
Returns the index of this TileGrid's rightmost column.

abstract Drawable 
getTile(int column,
int row)
Returns the tile at the specified location in this TileGrid, or null if
there is none.

abstract 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.

int 
getTileHeight()
Returns the height in pixels of each of this TileGrid's tiles.

abstract java.util.Set<java.awt.Point> 
getTileLocations()
Returns an unmodifiable Set view of the locations in this TileGrid that
are occupied by tiles.

int 
getTileWidth()
Returns the width in pixels of each of this TileGrid's tiles.

abstract 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.

abstract 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.

abstract int 
getTopmostRow()
Returns the index of this TileGrid's topmost row.

abstract boolean 
setTile(int column,
int row,
Drawable tile)
Sets the tile at the specified location in this TileGrid to the specified
Drawable.

abstract 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.

abstract boolean 
setTileXFlip(int column,
int row,
boolean xFlip)
Sets whether the tile at the specified location in this TileGrid is
flipped horizontally.

abstract boolean 
setTileYFlip(int column,
int row,
boolean yFlip)
Sets whether the tile at the specified location in this TileGrid is
flipped vertically.

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getRenderableRegion
public TileGrid(int tileWidth, int tileHeight)
tileWidth
 The width in pixels of each of this TileGrid's tilestileHeight
 The height in pixels of each of this TileGrid's tilespublic static java.util.List<java.awt.Rectangle> coverObjects(int x1, int y1, java.lang.Object[][] objects)
x1
 The xcoordinate (in the space of the returned rectangles) of
column 0 of the object arrayy1
 The ycoordinate (in the space of the returned rectangles) of
row 0 of the object arrayobjects
 The 2D array of objects to cover. The array's first index
is the xcoordinate, and the second is the ycoordinate. An index
increase of 1 corresponds to an increase of 1 in the corresponding
coordinate in the space of the returned rectangles.public static java.util.List<java.awt.Rectangle> coverPoints(java.util.Set<java.awt.Point> points)
points
 The set of points to coverpublic final int getTileWidth()
public final int getTileHeight()
public abstract int getLeftmostColumn()
public abstract int getRightmostColumn()
public abstract int getTopmostRow()
public abstract int getBottommostRow()
public abstract java.util.Set<java.awt.Point> getTileLocations()
public abstract Drawable getTile(int column, int row)
column
 The location's column indexrow
 The location's row indexpublic abstract boolean setTile(int column, int row, Drawable tile)
column
 The location's column indexrow
 The location's row indextile
 The Drawable to set as the tile at the specified location, or
null if there should be no tile at that locationpublic abstract boolean getTileXFlip(int column, int row)
column
 The location's column indexrow
 The location's row indexpublic abstract boolean setTileXFlip(int column, int row, boolean xFlip)
column
 The location's column indexrow
 The location's row indexxFlip
 Whether the tile at the specified location should be flipped
horizontallypublic abstract boolean getTileYFlip(int column, int row)
column
 The location's column indexrow
 The location's row indexpublic abstract boolean setTileYFlip(int column, int row, boolean yFlip)
column
 The location's column indexrow
 The location's row indexyFlip
 Whether the tile at the specified location should be flipped
verticallypublic abstract double getTileAngle(int column, int row)
column
 The location's column indexrow
 The location's row indexpublic abstract boolean setTileAngle(int column, int row, double angle)
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 abstract java.util.List<java.awt.Rectangle> cover()
public void draw(Graphics g, int x, int y)
Drawable
public void draw(Graphics g, int x, int y, boolean xFlip, boolean yFlip, double angle, double alpha, Filter filter)
Drawable
draw
in interface Drawable
g
 The Graphics context to draw the image tox
 The xcoordinate on the Graphics context of the drawn image's
originy
 The ycoordinate on the Graphics context of the drawn image's
originxFlip
 If true, the drawn image is flipped along a vertical line
through its originyFlip
 If true, the drawn image is flipped along a horizontal line
through its originangle
 The angle in degrees by which to rotate the drawn image and
its xFlip and yFlip lines counterclockwise around its originalpha
 The drawn image's alpha (opacity) value from 0 to 1filter
 The Filter to apply to the drawn image, or null if none
should be applied. Not every Filter has an effect on every Drawable.public void draw(Graphics g, int x, int y, double scale, boolean xFlip, boolean yFlip, double alpha, Filter filter)
Drawable
draw
in interface Drawable
g
 The Graphics context to draw the image tox
 The xcoordinate on the Graphics context of the drawn image's
originy
 The ycoordinate on the Graphics context of the drawn image's
originscale
 The factor by which to scale the drawn image around its
originxFlip
 If true, the drawn image is flipped along a vertical line
through its originyFlip
 If true, the drawn image is flipped along a horizontal line
through its originalpha
 The drawn image's alpha (opacity) value from 0 to 1filter
 The Filter to apply to the drawn image, or null if none
should be applied. Not every Filter has an effect on every Drawable.public void draw(Graphics g, int x, int y, int left, int right, int top, int bottom)
Drawable
draw
in interface Drawable
g
 The Graphics context to draw the region tox
 The xcoordinate on the Graphics context of the image's originy
 The ycoordinate on the Graphics context of the image's originleft
 The xcoordinate on the image, relative to its origin, of the
region's left edgeright
 The xcoordinate on the image, relative to its origin, of
the region's right edgetop
 The ycoordinate on the image, relative to its origin, of the
region's top edgebottom
 The ycoordinate on the image, relative to its origin, of
the region's bottom edgepublic void draw(Graphics g, int x, int y, int left, int right, int top, int bottom, boolean xFlip, boolean yFlip, double angle, double alpha, Filter filter)
Drawable
draw
in interface Drawable
g
 The Graphics context to draw the region tox
 The xcoordinate on the Graphics context of the image's originy
 The ycoordinate on the Graphics context of the image's originleft
 The xcoordinate on the image, relative to its origin, of the
region's left edgeright
 The xcoordinate on the image, relative to its origin, of
the region's right edgetop
 The ycoordinate on the image, relative to its origin, of the
region's top edgebottom
 The ycoordinate on the image, relative to its origin, of
the region's bottom edgexFlip
 If true, the drawn region is flipped along a vertical line
through the image's originyFlip
 If true, the drawn region is flipped along a horizontal line
through the image's originangle
 The angle in degrees by which to rotate the drawn region and
its xFlip and yFlip lines counterclockwise around the image's originalpha
 The drawn region's alpha (opacity) value from 0 to 1filter
 The Filter to apply to the drawn region, or null if none
should be applied. Not every Filter has an effect on every Drawable.public void draw(Graphics g, int x, int y, int left, int right, int top, int bottom, double scale, boolean xFlip, boolean yFlip, double alpha, Filter filter)
Drawable
draw
in interface Drawable
g
 The Graphics context to draw the region tox
 The xcoordinate on the Graphics context of the image's originy
 The ycoordinate on the Graphics context of the image's originleft
 The xcoordinate on the image, relative to its origin, of the
region's left edgeright
 The xcoordinate on the image, relative to its origin, of
the region's right edgetop
 The ycoordinate on the image, relative to its origin, of the
region's top edgebottom
 The ycoordinate on the image, relative to its origin, of
the region's bottom edgescale
 The factor by which to scale the drawn region around the
image's originxFlip
 If true, the drawn region is flipped along a vertical line
through the image's originyFlip
 If true, the drawn region is flipped along a horizontal line
through the image's originalpha
 The drawn region's alpha (opacity) value from 0 to 1filter
 The Filter to apply to the drawn region, or null if none
should be applied. Not every Filter has an effect on every Drawable.