org.jaitools.tilecache
Class DiskCachedTile

java.lang.Object
  extended by org.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$
Author:
Michael Bedward, Simone Giannecchini, GeoSolutions SAS
See Also:
DiskMemTileCache

Nested Class Summary
static class DiskCachedTile.TileAction
          Constants identifying tile actions.
 
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()
          Queries if this tile has been cached to disk.
 void deleteDiskCopy()
          Deletes this tile's disk cache file.
 int getAction()
          Gets the most recent action for this tile.
static File getCacheFolder()
          Get the current cache folder.
 File getFile()
          Gets this tile's disk cache file.
 Point getLocation()
          Gets this tile's location in its parent image in pixel coordinates
 RenderedImage getOwner()
          Gets the image that owns this tile.
 Raster getTile()
          Do not use this method.
 Object getTileCacheMetric()
          Gets the tile cache metric for this tile.
 Object getTileId()
          Gets the unique ID for this tile.
 long getTileSize()
          Gets the tile size in bytes.
 long getTileTimeStamp()
          Gets the last time of access for this tile.
 int getTileX()
          Gets the X ordinate of this tile in the parent image tile grid.
 int getTileY()
          Gets the Y ordinate of this tile in the parent image tile grid.
 boolean isWritable()
          Queries 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()
Gets the image that owns this tile.

Specified by:
getOwner in interface javax.media.jai.CachedTile
Returns:
the owning image

getTileTimeStamp

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

Specified by:
getTileTimeStamp in interface javax.media.jai.CachedTile
Returns:
the time stamp

getTileCacheMetric

public Object getTileCacheMetric()
Gets the tile cache metric for this tile.

Specified by:
getTileCacheMetric in interface javax.media.jai.CachedTile
Returns:
the metric

getTileSize

public long getTileSize()
Gets 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
Returns:
tile size in bytes

getAction

public int getAction()
Gets 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
Returns:
the most recent action

cachedToDisk

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

Returns:
true if the tile is cached on disk; false otherwise

getFile

public File getFile()
Gets this tile's disk cache file. Returns null if the tile has not been cached to disk.

Returns:
the disk cache file for this tile or null

deleteDiskCopy

public void deleteDiskCopy()
Deletes this tile's disk cache file. If the file could not be deleted a warning is logged.


getTileId

public Object getTileId()
Gets 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.

Returns:
tile ID

getLocation

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

Returns:
tile origin expressed in parent image coordinates

getTileX

public int getTileX()
Gets the X ordinate of this tile in the parent image tile grid.

Returns:
tile grid X ordinate

getTileY

public int getTileY()
Gets the Y ordinate of this tile in the parent image tile grid.

Returns:
tile grid Y ordinate

isWritable

public boolean isWritable()
Queries if this tile is writable.

Returns:
true if writable; false otherwise


Copyright © 2009-2013. All Rights Reserved.