|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--lava.gui.ImageLoader
Loads application images.
Details: ImageLoader
loads and caches images through a ResourceLoader.
Field Summary | |
protected ResourceLoader |
rl
Used for loading images. |
Constructor Summary | |
ImageLoader(ResourceLoader rl)
Sets ResourceLoader. |
Method Summary | |
java.awt.Image |
getImage(java.lang.String key)
Loads image. |
protected java.awt.Image |
loadImage(java.lang.String key)
Loads uncached image. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final ResourceLoader rl
Details: rl is the ResourceLoader that this ImageLoader uses to convert keys into image and load the images.
Constructor Detail |
public ImageLoader(ResourceLoader rl)
Details: This constructor binds this new ImageLoader to the given ResourceLoader. All images loaded by this ImageLoader will come through rl.
rl
- the ResourceLoaderMethod Detail |
public java.awt.Image getImage(java.lang.String key)
Details: getImage uses the ResourceLoader (provided in the constructor) to translate the given key (key) into an image. If the given key has already been used in a previous getImage
call, then this method simply retrieves the image from the cache instead of reloading it. If the image is not in the cache, however, it is loaded through the loadImage
method.
Normally, the AWT attempts to postpone image loading as late as possible. getImage circumvents this behavior by forcing the image to begin loading. getImage
does not return until the image's dimensions are available through the Image
's getWidth
and getHeight
methods. If the image cannot be loaded, getImage
returns null
.
the
- key into the ResourceLoaderprotected java.awt.Image loadImage(java.lang.String key)
Details: loadImage retrieves an image from the ResourceLoader, using the given key, but only after verifying that the key points to an actually existing resource. It then caches the image and returns it, or null
if the image cannot be loaded.
This method is called by getImage. Subclasses may override this method to generate verbose information about image loading status, etc., but overriding implementations should call super.loadImage
.
key
- the key
|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |