Package nl.bebr.mapviewer.data
Class TileCache<T>
- java.lang.Object
-
- nl.bebr.mapviewer.data.TileCache<T>
-
public abstract class TileCache<T> extends Object
An implementation only class for now. For internal use only.- Author:
- joshua.marinacci@sun.com, Frantisek Post
-
-
Constructor Summary
Constructors Constructor Description TileCache()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclear()Tget(URI uri)Returns a buffered image for the requested URI from the cache.protected abstract intgetImageSizeInBytes(T image)protected abstract Map<URI,T>getImgMap()target implementation should return static imageMapvoidneedMoreMemory()Request that the cache free up some memory.voidput(URI uri, T img)Put a tile image into the cache.
-
-
-
Method Detail
-
put
public void put(URI uri, T img)
Put a tile image into the cache. This puts both a buffered image and array of bytes that make up the compressed image.- Parameters:
uri- URI of image that is being stored in the cacheimg- image to store in the cache
-
get
public T get(URI uri) throws IOException
Returns a buffered image for the requested URI from the cache. This method must return null if the image is not in the cache. If the image is unavailable but it's compressed version *is* available, then the compressed version will be expanded and returned.- Parameters:
uri- URI of the image previously put in the cache- Returns:
- the image matching the requested URI, or null if not available
- Throws:
IOException
-
getImageSizeInBytes
protected abstract int getImageSizeInBytes(T image)
-
getImgMap
protected abstract Map<URI,T> getImgMap()
target implementation should return static imageMap- Returns:
-
needMoreMemory
public void needMoreMemory()
Request that the cache free up some memory. How this happens or how much memory is freed is up to the TileCache implementation. Subclasses can implement their own strategy. The default strategy is to clear out all buffered images but retain the compressed versions.
-
clear
public void clear()
-
-