Package VASSAL.tools.image.tilecache
Class ImageTileDiskCache
java.lang.Object
VASSAL.tools.image.tilecache.ImageTileDiskCache
- All Implemented Interfaces:
Closeable,AutoCloseable,ImageTileSource,FileStore
An on-disk
ImageTileSource and FileStore for image tiles.- Since:
- 3.2.0
- Author:
- Joel Uckelman
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the store.booleanQueries whether a file exists in the store.getFiles()Gets the list of files in the store.Gets the list of files under a given directory of the store.getInputStream(String path)Gets anInputStreamto read from the given file.longGets the modification time of a file in the store, in milliseconds since the epoch.longGets the size of a file in the store, in bytes.Gets an image tile.getTileSize(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- if the tile can't be read
-
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- if the tile can't be read
-
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- if the image can't be read
-
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- oops
-
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- oops
-
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- oops
-
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- oops
-
getFiles
Gets the list of files in the store.- Specified by:
getFilesin interfaceFileStore- Returns:
- the list of files in the store
- Throws:
IOException- oops
-
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- oops
-
isClosed
public boolean isClosed()Checks whether the store is closed. -
close
public void close()Closes the store.
-