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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the store.boolean
Queries 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 anInputStream
to read from the given file.long
Gets the modification time of a file in the store, in milliseconds since the epoch.long
Gets 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.boolean
isClosed()
Checks whether the store is closed.boolean
tileExists
(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 ImageIOException Gets an image tile.- Specified by:
getTile
in 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 ImageIOException Gets the size of an image tile.- Specified by:
getTileSize
in 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:
tileExists
in 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:
contains
in interfaceFileStore
- Parameters:
path
- the path to the file in the store- Returns:
true
if the file exists in the store- Throws:
IOException
- oops
-
getInputStream
Gets anInputStream
to read from the given file.- Specified by:
getInputStream
in interfaceFileStore
- Parameters:
path
- the path to the file in the store- Returns:
- an
InputStream
containing the requested file - Throws:
IOException
- oops
-
getSize
Gets the size of a file in the store, in bytes.- Specified by:
getSize
in interfaceFileStore
- Parameters:
path
- the path to the file in the store- Returns:
- the size of the file, in bytes
- Throws:
IOException
- oops
-
getMTime
Gets the modification time of a file in the store, in milliseconds since the epoch.- Specified by:
getMTime
in interfaceFileStore
- Parameters:
path
- the path to the file in the store- Returns:
- the mtime of the file
- Throws:
IOException
- oops
-
getFiles
Gets the list of files in the store.- Specified by:
getFiles
in 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:
getFiles
in interfaceFileStore
- Parameters:
root
- the directory- Returns:
- the list of files under the given directory
- Throws:
IOException
- oops
-
isClosed
-
close
-