|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.richclient.image.DefaultImageSource
public class DefaultImageSource
A collection of image resources, each indexed by a common key alias.
For example, action.edit.copy = /images/edit/copy.gif
This class by default performs caching of all loaded image resources using soft references (TODO it just lazy loads them, but it doesn't use SoftReference).
An image Handler
is available that handles the 'image' protocol.
Check the javadocs of the handler to know how to use/register it.
Field Summary | |
---|---|
protected static org.apache.commons.logging.Log |
logger
|
Constructor Summary | |
---|---|
DefaultImageSource(boolean installUrlHandler,
Map imageResources)
Creates a image resource bundle containing the specified map of keys to resource paths. |
|
DefaultImageSource(Map imageResources)
Creates a image resource bundle containing the specified map of keys to resource paths. |
Method Summary | |
---|---|
boolean |
containsKey(Object key)
|
Image |
getImage(String key)
Loads the image with the specified key. |
Image |
getImageAtLocation(Resource location)
|
AwtImageResource |
getImageResource(String key)
Returns the image resource indexed by the specified key. |
void |
setBrokenImageIndicator(Resource resource)
|
int |
size()
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.commons.logging.Log logger
Constructor Detail |
---|
public DefaultImageSource(Map imageResources)
A custom URL protocol handler
will be installed for the
"image:" protocol. This allows for images in this image source to be
located using the Java URL classes:
URL imageUrl = new URL("image:the.image.key")
imageResources
- a map of key-to-image-resources.public DefaultImageSource(boolean installUrlHandler, Map imageResources)
installUrlHandler
- should a URL handler be installed.imageResources
- a map of key-to-image-resources.Method Detail |
---|
public Image getImage(String key)
ImageSource
If the load is successful, the image resource is returned. If the load fails, a broken image indicator is returned if it is set for this source. If not set, an exception is thrown.
getImage
in interface ImageSource
key
- The image key
public AwtImageResource getImageResource(String key)
ImageSource
getImageResource
in interface ImageSource
key
- The image key.
public boolean containsKey(Object key)
public Image getImageAtLocation(Resource location)
public int size()
public void setBrokenImageIndicator(Resource resource)
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |