net.sf.jomic.comic
Class ComicCache

java.lang.Object
  extended by net.sf.jomic.comic.ComicCache
All Implemented Interfaces:
StandardConstants

public final class ComicCache
extends java.lang.Object
implements StandardConstants

Cache for comic related extracted archives, images, thumbnails.

Author:
Thomas Aglassinger

Nested Class Summary
 class ComicCache.TitleImageCache
          ImageCache for comic title pages.
 
Field Summary
static int MAX_THUMB_HEIGHT
           
static int MAX_THUMB_WIDTH
           
 
Fields inherited from interface net.sf.jomic.tools.StandardConstants
KILO_BYTE, MEGA_BYTE, TICK
 
Method Summary
 void dispose()
           
 long getApplicationMemory()
          Approximate number of bytes available for application and unavailable for caches.
 ArchiveCache getArchiveCache()
           
 long getAvailableMemory()
          Total memory available to application and caches.
 java.io.File getCacheDir()
           
 java.awt.image.RenderedImage getImage(java.io.File imageFile)
           
 ImageCache getImageCache()
           
 long getImageCacheMemory()
          Approximate number of bytes available for image cache.
 java.awt.image.RenderedImage geTitleImage(java.io.File comicFile)
          Get thumbnail for title image of comicFile.
 net.sf.jomic.comic.ComicCache.ThumbImageCache getThumbCache()
           
 long getThumbCacheMemory()
          Approximate number of bytes available for thumbnail cache.
 int getThumbHeight()
           
 java.awt.image.RenderedImage getThumbnail(java.io.File imageFile)
          Get thumbnail for imageFile.
 java.awt.image.RenderedImage getThumbnail(java.io.File imageFile, ImageInCacheListener listener)
          Get thumbnail for imageFile.
 int getThumbWidth()
           
 ComicCache.TitleImageCache getTitleCache()
           
 long getTitleCacheMemory()
          Approximate number of bytes available for title thumbnail cache.
 java.awt.image.RenderedImage getTitleImage(java.io.File comicFile, ImageInCacheListener listener)
          Get thumbnail for title image for comicFile.
static ComicCache instance()
           
 void setUp(java.io.File newCacheDir)
          Setup the cache.
 void setUp(java.io.File newCacheDir, long newMaxArchiveCacheSize)
          Setup the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_THUMB_HEIGHT

public static final int MAX_THUMB_HEIGHT
See Also:
Constant Field Values

MAX_THUMB_WIDTH

public static final int MAX_THUMB_WIDTH
See Also:
Constant Field Values
Method Detail

setUp

public void setUp(java.io.File newCacheDir)
           throws java.io.IOException
Setup the cache. This must be called before accessing it.

Throws:
java.io.IOException

setUp

public void setUp(java.io.File newCacheDir,
                  long newMaxArchiveCacheSize)
           throws java.io.IOException
Setup the cache. This must be called before accessing it.

Throws:
java.io.IOException

geTitleImage

public java.awt.image.RenderedImage geTitleImage(java.io.File comicFile)
Get thumbnail for title image of comicFile. If there is no such thumbnail in the cache, compute a new one and put it in the cache.


getApplicationMemory

public long getApplicationMemory()
Approximate number of bytes available for application and unavailable for caches.


getArchiveCache

public ArchiveCache getArchiveCache()

getAvailableMemory

public long getAvailableMemory()
Total memory available to application and caches.


getCacheDir

public java.io.File getCacheDir()

getImage

public java.awt.image.RenderedImage getImage(java.io.File imageFile)
                                      throws java.io.IOException
Throws:
java.io.IOException

getImageCache

public ImageCache getImageCache()
Returns:
Returns the imageCache.

getImageCacheMemory

public long getImageCacheMemory()
Approximate number of bytes available for image cache.


getThumbCache

public net.sf.jomic.comic.ComicCache.ThumbImageCache getThumbCache()
Returns:
Returns the thumbCache.

getThumbCacheMemory

public long getThumbCacheMemory()
Approximate number of bytes available for thumbnail cache.


getThumbHeight

public int getThumbHeight()

getThumbWidth

public int getThumbWidth()

getThumbnail

public java.awt.image.RenderedImage getThumbnail(java.io.File imageFile)
Get thumbnail for imageFile. If there is no such thumbnail in the cache, compute a new one and put it in the cache.


getThumbnail

public java.awt.image.RenderedImage getThumbnail(java.io.File imageFile,
                                                 ImageInCacheListener listener)
Get thumbnail for imageFile. If there is no such thumbnail in the cache, return a placeholder image immediately, and notify listener when the actual thumbnail is ready.


getTitleCache

public ComicCache.TitleImageCache getTitleCache()

getTitleCacheMemory

public long getTitleCacheMemory()
Approximate number of bytes available for title thumbnail cache.


getTitleImage

public java.awt.image.RenderedImage getTitleImage(java.io.File comicFile,
                                                  ImageInCacheListener listener)
Get thumbnail for title image for comicFile. If there is no such thumbnail in the cache, return a placeholder image immediately, and notify listener when the actual thumbnail is ready.


instance

public static ComicCache instance()

dispose

public void dispose()