|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectice.storm.ImageCache
Object of this class represents an image cache. In many JVMs instances of Images are cached endlessly until somebody calls flush() on the images that have been cached.
The simplest solution in a browser is to store references to all the images on a page and after user leaves the page, call flush() on all those images. Unfortunately this eliminates image caching completely and may not be desirable when data is loaded over a slow link.
To solve the problem ImageCache class has been introduced. It gives the ability to configure or change image caching behaviour. ICE Browser performs all image loading and unloading using this ImageCache.getInstance().
By default the image cache contains reference counter per image. When the counter reaches zero (nobody has a reference to the image), a timeout is set. During the call to flushImages() the timeout values are checked for images that have reference counter equal zero. All such images are flushed. The timeout value can be set via setExpire() method and is by default 30 seconds.
This image caching mechanism could be extended by for example introducing an 'image collector' thread that would kick from time to time and flush unused images.
To disable the image caching, call setExpire(0); This will make sure that the images are freed as soon as possible after they are not in use any more.
| Field Summary | |
protected HashArray |
imageToEntry
|
protected int |
timeout
|
protected HashArray |
uriToEntry
|
| Constructor Summary | |
protected |
ImageCache(Session session)
|
| Method Summary | |
void |
checkForAnimatedImagesBug()
Called from the ObjectPool whenever a new animated image is discovered (first time imageUpdate() is called with FRAMEBITS). |
void |
dispose()
Deprecated. Use #disposeResource instead |
void |
disposeResources()
|
protected Image |
factoryGetImage(URL url)
|
void |
flushImages(boolean all)
Flush images in the cache. |
static ImageCache |
get(Session session)
|
Toolkit |
getAwtToolkit()
|
int |
getExpire()
Get timeout value |
Image |
getImage(String url)
Get an image which is loaded from a given URI. |
Image |
getImage(URL u)
Deprecated. Use getImage(String). |
void |
release(Image img)
After the image is no longer needed, this method should be called notifying the image cache. |
static ImageCache |
set(Session session,
ImageCache cache)
|
void |
setExpire(int t)
Set value of the timeout (in seconds) after which an unused image will be flushed. |
void |
setReload(boolean flag)
|
void |
stopLoading(Image img)
Call this method if you want to stop loading an image |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected HashArray uriToEntry
protected HashArray imageToEntry
protected int timeout
| Constructor Detail |
protected ImageCache(Session session)
| Method Detail |
public static ImageCache get(Session session)
public static ImageCache set(Session session,
ImageCache cache)
public void setReload(boolean flag)
public Toolkit getAwtToolkit()
public void setExpire(int t)
public int getExpire()
public void dispose()
#disposeResource instead
public void disposeResources()
disposeResources in interface ResourceOwnerpublic Image getImage(URL u)
getImage(String).
public Image getImage(String url)
public void stopLoading(Image img)
public void release(Image img)
public void flushImages(boolean all)
all - if false - only epxired unused images are flushed. If true -
all the images in the cache are flushed.public void checkForAnimatedImagesBug()
protected Image factoryGetImage(URL url)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||