net.sourceforge.jsh3modtool.gui.imagetable.cache
Class ImageCache

java.lang.Object
  extended by net.sourceforge.jsh3modtool.gui.imagetable.cache.ImageCache
All Implemented Interfaces:
ThumbnailViewer

public class ImageCache
extends java.lang.Object
implements ThumbnailViewer

A very simple image cache stuff.

Author:
erma

Constructor Summary
ImageCache(ImageLoadingListener listener)
          Creates a new instance of ImageBrowserCache
ImageCache(ImageLoadingListener listener, int cacheMax)
          Creates a new instance of ImageBrowserCache
 
Method Summary
 void clear()
          Clears the cache.
 int getCachedImagesCount()
          Returns the number of cached images.
 java.awt.image.BufferedImage getImage(ImageCell imageCell)
          Returns the cached image for the specified image, can be null.
 boolean isCached(ImageCell imageCell)
          Returns if the tableimage is cached or not.
 void reloadCachedImage(ImageCell imageCell)
          Tells the cache to reload the cached image.
 void removeCachedImage(ImageCell imageCell)
          Clears the cached image from the cache.
 void setImage(ImageModel imageModel, java.awt.Image image)
          Notifies the thumbnail viewer that the supplied image has been updated.
 void setMessage(ImageModel imageModel, java.lang.String msg)
          Notifies the thumbnail viewer that the image couldnt be loaded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageCache

public ImageCache(ImageLoadingListener listener)
Creates a new instance of ImageBrowserCache

Parameters:
listener - a image loading listener.

ImageCache

public ImageCache(ImageLoadingListener listener,
                  int cacheMax)
Creates a new instance of ImageBrowserCache

Parameters:
listener - a image loading listener.
cacheMax - the maximum number of images to cache.
Method Detail

getCachedImagesCount

public int getCachedImagesCount()
Returns the number of cached images.

Returns:
the number of cached images.

getImage

public java.awt.image.BufferedImage getImage(ImageCell imageCell)
Returns the cached image for the specified image, can be null.

Parameters:
imageCell - the image cell to get the cached image for.
Returns:
the cached image for the specified image, can be null.

reloadCachedImage

public void reloadCachedImage(ImageCell imageCell)
Tells the cache to reload the cached image. The cache will keep the old image until the new one has been loaded. When the new image has been loaded it will replace the cached and the cell with be updated.

Parameters:
imageCell - the cell that needs a new image.

isCached

public boolean isCached(ImageCell imageCell)
Returns if the tableimage is cached or not.

Parameters:
imageCell - the lookup object.
Returns:
if the tableimage is cached or not.

clear

public void clear()
Clears the cache.


removeCachedImage

public void removeCachedImage(ImageCell imageCell)
Clears the cached image from the cache.

Parameters:
imageCell - the image cells cached image to remove.

setImage

public void setImage(ImageModel imageModel,
                     java.awt.Image image)
Notifies the thumbnail viewer that the supplied image has been updated.

Specified by:
setImage in interface ThumbnailViewer
Parameters:
imageModel - the image properties detailing which image that was updated.
image - the new raw image as an imagedata object.

setMessage

public void setMessage(ImageModel imageModel,
                       java.lang.String msg)
Notifies the thumbnail viewer that the image couldnt be loaded.

Specified by:
setMessage in interface ThumbnailViewer
Parameters:
imageModel - the image properties detailing which image that was updated.
msg - the message stating what happened


Copyright © 2005 sourceforge.net. All Rights Reserved.