public class MyTileCache extends Object
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int tileX,
int tileY,
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.
|
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.
|
public MyTileCache(int imageWidth, int imageHeight, int tileWidth, int tileHeight, int bytesPerPixel, int memoryCapacity)
imageWidth
- The width of the image in pixelsimageHeight
- The height of the image in pixelstileWidth
- The width of a tile in pixelstileHeight
- The height of a tile in pixelsbytesPerPixel
- The number of bytes required for one pixelmemoryCapacity
- The maximum number of bytes to allocate before discarding old tilespublic MyTileCache(int imageWidth, int imageHeight, int tileWidth, int tileHeight, int bytesPerPixel)
imageWidth
- The width of the image in pixelsimageHeight
- The height of the image in pixelstileWidth
- The width of a tile in pixelstileHeight
- The height of a tile in pixelsbytesPerPixel
- The number of bytes required for one pixelpublic void add(int tileX, int tileY, Raster tile)
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.public void remove(int tileX, int tileY)
tileX
- The X index of the tile in the tile grid.tileY
- The Y index of the tile in the tile grid.public void clear()
public Raster getTile(int tileX, int tileY)
null
if the tile is not
present in the cache.tileX
- The X index of the tile in the tile grid.tileY
- The Y index of the tile in the tile grid.public int getTileCapacity()
public long getMemoryCapacity()
Copyright © 2023 Central Laboratory of the Research Councils. All Rights Reserved.