|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.tensegrity.graphics.ImagePool
The ImagePool is the facility that takes over the work of
pooling images. Pooling of images is necessary because they are
most often frequently used objects and their memory consumption is very high.
NOTICE:When trying to store an image in the ImagePool
with a key that is already in use the ImagePool throws an
InvalidKeyException this is done because
ImagePool
is forced to handle this situation by itself. This handling can be something
like the following:
ImagePool if it is sure that both
images are the same.
ImagePool and reset
all references to the removed image.
| Field Summary | |
static java.lang.String |
PATH_FILETIME_SEPARATOR
Separator dividing the pathname of the file from the filetime |
| Method Summary | |
static void |
clear()
Removes all the pooled Rasters from the
ImagePool. |
static boolean |
contains(Raster raster)
Checks whether a raster is in the pool or not |
static void |
dump(java.io.PrintStream s)
Dumps the ImagePool to the PrintStream given by
s. |
static Raster |
get(java.lang.String key)
Returns the Raster that is described through the
String given by key if it
is stored in the ImagePool. |
static java.lang.Object |
getKeyOf(Raster image)
Searches for the Raster given by image in the
pool and returns the key for that Raster. |
static java.util.Iterator |
iterator()
Returns an iterator for all rasters in the image pool |
static java.util.Iterator |
keysIterator()
Returns an iterator for all texture raster keys in the image pool |
static Raster |
loadAndPool(java.lang.Class referenceClass,
java.lang.String key,
java.lang.String resourceImagePath)
Loads an image that is specified through the path given by resourceImagePath and adds the loaded image to the
ImagePool.
|
static Raster |
loadAndPool(java.lang.String resourceImagePath)
Loads an image that is specified through the path given by resourceImagePath and adds the loaded image to the
ImagePool.
|
static Raster |
loadAndPool(java.lang.String resourceImagePath,
java.lang.String key)
Loads an image that is specified through the path given by resourceImagePath and adds the loaded image to the
ImagePool.
|
static Raster |
loadAndPool(java.lang.String key,
java.net.URL imagepath)
|
static Raster |
loadAndPool(java.net.URL imagepath)
Loads an image that is specified through the path given by resourceImagePath and adds the loaded image to the
ImagePool.
|
static void |
pool(java.lang.String key,
Raster image)
Puts the Raster given by image into the
ImagePool. |
static int |
size()
Returns the number of the Rasters actually pooled
in the |
static void |
useThreadLocal()
A call to this method configures the ImagePool to make use
of the ThreadLocal class hence a pool is created for each
Thread the ImagePool is used by.
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String PATH_FILETIME_SEPARATOR
| Method Detail |
public static final void useThreadLocal()
ImagePool to make use
of the ThreadLocal class hence a pool is created for each
Thread the ImagePool is used by.
ImagePool is in use by any Thread.
ThreadLocal
public static final void pool(java.lang.String key,
Raster image)
throws InvalidKeyException
Raster given by image into the
ImagePool. Afterwards the Raster can be fetched
from the ImagePool by using the description given by
key. If there is already a Raster instance
stored in the ImagePool that has the same description an
InvalidArgumentException is thrown. This is done because
it depends on the application how to handle this situation.
key - the description the Raster instance should
stored into the ImagePool withimage - the Raster to put into the
ImagePool
InvalidArgumentException - if the given key or
image is null
InvalidKeyException - is thrown when the given key is already in
usepublic static final Raster get(java.lang.String key)
Raster that is described through the
String given by key if it
is stored in the ImagePool. If the described
Raster is not stored in the ImagePool
null is returned.
- Parameters:
key - the description of the Raster
- Returns:
- Raster an instance of the requested
Raster or
null
public static final Raster loadAndPool(java.lang.String resourceImagePath)
throws ImagePoolingException
Loads an image that is specified through the path given by
resourceImagePath and adds the loaded image to the
ImagePool.
An ImagePoolingException is thrown whenever something went
wrong while the process of loading and pooling the image.
resourceImagePath - the path for the image to load.
ImagePoolingException - is thrown when something went wrong while
the image is loaded and pooled
public static final Raster loadAndPool(java.lang.String resourceImagePath,
java.lang.String key)
throws ImagePoolingException
Loads an image that is specified through the path given by
resourceImagePath and adds the loaded image to the
ImagePool.
An ImagePoolingException is thrown whenever something went
wrong while the process of loading and pooling the image.
resourceImagePath - the path for the image to load.key - the key under which the raster will be stored
ImagePoolingException - is thrown when something went wrong while
the image is loaded and pooled
public static final Raster loadAndPool(java.lang.Class referenceClass,
java.lang.String key,
java.lang.String resourceImagePath)
throws ImagePoolingException
Loads an image that is specified through the path given by
resourceImagePath and adds the loaded image to the
ImagePool.
An ImagePoolingException is thrown whenever something went
wrong while the process of loading and pooling the image.
referenceClass - The reference class for laoding resourcesresourceImagePath - the path for the image to load.key - the key under which the raster will be stored
ImagePoolingException - is thrown when something went wrong while
the image is loaded and pooled
public static final Raster loadAndPool(java.net.URL imagepath)
throws ImagePoolingException
Loads an image that is specified through the path given by
resourceImagePath and adds the loaded image to the
ImagePool.
An ImagePoolingException is thrown whenever something went
wrong while the process of loading and pooling the image.
imagepath - the path for the image to load.
ImagePoolingException - is thrown when something went wrong while
the image is loaded and pooled
public static final Raster loadAndPool(java.lang.String key,
java.net.URL imagepath)
throws ImagePoolingException
ImagePoolingExceptionpublic static final java.lang.Object getKeyOf(Raster image)
Raster given by image in the
pool and returns the key for that Raster. If the
Raster is not part of the pool null is
returned.
image - the Raster instance to search the key for
Raster or
nullpublic static final int size()
Rasters actually pooled
in the
Rasterspublic static final void clear()
Rasters from the
ImagePool. Notice that this only
can be done when it is sure that the pooled
Rasters are no longer referenced by any object.
Otherwise these objects have a weak reference.
public static java.util.Iterator iterator()
public static java.util.Iterator keysIterator()
public static boolean contains(Raster raster)
raster - The raster to check
public static final void dump(java.io.PrintStream s)
ImagePool to the PrintStream given by
s.
s - the PrintStream to dump the ImagePool
to
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||