|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.media.image.ImageManager
public class ImageManager
Provides a single point of access for image retrieval and caching. This does not include any tie-in to runtime adjustments to control caching and mirage creation.
| Nested Class Summary | |
|---|---|
protected static class |
ImageManager.CacheRecord
Maintains a source image and a set of colorized versions in the image cache. |
static class |
ImageManager.ImageKey
Used to identify an image for caching and reconstruction. |
static interface |
ImageManager.OptimalImageCreator
This interface allows the image manager to create images that are in a format optimal for rendering to the screen. |
| Field Summary | |
|---|---|
protected Throttle |
_cacheStatThrottle
Throttle our cache status logging to once every 300 seconds. |
protected LRUHashMap<ImageManager.ImageKey,ImageManager.CacheRecord> |
_ccache
A cache of loaded images. |
protected ImageDataProvider |
_defaultProvider
Our default data provider. |
protected ImageManager.OptimalImageCreator |
_icreator
We use this to create images optimized for rendering. |
protected HashSet<ImageManager.ImageKey> |
_keySet
The set of all keys we've ever seen. |
protected Map<String,ImageDataProvider> |
_providers
Data providers for different resource sets. |
protected ResourceManager |
_rmgr
A reference to the resource manager via which we load image data by default. |
protected static int |
DEFAULT_CACHE_SIZE
Default amount of data we'll store in our image cache. |
| Constructor Summary | |
|---|---|
ImageManager(ResourceManager rmgr,
Component context)
A convenience constructor that creates an AWTImageCreator for use by the image
manager. |
|
ImageManager(ResourceManager rmgr,
ImageManager.OptimalImageCreator icreator)
Construct an image manager with the specified ResourceManager from which it will
obtain its data. |
|
| Method Summary | |
|---|---|
void |
clearCache()
Clears all images out of the cache. |
BufferedImage |
createImage(int width,
int height,
int transparency)
Creates a buffered image, optimized for display on our graphics device. |
int |
getCacheSize()
Returns how much space we're willing to use for caching images. |
protected ImageDataProvider |
getDataProvider(String rset)
Returns the data provider configured to obtain image data from the specified resource set. |
BufferedImage |
getImage(ImageManager.ImageKey key,
Colorization[] zations)
Obtains the image identified by the specified key, caching if possible. |
BufferedImage |
getImage(String path)
Loads (and caches) the specified image from the resource manager using the supplied path to identify the image. |
BufferedImage |
getImage(String path,
Colorization[] zations)
Like getImage(String) but the specified colorizations are applied to the image
before it is returned. |
BufferedImage |
getImage(String rset,
String path)
Like getImage(String) but the image is loaded from the specified resource set
rathern than the default resource set. |
BufferedImage |
getImage(String rset,
String path,
Colorization[] zations)
Like getImage(String,String) but the specified colorizations are applied to the
image before it is returned. |
ImageManager.OptimalImageCreator |
getImageCreator()
Returns the image creator that can be used to create buffered images optimized for rendering to the screen. |
ImageManager.ImageKey |
getImageKey(ImageDataProvider daprov,
String path)
Returns an image key that can be used to fetch the image identified by the specified data provider and image path. |
ImageManager.ImageKey |
getImageKey(String rset,
String path)
Returns an image key that can be used to fetch the image identified by the specified resource set and image path. |
Mirage |
getMirage(ImageManager.ImageKey key)
Creates a mirage which is an image optimized for display on our current display device and which will be stored into video memory if possible. |
Mirage |
getMirage(ImageManager.ImageKey key,
Colorization[] zations)
Like getMirage(ImageKey) but the supplied colorizations are applied to the source
image before creating the mirage. |
Mirage |
getMirage(ImageManager.ImageKey key,
Rectangle bounds)
Like getMirage(ImageKey) but that only the specified subimage of the source image
is used to build the mirage. |
Mirage |
getMirage(ImageManager.ImageKey key,
Rectangle bounds,
Colorization[] zations)
Like getMirage(ImageKey,Colorization[]) except that the mirage is created using
only the specified subset of the original image. |
Mirage |
getMirage(String rsrcPath)
Creates a mirage which is an image optimized for display on our current display device and which will be stored into video memory if possible. |
BufferedImage |
getPreparedImage(String path)
Loads (and caches) the specified image from the resource manager using the supplied path to identify the image. |
BufferedImage |
getPreparedImage(String rset,
String path)
Loads (and caches) the specified image from the resource manager, obtaining the image from the supplied resource set. |
BufferedImage |
getPreparedImage(String rset,
String path,
Colorization[] zations)
Loads (and caches) the specified image from the resource manager, obtaining the image from the supplied resource set and applying the using the supplied path to identify the image. |
protected BufferedImage |
loadImage(ImageManager.ImageKey key)
Loads and returns the image with the specified key from the supplied data provider. |
protected void |
reportCachePerformance()
Reports statistics detailing the image manager cache performance and the current size of the cached images. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected ResourceManager _rmgr
protected ImageManager.OptimalImageCreator _icreator
protected LRUHashMap<ImageManager.ImageKey,ImageManager.CacheRecord> _ccache
protected HashSet<ImageManager.ImageKey> _keySet
protected Throttle _cacheStatThrottle
protected ImageDataProvider _defaultProvider
protected Map<String,ImageDataProvider> _providers
protected static int DEFAULT_CACHE_SIZE
| Constructor Detail |
|---|
public ImageManager(ResourceManager rmgr,
ImageManager.OptimalImageCreator icreator)
ResourceManager from which it will
obtain its data.
public ImageManager(ResourceManager rmgr,
Component context)
AWTImageCreator for use by the image
manager.
| Method Detail |
|---|
public int getCacheSize()
public void clearCache()
public BufferedImage createImage(int width,
int height,
int transparency)
createImage in interface ImageUtil.ImageCreatorpublic BufferedImage getImage(String path)
public BufferedImage getImage(String path,
Colorization[] zations)
getImage(String) but the specified colorizations are applied to the image
before it is returned.
public BufferedImage getImage(String rset,
String path)
getImage(String) but the image is loaded from the specified resource set
rathern than the default resource set.
public BufferedImage getImage(String rset,
String path,
Colorization[] zations)
getImage(String,String) but the specified colorizations are applied to the
image before it is returned.
public BufferedImage getPreparedImage(String path)
Additionally the image is optimized for display in the current graphics
configuration. Consider using getMirage(ImageKey) instead of prepared images as
they (some day) will automatically use volatile images to increase performance.
public BufferedImage getPreparedImage(String rset,
String path)
Additionally the image is optimized for display in the current graphics
configuration. Consider using getMirage(ImageKey) instead of prepared images as
they (some day) will automatically use volatile images to increase performance.
public BufferedImage getPreparedImage(String rset,
String path,
Colorization[] zations)
Additionally the image is optimized for display in the current graphics
configuration. Consider using getMirage(ImageKey,Colorization[]) instead of
prepared images as they (some day) will automatically use volatile images to increase
performance.
public ImageManager.ImageKey getImageKey(String rset,
String path)
public ImageManager.ImageKey getImageKey(ImageDataProvider daprov,
String path)
public BufferedImage getImage(ImageManager.ImageKey key,
Colorization[] zations)
public Mirage getMirage(String rsrcPath)
public Mirage getMirage(ImageManager.ImageKey key)
public Mirage getMirage(ImageManager.ImageKey key,
Rectangle bounds)
getMirage(ImageKey) but that only the specified subimage of the source image
is used to build the mirage.
public Mirage getMirage(ImageManager.ImageKey key,
Colorization[] zations)
getMirage(ImageKey) but the supplied colorizations are applied to the source
image before creating the mirage.
public Mirage getMirage(ImageManager.ImageKey key,
Rectangle bounds,
Colorization[] zations)
getMirage(ImageKey,Colorization[]) except that the mirage is created using
only the specified subset of the original image.
public ImageManager.OptimalImageCreator getImageCreator()
protected ImageDataProvider getDataProvider(String rset)
protected BufferedImage loadImage(ImageManager.ImageKey key)
protected void reportCachePerformance()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||