|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.media.tile.TileManager
public class TileManager
The tile manager provides a simplified interface for retrieving and caching tiles. Tiles can be loaded in two different ways. An application can load a tileset by hand, specifying the path to the tileset image and all of the tileset metadata necessary for extracting the image tiles, or it can provide a tileset repository which loads up tilesets using whatever repository mechanism is implemented by the supplied repository. In the latter case, tilesets are loaded by a unique identifier.
Loading tilesets by hand is intended for things like toolbar icons or games with a single set of tiles (think Stratego, for example). Loading tilesets from a repository supports games with vast numbers of tiles to which more tiles may be added on the fly (think the tiles for an isometric-display graphical MUD).
| Field Summary | |
|---|---|
protected ImageProvider |
_defaultProvider
Used to load tileset images from the default resource source. |
protected Map<String,SoftReference<UniformTileSet>> |
_handcache
A cache of tilesets that have been loaded by hand. |
protected ImageManager |
_imgr
The entity through which we decode and cache images. |
protected TileSetRepository |
_setrep
The tile set repository. |
| Constructor Summary | |
|---|---|
TileManager(ImageManager imgr)
Creates a tile manager and provides it with a reference to the image manager from which it will load tileset images. |
|
| Method Summary | |
|---|---|
void |
clearCache()
Clears any cached tilesets. |
ImageProvider |
getImageProvider(String rset)
Returns an image provider that will load images from the specified resource set. |
Tile |
getTile(int fqTileId)
Returns the Tile object with the specified fully qualified tile id. |
Tile |
getTile(int tileSetId,
int tileIndex,
TileSet.Colorizer rizer)
Returns the Tile object from the specified tileset at the specified index. |
Tile |
getTile(int fqTileId,
TileSet.Colorizer rizer)
Returns the Tile object with the specified fully qualified tile id. |
TileSet |
getTileSet(int tileSetId)
Returns the tileset with the specified id. |
TileSet |
getTileSet(String name)
Returns the tileset with the specified name. |
TileSetRepository |
getTileSetRepository()
Returns the tileset repository currently in use. |
protected UniformTileSet |
loadCachedTileSet(String bundle,
String imgPath,
int width,
int height)
Used to load and cache tilesets loaded via loadTileSet(java.lang.String, int, int). |
UniformTileSet |
loadTileSet(ImageProvider improv,
String improvKey,
String imgPath,
int width,
int height)
|
UniformTileSet |
loadTileSet(String imgPath,
int width,
int height)
Loads up a tileset from the specified image with the specified metadata parameters. |
UniformTileSet |
loadTileSet(String rset,
String imgPath,
int width,
int height)
Loads up a tileset from the specified image (located in the specified resource set) with the specified metadata parameters. |
void |
setTileSetRepository(TileSetRepository setrep)
Sets the tileset repository that will be used by the tile manager when tiles are requested by tileset id. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected ImageManager _imgr
protected Map<String,SoftReference<UniformTileSet>> _handcache
protected TileSetRepository _setrep
protected ImageProvider _defaultProvider
| Constructor Detail |
|---|
public TileManager(ImageManager imgr)
imgr - the image manager via which the tile manager will decode and cache images.| Method Detail |
|---|
public UniformTileSet loadTileSet(String imgPath,
int width,
int height)
public UniformTileSet loadTileSet(String rset,
String imgPath,
int width,
int height)
public UniformTileSet loadTileSet(ImageProvider improv,
String improvKey,
String imgPath,
int width,
int height)
public ImageProvider getImageProvider(String rset)
protected UniformTileSet loadCachedTileSet(String bundle,
String imgPath,
int width,
int height)
loadTileSet(java.lang.String, int, int).
public void clearCache()
public void setTileSetRepository(TileSetRepository setrep)
public TileSetRepository getTileSetRepository()
public TileSet getTileSet(int tileSetId)
throws NoSuchTileSetException
setTileSetRepository(com.threerings.media.tile.TileSetRepository), and are subsequently cached.
tileSetId - the unique identifier for the desired tileset.
NoSuchTileSetException - thrown if no tileset exists with the specified id or if
an underlying error occurs with the tileset repository's persistence mechanism.
public TileSet getTileSet(String name)
throws NoSuchTileSetException
NoSuchTileSetException - if no tileset with the specified name is available via our
configured tile set repository.
public Tile getTile(int fqTileId)
throws NoSuchTileSetException
Tile object with the specified fully qualified tile id.
NoSuchTileSetExceptionTileUtil.getFQTileId(int, int)
public Tile getTile(int fqTileId,
TileSet.Colorizer rizer)
throws NoSuchTileSetException
Tile object with the specified fully qualified tile id. The supplied
colorizer will be used to recolor the tile.
NoSuchTileSetExceptionTileUtil.getFQTileId(int, int)
public Tile getTile(int tileSetId,
int tileIndex,
TileSet.Colorizer rizer)
throws NoSuchTileSetException
Tile object from the specified tileset at the specified index.
tileSetId - the tileset id.tileIndex - the index of the tile to be retrieved.
NoSuchTileSetException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||