|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.media.IconManager
public class IconManager
Manages the creation of icons from tileset images. The icon manager is provided with a configuration file, which maps icon set identifiers to uniform tilesets and provides the metric information for said tilesets. UI code can subsequently request icons from the icon manager based on icon set identifier and index.
The configuration might look like the following:
arrows.path = /rsrc/media/icons/arrows.png arrows.metrics = 20, 25 # icons that are 20 pixels wide and 25 pixels tall smileys.path = /rsrc/media/icons/smileys.png smileys.metrics = 16, 16 # icons that are 16 pixels squareA user could then request an
arrows icon like so:
Icon icon = iconmgr.getIcon("arrows", 2);
| Field Summary | |
|---|---|
protected Properties |
_config
Our configuration information. |
protected Map<String,TileSet> |
_icons
A cache of our icon tilesets. |
protected String |
_rsrcSet
The resource bundle from which we load icon images, or null if they should be loaded from the classpath. |
protected TileManager |
_tilemgr
The tile manager we use to load tilesets. |
protected static int |
ICON_CACHE_SIZE
The maximum number of icon tilesets that may be cached at once. |
protected static String |
METRICS_SUFFIX
The suffix we append to an icon set name to obtain the tileset metrics configuration parameter. |
protected static String |
PATH_SUFFIX
The suffix we append to an icon set name to obtain the tileset image path configuration parameter. |
| Constructor Summary | |
|---|---|
IconManager(TileManager tmgr,
Properties config)
Creates an icon manager that will obtain tilesets from the supplied tile manager and which will read its configuration information from the supplied properties file. |
|
IconManager(TileManager tmgr,
String configPath)
Creates an icon manager that will obtain tilesets from the supplied tile manager and which will load its configuration information from the specified properties file. |
|
| Method Summary | |
|---|---|
Icon |
getIcon(String iconSet,
int index)
Fetches the icon with the specified index from the named icon set. |
void |
setSource(String resourceSet)
If icon images should be loaded from a set of resource bundles rather than the classpath, that set can be set here. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected TileManager _tilemgr
protected Properties _config
protected String _rsrcSet
protected Map<String,TileSet> _icons
protected static final String PATH_SUFFIX
protected static final String METRICS_SUFFIX
protected static final int ICON_CACHE_SIZE
| Constructor Detail |
|---|
public IconManager(TileManager tmgr,
String configPath)
throws IOException
tmgr - the tile manager to use when fetching tilesets.configPath - the path (relative to the classpath) from which
the icon manager configuration can be loaded.
IOException - thrown if an error occurs loading the
configuration file.
public IconManager(TileManager tmgr,
Properties config)
| Method Detail |
|---|
public void setSource(String resourceSet)
public Icon getIcon(String iconSet,
int index)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||