|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.croftsoft.core.awt.image.ImageCache
public final class ImageCache
Caches loaded images by file name.
Constructor Summary | |
---|---|
ImageCache()
Convenience constructor. |
|
ImageCache(int transparency,
Component component,
ClassLoader classLoader,
String mediaDir)
|
|
ImageCache(int transparency,
Component component,
ClassLoader classLoader,
String mediaDir,
Map imageMap)
Main constructor. |
|
ImageCache(Map imageMap)
Convenience constructor. |
Method Summary | |
---|---|
void |
clear()
|
boolean |
containsKey(String imageFilename)
|
BufferedImage |
get(String imageFilename)
|
Image |
remove(String imageFilename)
|
Image |
validate(String imageFilename)
Validates the image without waiting to ensure load completion. |
Image |
validate(String imageFilename,
Component component,
long maxWaitTimeMs)
Validates the image. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ImageCache(int transparency, Component component, ClassLoader classLoader, String mediaDir, Map imageMap)
imageMap
- A Map of images keyed by filenames. You may wish to consider
using a WeakHashMap instead of the default HashMap created by
the convenience constructor.WeakHashMap
public ImageCache(int transparency, Component component, ClassLoader classLoader, String mediaDir)
public ImageCache(Map imageMap)
public ImageCache()
Method Detail |
---|
public void clear()
public boolean containsKey(String imageFilename)
public BufferedImage get(String imageFilename) throws IOException
IOException
public Image remove(String imageFilename)
public Image validate(String imageFilename, Component component, long maxWaitTimeMs) throws IOException, InterruptedException
Checks to see if the image is already loaded. If not, loads the file as a class resource byte stream and converts to an image. If component is not null, creates a MediaTracker to wait until the image is completely loaded before returning.
imageFilename
- The image filename and cache key. Filenames are relative to
the root of the classpath or JAR file.
Example: if the classpath is "J:\lib", this method would load
"/images/image.png" from "J:\lib\images\image.png".component
- If null, a MediaTracker will not be used to ensure load completion
before returning.maxWaitTimeMs
- The maximum time in milliseconds to wait for an image to finish
loading before returning. Passed as the argument to
MediaTracker.waitForAll().
IOException
InterruptedException
MediaTracker
,
ClassLib.getResourceAsImage(java.lang.Class, java.lang.String)
public Image validate(String imageFilename) throws IOException
validate(imageFilename,null,0)
.
IOException
|
CroftSoft Javadoc | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |