Package VASSAL.tools.image.tilecache
Class ImageTileDiskCache
java.lang.Object
VASSAL.tools.image.tilecache.ImageTileDiskCache
- All Implemented Interfaces:
Closeable,AutoCloseable,ImageTileSource,FileStore
public class ImageTileDiskCache extends Object implements ImageTileSource, FileStore
An on-disk
ImageTileSource and FileStore for image tiles.- Since:
- 3.2.0
- Author:
- Joel Uckelman
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ImageTileDiskCache(String cpath)Creates anImageTileDiskCache. -
Method Summary
Modifier and Type Method Description voidclose()Closes the store.booleancontains(String path)Queries whether a file exists in the store.List<String>getFiles()Gets the list of files in the store.List<String>getFiles(String root)Gets the list of files under a given directory of the store.InputStreamgetInputStream(String path)Gets anInputStreamto read from the given file.longgetMTime(String path)Gets the modification time of a file in the store, in milliseconds since the epoch.longgetSize(String path)Gets the size of a file in the store, in bytes.BufferedImagegetTile(String name, int tileX, int tileY, double scale)Gets an image tile.DimensiongetTileSize(String name, int tileX, int tileY, double scale)Gets the size of an image tile.booleanisClosed()Checks whether the store is closed.booleantileExists(String name, int tileX, int tileY, double scale)Checks whether an image tile exists.
-
Field Details
-
cpath
-
-
Constructor Details
-
ImageTileDiskCache
Creates anImageTileDiskCache.- Parameters:
cpath- path to the root directory of the cache
-
-
Method Details
-
getTile
public BufferedImage getTile(String name, int tileX, int tileY, double scale) throws ImageIOExceptionGets an image tile.- Specified by:
getTilein interfaceImageTileSource- Parameters:
name- the image nametileX- the X coordinate of the tiletileY- the Y coordinate of the tilescale- the scale of the tile- Returns:
- the tile
- Throws:
ImageIOException
-
getTileSize
public Dimension getTileSize(String name, int tileX, int tileY, double scale) throws ImageIOExceptionGets the size of an image tile.- Specified by:
getTileSizein interfaceImageTileSource- Parameters:
name- the image nametileX- the X coordinate of the tiletileY- the Y coordinate of the tilescale- the scale of the tile- Returns:
- the size of the tile
- Throws:
ImageIOException
-
tileExists
Checks whether an image tile exists.- Specified by:
tileExistsin interfaceImageTileSource- Parameters:
name- the image nametileX- the X coordinate of the tiletileY- the Y coordinate of the tilescale- the scale of the tile- Throws:
ImageIOException
-
contains
Queries whether a file exists in the store.- Specified by:
containsin interfaceFileStore- Parameters:
path- the path to the file in the store- Returns:
trueif the file exists in the store- Throws:
IOException
-
getInputStream
Gets anInputStreamto read from the given file.- Specified by:
getInputStreamin interfaceFileStore- Parameters:
path- the path to the file in the store- Returns:
- an
InputStreamcontaining the requested file - Throws:
IOException
-
getSize
Gets the size of a file in the store, in bytes.- Specified by:
getSizein interfaceFileStore- Parameters:
path- the path to the file in the store- Returns:
- the size of the file, in bytes
- Throws:
FileNotFoundException- ifpathis not in the storeIOException
-
getMTime
Gets the modification time of a file in the store, in milliseconds since the epoch.- Specified by:
getMTimein interfaceFileStore- Parameters:
path- the path to the file in the store- Returns:
- the mtime of the file
- Throws:
FileNotFoundException- ifpathis not in the storeIOException
-
getFiles
Gets the list of files in the store.- Specified by:
getFilesin interfaceFileStore- Returns:
- the list of files in the store
- Throws:
IOException
-
getFiles
Gets the list of files under a given directory of the store.- Specified by:
getFilesin interfaceFileStore- Parameters:
root- the directory- Returns:
- the list of files under the given directory
- Throws:
FileNotFoundException- ifrootis not in the storeIOException
-
isClosed
public boolean isClosed()Checks whether the store is closed. -
close
public void close()Closes the store.
-