jsky.image
Class MyTileCache

java.lang.Object
  extended by jsky.image.MyTileCache

public class MyTileCache
extends java.lang.Object

Implements the JAI TileCache interface.

Version:
$Revision: 1.1 $
Author:
Allan Brighton

Constructor Summary
MyTileCache(int imageWidth, int imageHeight, int tileWidth, int tileHeight, int bytesPerPixel)
          Create a new tile cache for an image with the given size.
MyTileCache(int imageWidth, int imageHeight, int tileWidth, int tileHeight, int bytesPerPixel, int memoryCapacity)
          Create a new tile cache for an image with the given size.
 
Method Summary
 void add(int tileX, int tileY, java.awt.image.Raster tile)
          Adds a tile to the cache.
 void clear()
          Clear the tile cache, so that the memory may be reclaimed
 long getMemoryCapacity()
          Returns the memory capacity in bytes.
 java.awt.image.Raster getTile(int tileX, int tileY)
          Retrieves a tile.
 int getTileCapacity()
          Returns the tile capacity in tiles.
 void remove(int tileX, int tileY)
          Advises the cache that a tile is no longer needed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MyTileCache

public MyTileCache(int imageWidth,
                   int imageHeight,
                   int tileWidth,
                   int tileHeight,
                   int bytesPerPixel,
                   int memoryCapacity)
Create a new tile cache for an image with the given size.

Parameters:
imageWidth - The width of the image in pixels
imageHeight - The height of the image in pixels
tileWidth - The width of a tile in pixels
tileHeight - The height of a tile in pixels
bytesPerPixel - The number of bytes required for one pixel
memoryCapacity - The maximum number of bytes to allocate before discarding old tiles

MyTileCache

public MyTileCache(int imageWidth,
                   int imageHeight,
                   int tileWidth,
                   int tileHeight,
                   int bytesPerPixel)
Create a new tile cache for an image with the given size. The maximum memory usage is set to 64MB.

Parameters:
imageWidth - The width of the image in pixels
imageHeight - The height of the image in pixels
tileWidth - The width of a tile in pixels
tileHeight - The height of a tile in pixels
bytesPerPixel - The number of bytes required for one pixel
Method Detail

add

public void add(int tileX,
                int tileY,
                java.awt.image.Raster tile)
Adds a tile to the cache.

Parameters:
tileX - The X index of the tile in the tile grid.
tileY - The Y index of the tile in the tile grid.
tile - A Raster containging the tile data.

remove

public void remove(int tileX,
                   int tileY)
Advises the cache that a tile is no longer needed. It is legal to implement this method as a no-op.

Parameters:
tileX - The X index of the tile in the tile grid.
tileY - The Y index of the tile in the tile grid.

clear

public void clear()
Clear the tile cache, so that the memory may be reclaimed


getTile

public java.awt.image.Raster getTile(int tileX,
                                     int tileY)
Retrieves a tile. Returns null if the tile is not present in the cache.

Parameters:
tileX - The X index of the tile in the tile grid.
tileY - The Y index of the tile in the tile grid.

getTileCapacity

public int getTileCapacity()
Returns the tile capacity in tiles.


getMemoryCapacity

public long getMemoryCapacity()
Returns the memory capacity in bytes.