diff --git a/src/java/com/threerings/media/tile/TileManager.java b/src/java/com/threerings/media/tile/TileManager.java index 51d71bf5..81f5036f 100644 --- a/src/java/com/threerings/media/tile/TileManager.java +++ b/src/java/com/threerings/media/tile/TileManager.java @@ -21,40 +21,37 @@ package com.threerings.media.tile; -import java.lang.ref.SoftReference; +import static com.threerings.media.Log.log; -import java.util.HashMap; +import java.lang.ref.SoftReference; +import java.util.Map; + +import com.google.common.collect.Maps; import com.samskivert.io.PersistenceException; import com.threerings.media.image.ImageManager; -import static com.threerings.media.Log.log; - /** - * 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). + * 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).
*/
public class TileManager
{
/**
- * Creates a tile manager and provides it with a reference to the
- * image manager from which it will load tileset images.
- *
- * @param imgr the image manager via which the tile manager will
- * decode and cache images.
+ * Creates a tile manager and provides it with a reference to the image manager from which it
+ * will load tileset images.
+ *
+ * @param imgr the image manager via which the tile manager will decode and cache images.
*/
public TileManager (ImageManager imgr)
{
@@ -63,8 +60,7 @@ public class TileManager
}
/**
- * Loads up a tileset from the specified image with the specified
- * metadata parameters.
+ * Loads up a tileset from the specified image with the specified metadata parameters.
*/
public UniformTileSet loadTileSet (String imgPath, int width, int height)
{
@@ -72,14 +68,12 @@ public class TileManager
}
/**
- * Loads up a tileset from the specified image (located in the
- * specified resource set) with the specified metadata parameters.
+ * Loads up a tileset from the specified image (located in the specified resource set) with
+ * the specified metadata parameters.
*/
- public UniformTileSet loadTileSet (
- String rset, String imgPath, int width, int height)
+ public UniformTileSet loadTileSet (String rset, String imgPath, int width, int height)
{
- return loadTileSet(
- getImageProvider(rset), rset, imgPath, width, height);
+ return loadTileSet(getImageProvider(rset), rset, imgPath, width, height);
}
/**
@@ -88,8 +82,7 @@ public class TileManager
ImageProvider improv, String improvKey, String imgPath,
int width, int height)
{
- UniformTileSet uts = loadCachedTileSet(
- improvKey, imgPath, width, height);
+ UniformTileSet uts = loadCachedTileSet(improvKey, imgPath, width, height);
uts.setImageProvider(improv);
return uts;
}
@@ -106,20 +99,19 @@ public class TileManager
/**
* Used to load and cache tilesets loaded via {@link #loadTileSet}.
*/
- protected UniformTileSet loadCachedTileSet (
- String bundle, String imgPath, int width, int height)
+ protected UniformTileSet loadCachedTileSet (String bundle, String imgPath, int width,
+ int height)
{
String key = bundle + "::" + imgPath;
- SoftReference ref = (SoftReference) _handcache.get(key);
- UniformTileSet uts = (ref == null) ? null
- : (UniformTileSet) ref.get();
+ SoftReference