| java.lang.Object java.util.Observable com.sun.media.jai.util.SunTileCache
SunTileCache | final public class SunTileCache extends Observable implements TileCache,CacheDiagnostics(Code) | | This is Sun Microsystems' reference implementation of the
javax.media.jai.TileCache interface. It provides a
central location for images to cache computed tiles, and is used as
the default tile cache mechanism when no other tile cache objects
are specified.
In this implementation, the cache size is limited by the memory
capacity, which may be set at construction time or using the
setMemoryCapacity(long) method. The tile capacity
is not used. Different images may have very different tile sizes.
Therefore, the memory usage for a specific tile capacity may vary
greatly depends on the type of images involved. In fact, the tile
capacity is rather meaningless.
See Also: javax.media.jai.TileCache |
Method Summary | |
public void | add(RenderedImage owner, int tileX, int tileY, Raster tile) Adds a tile to the cache.
If the specified tile is already in the cache, it will not be
cached again. | public synchronized void | add(RenderedImage owner, int tileX, int tileY, Raster tile, Object tileCacheMetric) Adds a tile to the cache with an associated tile compute cost.
If the specified tile is already in the cache, it will not be
cached again. | public synchronized void | addTiles(RenderedImage owner, Point[] tileIndices, Raster[] tiles, Object tileCacheMetric) Adds an array of tiles to the tile cache. | public void | disableDiagnostics() | public void | dump() | public void | enableDiagnostics() | public synchronized void | flush() Removes -ALL- tiles from the cache. | public long | getCacheHitCount() | public long | getCacheMemoryUsed() | public long | getCacheMissCount() | public long | getCacheTileCount() | public Object | getCachedObject() Returns the Object that represents the actual cache. | public static EnumeratedParameter[] | getCachedTileActions() Returns an array of EnumeratedParameter s corresponding
to the numeric values returned by the getAction()
method of the CachedTile implementation used by
SunTileCache . | public long | getMemoryCapacity() Returns the cache's memory capacity in bytes. | public float | getMemoryThreshold() Returns the current memoryThreshold . | public synchronized Raster | getTile(RenderedImage owner, int tileX, int tileY) Retrieves a tile from the cache.
If the specified tile is not in the cache, this method
returns null . | public int | getTileCapacity() Returns the cache's tile capacity.
This implementation of TileCache does not use
the tile capacity. | public Comparator | getTileComparator() | public synchronized Raster[] | getTiles(RenderedImage owner) Retrieves a contiguous array of all tiles in the cache which are
owned by the specified image. | public synchronized Raster[] | getTiles(RenderedImage owner, Point[] tileIndices) Returns an array of tile Raster s from the cache. | public synchronized void | memoryControl() Removes tiles from the cache based on their last-access time
(old to new) until the memory usage is memoryThreshold % of that of the
memory capacity. | public synchronized void | remove(RenderedImage owner, int tileX, int tileY) Removes a tile from the cache. | public void | removeTiles(RenderedImage owner) Removes all the tiles that belong to a RenderedImage
from the cache. | public void | resetCounts() Reset hit and miss counters. | void | sendExceptionToListener(String message, Exception e) | public void | setMemoryCapacity(long memoryCapacity) Sets the cache's memory capacity to the desired number of bytes. | public void | setMemoryThreshold(float mt) Set the memory threshold value. | public void | setTileCapacity(int tileCapacity) Sets the cache's tile capacity to the desired number of tiles.
This implementation of TileCache does not use
the tile capacity. | public synchronized void | setTileComparator(Comparator c) The Comparator is used to produce an
ordered list of tiles based on a user defined
compute cost or priority metric. | public String | toString() Returns a string representation of the class object. |
SunTileCache | public SunTileCache()(Code) | | No args constructor. Use the DEFAULT_MEMORY_CAPACITY of 16 Megs.
|
SunTileCache | public SunTileCache(long memoryCapacity)(Code) | | Constructor. The memory capacity should be explicitly specified.
Parameters: memoryCapacity - The maximum cache memory size in bytes. throws: IllegalArgumentException - If memoryCapacity is less than 0. |
add | public void add(RenderedImage owner, int tileX, int tileY, Raster tile)(Code) | | Adds a tile to the cache.
If the specified tile is already in the cache, it will not be
cached again. If by adding this tile, the cache exceeds the memory
capacity, older tiles in the cache are removed to keep the cache
memory usage under the specified limit.
Parameters: owner - The image the tile blongs to. Parameters: tileX - The tile's X index within the image. Parameters: tileY - The tile's Y index within the image. Parameters: tile - The tile to be cached. |
add | public synchronized void add(RenderedImage owner, int tileX, int tileY, Raster tile, Object tileCacheMetric)(Code) | | Adds a tile to the cache with an associated tile compute cost.
If the specified tile is already in the cache, it will not be
cached again. If by adding this tile, the cache exceeds the memory
capacity, older tiles in the cache are removed to keep the cache
memory usage under the specified limit.
Parameters: owner - The image the tile blongs to. Parameters: tileX - The tile's X index within the image. Parameters: tileY - The tile's Y index within the image. Parameters: tile - The tile to be cached. Parameters: tileCacheMetric - Metric for prioritizing tiles |
addTiles | public synchronized void addTiles(RenderedImage owner, Point[] tileIndices, Raster[] tiles, Object tileCacheMetric)(Code) | | Adds an array of tiles to the tile cache.
Parameters: owner - The RenderedImage that the tile belongs to. Parameters: tileIndices - An array of Point s containing thetileX and tileY indices for each tile. Parameters: tiles - The array of tile Raster s containing tile data. Parameters: tileCacheMetric - Object which provides an ordering metricassociated with the RenderedImage owner. since: 1.1 |
disableDiagnostics | public void disableDiagnostics()(Code) | | Turn off diagnostic notification
|
enableDiagnostics | public void enableDiagnostics()(Code) | | Enable Tile Monitoring and Diagnostics
|
flush | public synchronized void flush()(Code) | | Removes -ALL- tiles from the cache.
|
getCacheHitCount | public long getCacheHitCount()(Code) | | |
getCacheMemoryUsed | public long getCacheMemoryUsed()(Code) | | |
getCacheMissCount | public long getCacheMissCount()(Code) | | |
getCacheTileCount | public long getCacheTileCount()(Code) | | |
getCachedObject | public Object getCachedObject()(Code) | | Returns the Object that represents the actual cache.
|
getCachedTileActions | public static EnumeratedParameter[] getCachedTileActions()(Code) | | Returns an array of EnumeratedParameter s corresponding
to the numeric values returned by the getAction()
method of the CachedTile implementation used by
SunTileCache . The "name" of each
EnumeratedParameter provides a brief string
describing the numeric action value.
|
getMemoryCapacity | public long getMemoryCapacity()(Code) | | Returns the cache's memory capacity in bytes.
|
getMemoryThreshold | public float getMemoryThreshold()(Code) | | Returns the current memoryThreshold .
since: 1.1 |
getTile | public synchronized Raster getTile(RenderedImage owner, int tileX, int tileY)(Code) | | Retrieves a tile from the cache.
If the specified tile is not in the cache, this method
returns null . If the specified tile is in the
cache, its last-access time is updated.
Parameters: owner - The image the tile blongs to. Parameters: tileX - The tile's X index within the image. Parameters: tileY - The tile's Y index within the image. |
getTileCapacity | public int getTileCapacity()(Code) | | Returns the cache's tile capacity.
This implementation of TileCache does not use
the tile capacity. This method always returns 0.
|
getTileComparator | public Comparator getTileComparator()(Code) | | Return the current comparator
since: 1.1 |
getTiles | public synchronized Raster[] getTiles(RenderedImage owner)(Code) | | Retrieves a contiguous array of all tiles in the cache which are
owned by the specified image. May be null if there
were no tiles in the cache. The array contains no null entries.
Parameters: owner - The RenderedImage to which the tiles belong. An array of all tiles owned by the specified image ornull if there are none currently in the cache. |
getTiles | public synchronized Raster[] getTiles(RenderedImage owner, Point[] tileIndices)(Code) | | Returns an array of tile Raster s from the cache.
Any or all of the elements of the returned array may be null
if the corresponding tile is not in the cache.
Parameters: owner - The RenderedImage that the tile belongs to. Parameters: tileIndices - An array of Point s containing thetileX and tileY indices for each tile. since: 1.1 |
memoryControl | public synchronized void memoryControl()(Code) | | Removes tiles from the cache based on their last-access time
(old to new) until the memory usage is memoryThreshold % of that of the
memory capacity.
|
remove | public synchronized void remove(RenderedImage owner, int tileX, int tileY)(Code) | | Removes a tile from the cache.
If the specified tile is not in the cache, this method
does nothing.
|
removeTiles | public void removeTiles(RenderedImage owner)(Code) | | Removes all the tiles that belong to a RenderedImage
from the cache.
Parameters: owner - The image whose tiles are to be removed from the cache. |
resetCounts | public void resetCounts()(Code) | | Reset hit and miss counters.
since: 1.1 |
setMemoryCapacity | public void setMemoryCapacity(long memoryCapacity)(Code) | | Sets the cache's memory capacity to the desired number of bytes.
If the new memory capacity is smaller than the amount of memory
currently being used by this cache, tiles are removed from the
cache until the memory usage is less than the specified memory
capacity.
Parameters: memoryCapacity - The desired memory capacity for this cachein bytes. throws: IllegalArgumentException - If memoryCapacity is less than 0. |
setMemoryThreshold | public void setMemoryThreshold(float mt)(Code) | | Set the memory threshold value.
since: 1.1 |
setTileCapacity | public void setTileCapacity(int tileCapacity)(Code) | | Sets the cache's tile capacity to the desired number of tiles.
This implementation of TileCache does not use
the tile capacity. The cache size is limited by the memory
capacity only. This method does nothing and has no effect on
the cache.
Parameters: tileCapacity - The desired tile capacity for this cachein number of tiles. |
setTileComparator | public synchronized void setTileComparator(Comparator c)(Code) | | The Comparator is used to produce an
ordered list of tiles based on a user defined
compute cost or priority metric. This determines
which tiles are subject to "ordered" removal
during a memory control operation.
since: 1.1 |
toString | public String toString()(Code) | | Returns a string representation of the class object.
|
|
|