public abstract class TileSet extends Object implements Cloneable, Serializable
TileManager or other entities to retrieve individual tiles from the tile set and
encapsulates the potentially sophisticated process of extracting the tile image from a composite
tileset image.
Tiles are referenced by their tile id. The tile id is essentially the tile number, assuming the tile at the top-left of the image is tile id zero and tiles are numbered, in ascending order, left to right, top to bottom.
This class is serializable and will be serialized, so derived classes should be sure to mark
non-persistent fields as transient.
| Modifier and Type | Class and Description |
|---|---|
static interface |
TileSet.Colorizer
Used to assign colorizations to tiles that require them.
|
| Constructor and Description |
|---|
TileSet() |
| Modifier and Type | Method and Description |
|---|---|
TileSet |
clone(Colorization[] zations)
Creates a copy of this tileset which will apply the supplied colorizations to its tileset
image when creating tiles.
|
TileSet |
clone(String imagePath)
Returns a new tileset that is a clone of this tileset with the image path updated to
reference the given path.
|
abstract Rectangle |
computeTileBounds(int tileIndex,
Rectangle bounds)
Computes and fills in the bounds for the specified tile based on the mechanism used by the
derived class to do such things.
|
String |
getImagePath()
Returns the path to the composite image used by this tileset.
|
String |
getName()
Returns the tileset name.
|
BufferedImage |
getRawTileImage(int tileIndex)
Returns the raw (unprepared) image that would be used by the tile at the specified
index.
|
BufferedImage |
getRawTileSetImage()
Returns the entire, raw, uncut, unprepared tileset source image.
|
Tile |
getTile(int tileIndex)
Equivalent to
getTile(int,Colorizer) with a null Colorizer argument. |
Tile |
getTile(int tileIndex,
Colorization[] zations)
Creates a
Tile object from this tileset corresponding to the specified tile id and
returns that tile. |
Tile |
getTile(int tileIndex,
TileSet.Colorizer rizer)
Creates a
Tile object from this tileset corresponding to the specified tile id and
returns that tile. |
abstract int |
getTileCount()
Returns the number of tiles in the tileset.
|
Mirage |
getTileMirage(int tileIndex)
Returns a prepared version of the image that would be used by the tile at the specified
index.
|
Mirage |
getTileMirage(int tileIndex,
Colorization[] zations)
Returns a prepared version of the image that would be used by the tile at the specified
index.
|
Mirage[] |
getTileMirages()
Returns prepared versions of the images that would be used for each of the tiles.
|
void |
setImagePath(String imagePath)
Sets the path to the image that will be used by this tileset.
|
void |
setImageProvider(ImageProvider improv)
Configures this tileset with an image provider that it can use to load its tileset image.
|
void |
setName(String name)
Specifies the tileset name.
|
String |
toString() |
public void setImageProvider(ImageProvider improv)
TileManager.public String getName()
public void setName(String name)
public void setImagePath(String imagePath)
getTile(int).public String getImagePath()
public abstract int getTileCount()
public TileSet clone(Colorization[] zations)
public TileSet clone(String imagePath) throws CloneNotSupportedException
CloneNotSupportedExceptionpublic abstract Rectangle computeTileBounds(int tileIndex, Rectangle bounds)
tileIndex - the index of the tile whose bounds are to be computed.bounds - the rectangle object into which to fill the bounds.public Tile getTile(int tileIndex)
getTile(int,Colorizer) with a null Colorizer argument.public Tile getTile(int tileIndex, TileSet.Colorizer rizer)
Tile object from this tileset corresponding to the specified tile id and
returns that tile. A null tile will never be returned, but one with an error image may be
returned if a problem occurs loading the underlying tileset image.tileIndex - the index of the tile in the tileset. Tile indexes start with zero as the
upper left tile and increase by one as the tiles move left to right and top to bottom over
the source image.rizer - an entity that will be used to obtain colorizations for tilesets that are
recolorizable. Passing null if the tileset is known not to be recolorizable is valid.public Tile getTile(int tileIndex, Colorization[] zations)
Tile object from this tileset corresponding to the specified tile id and
returns that tile. A null tile will never be returned, but one with an error image may be
returned if a problem occurs loading the underlying tileset image.tileIndex - the index of the tile in the tileset. Tile indexes start with zero as the
upper left tile and increase by one as the tiles move left to right and top to bottom over
the source image.zations - colorizations to be applied to the tile image prior to returning it. These
may be null for uncolorized images.public Mirage getTileMirage(int tileIndex)
Tile object when all
that is desired is access to the underlying image.public Mirage[] getTileMirages()
Tile objects when all that is
desired is access to the underlying images.public Mirage getTileMirage(int tileIndex, Colorization[] zations)
Tile object when all
that is desired is access to the underlying image.public BufferedImage getRawTileSetImage()
getTile(int)), or a tile mirage (getTileMirage(int)).public BufferedImage getRawTileImage(int tileIndex)
getTileMirage(int) because that
prepares the image for display. Only use this if you're going to do further processing and
prepare the subsequent image for display onscreen.Copyright © 2015. All rights reserved.