jaitools.tilecache
Class DiskCachedTile

java.lang.Object
  extended by jaitools.tilecache.DiskCachedTile
All Implemented Interfaces:
javax.media.jai.CachedTile

public final class DiskCachedTile
extends Object
implements javax.media.jai.CachedTile

A managed tile class for DiskMemTileCache. Represents an image tile that can be cached on disk and/or in memory.

Since:
1.0
Version:
$Id: DiskCachedTile.java 1514 2011-03-07 07:58:54Z michael.bedward $
Author:
Michael Bedward, Simone Giannecchini, GeoSolutions SAS
See Also:
DiskMemTileCache

Nested Class Summary
static class DiskCachedTile.TileAction
           
 
Field Summary
static String FILE_PREFIX
          The prefix used for temporary cache files data
static String FILE_SUFFIX
          The suffix used for temporary cache files
 
Method Summary
 boolean cachedToDisk()
          Query if this tile has been cached to disk.
 void deleteDiskCopy()
          Delete this tile's disk cache file
 int getAction()
          Get the most recent action for this tile.
static File getCacheFolder()
          Get the current cache folder.
 File getFile()
          Get this tile's disk cache file.
 Point getLocation()
          Get this tile's location in its parent image in pixel coordinates
 RenderedImage getOwner()
          Get the image that owns this tile
 Raster getTile()
          Do not use this method.
 Object getTileCacheMetric()
           
 Object getTileId()
          Get the unique ID for this tile.
 long getTileSize()
          Get the tile size in bytes.
 long getTileTimeStamp()
          Get the last time of access for this tile
 int getTileX()
          Return the X location (column) of this tile
 int getTileY()
          Return the Y location (row) of this tile
 boolean isWritable()
          Query if this tile is writable
static void setCacheFolder(File folder)
          Set the current cache folder.
 String toString()
          Returns a string representation of this cached tile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FILE_PREFIX

public static final String FILE_PREFIX
The prefix used for temporary cache files data

See Also:
Constant Field Values

FILE_SUFFIX

public static final String FILE_SUFFIX
The suffix used for temporary cache files

See Also:
Constant Field Values
Method Detail

getCacheFolder

public static File getCacheFolder()
Get the current cache folder. This is the folder in which newly created temporary files holding tile data will be created.

Returns:
a new File object for the current cache folder or null if the default system folder is being used (ie. the folder corresponding to the java.io.file System property

setCacheFolder

public static void setCacheFolder(File folder)
Set the current cache folder. This is the folder in which newly created temporary files holding tile data will be created.

It is safe, though not necessarily sensible, to change the cache folder while one or more caches are running.

Parameters:
folder - the new cache folder or null to use the System's default temporary file folder

toString

public String toString()
Returns a string representation of this cached tile

Overrides:
toString in class Object

getTile

public Raster getTile()
Do not use this method.

It is implemented to satisfy the CAchedTile interface but calling it will provoke an UnsupportedOperationException.

To get a tile, use DiskBasedTileCache#getTile(java.awt.image.RenderedImage, int, int)

Specified by:
getTile in interface javax.media.jai.CachedTile

getOwner

public RenderedImage getOwner()
Get the image that owns this tile

Specified by:
getOwner in interface javax.media.jai.CachedTile

getTileTimeStamp

public long getTileTimeStamp()
Get the last time of access for this tile

Specified by:
getTileTimeStamp in interface javax.media.jai.CachedTile

getTileCacheMetric

public Object getTileCacheMetric()
Specified by:
getTileCacheMetric in interface javax.media.jai.CachedTile

getTileSize

public long getTileSize()
Get the tile size in bytes. This is actually the size of the raster associated with this cached tile instance.

Specified by:
getTileSize in interface javax.media.jai.CachedTile

getAction

public int getAction()
Get the most recent action for this tile. More information can be retrieved by getting the corresponding DiskCachedTile.TileAction constant as shown here:

 int code = tile.getAction();
 TileAction action = TileAction.get(code);
 System.out.println("tile action: " + action.getDescription());
 

Specified by:
getAction in interface javax.media.jai.CachedTile

cachedToDisk

public boolean cachedToDisk()
Query if this tile has been cached to disk. This method is a short-cut for: getFile() != null


getFile

public File getFile()
Get this tile's disk cache file. If the tile has not been cached to disk, return null.


deleteDiskCopy

public void deleteDiskCopy()
Delete this tile's disk cache file


getTileId

public Object getTileId()
Get the unique ID for this tile. The ID is a combination of either the JAI-generated unique ID of the owning image or the image's hash key if a unique ID was not available plus the tile index. The returned object will be either Long or BigInteger.


getLocation

public Point getLocation()
Get this tile's location in its parent image in pixel coordinates

Returns:
a new Point instance for the location

getTileX

public int getTileX()
Return the X location (column) of this tile

Returns:
tile X location

getTileY

public int getTileY()
Return the Y location (row) of this tile

Returns:
tile Y location

isWritable

public boolean isWritable()
Query if this tile is writable



Copyright © 2009-2011. All Rights Reserved.