|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object prefuse.render.ImageFactory
public class ImageFactory
Utility class that manages loading and storing images. Includes a configurable LRU cache for managing loaded images. Also supports optional image scaling of loaded images to cut down on memory and visualization operation costs.
By default images are loaded upon first request. Use the
preloadImages(Iterator, String)
method to load images before they
are requested for rendering.
Field Summary | |
---|---|
protected java.awt.Component |
component
|
protected java.util.Map |
imageCache
|
protected java.util.Map |
loadMap
|
protected boolean |
m_asynch
|
protected int |
m_imageCacheSize
|
protected int |
m_maxImageHeight
|
protected int |
m_maxImageWidth
|
protected int |
nextTrackerID
|
protected java.awt.MediaTracker |
tracker
|
Constructor Summary | |
---|---|
ImageFactory()
Create a new ImageFactory. |
|
ImageFactory(int maxImageWidth,
int maxImageHeight)
Create a new ImageFactory. |
Method Summary | |
---|---|
java.awt.Image |
addImage(java.lang.String location,
java.awt.Image image)
Adds an image associated with a location string to this factory's cache. |
java.awt.Image |
getImage(java.lang.String imageLocation)
Get the image associated with the given location string. |
protected java.awt.Image |
getScaledImage(java.awt.Image img)
Scales an image to fit within the current size thresholds. |
boolean |
isAsynchronous()
Indicates if this ImageFactory loads images asynchronously (true by default) |
boolean |
isInCache(java.lang.String imageLocation)
Indicates if the given string location corresponds to an image currently stored in this ImageFactory's cache. |
void |
preloadImages(java.util.Iterator iter,
java.lang.String field)
Preloads images for use in a visualization. |
void |
setAsynchronous(boolean b)
Sets if this ImageFactory loads images asynchronously. |
void |
setImageCacheSize(int size)
Sets the capacity of this factory's image cache |
void |
setMaxImageDimensions(int width,
int height)
Sets the maximum image dimensions of loaded images, images larger than these limits will be scaled to fit within bounds. |
protected void |
waitForImage(java.awt.Image image)
Wait for an image to load. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int m_imageCacheSize
protected int m_maxImageWidth
protected int m_maxImageHeight
protected boolean m_asynch
protected java.util.Map imageCache
protected java.util.Map loadMap
protected final java.awt.Component component
protected final java.awt.MediaTracker tracker
protected int nextTrackerID
Constructor Detail |
---|
public ImageFactory()
public ImageFactory(int maxImageWidth, int maxImageHeight)
maxImageWidth
- the maximum width of input images
(-1 means no limit)maxImageHeight
- the maximum height of input images
(-1 means no limit)Method Detail |
---|
public boolean isAsynchronous()
public void setAsynchronous(boolean b)
b
- true for asynchronous (background) loading, false for
synchronous (blocking) loadingpublic void setMaxImageDimensions(int width, int height)
width
- the maximum width of input images (-1 means no limit)height
- the maximum height of input images (-1 means no limit)public void setImageCacheSize(int size)
size
- the new size of the image cachepublic boolean isInCache(java.lang.String imageLocation)
imageLocation
- the image location string
public java.awt.Image getImage(java.lang.String imageLocation)
Get the image associated with the given location string. If the image has already been loaded, it simply will return the image, otherwise it will load it from the specified location.
The imageLocation argument must be a valid resource string pointing to either (a) a valid URL, (b) a file on the classpath, or (c) a file on the local filesystem. The location will be resolved in that order.
imageLocation
- the image location as a resource string.
public java.awt.Image addImage(java.lang.String location, java.awt.Image image)
location
- the location string uniquely identifying the imageimage
- the actual image
protected void waitForImage(java.awt.Image image)
image
- the image to wait forprotected java.awt.Image getScaledImage(java.awt.Image img)
img
- the image to scale
public void preloadImages(java.util.Iterator iter, java.lang.String field)
Preloads images for use in a visualization. Images to load are
determined by taking objects from the given iterator and retrieving
the value of the specified field. The items in the iterator must
be instances of the Tuple
class.
Images are loaded in the order specified by the iterator until the the iterator is empty or the maximum image cache size is met. Thus higher priority images should appear sooner in the iteration.
iter
- an Iterator of Tuple
instancesfield
- the data field that contains the image location
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |