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 Details

    • cpath

      protected final String cpath
  • Constructor Details

    • ImageTileDiskCache

      public ImageTileDiskCache​(String cpath)
      Creates an ImageTileDiskCache.
      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 interface ImageTileSource
      Parameters:
      name - the image name
      tileX - the X coordinate of the tile
      tileY - the Y coordinate of the tile
      scale - the scale of the tile
      Returns:
      the tile
      Throws:
      ImageIOException
    • 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 interface ImageTileSource
      Parameters:
      name - the image name
      tileX - the X coordinate of the tile
      tileY - the Y coordinate of the tile
      scale - the scale of the tile
      Returns:
      the size of the tile
      Throws:
      ImageIOException
    • tileExists

      public boolean tileExists​(String name, int tileX, int tileY, double scale) throws ImageIOException
      Checks whether an image tile exists.
      Specified by:
      tileExists in interface ImageTileSource
      Parameters:
      name - the image name
      tileX - the X coordinate of the tile
      tileY - the Y coordinate of the tile
      scale - the scale of the tile
      Throws:
      ImageIOException
    • contains

      public boolean contains​(String path) throws IOException
      Queries whether a file exists in the store.
      Specified by:
      contains in interface FileStore
      Parameters:
      path - the path to the file in the store
      Returns:
      true if the file exists in the store
      Throws:
      IOException
    • getInputStream

      public InputStream getInputStream​(String path) throws IOException
      Gets an InputStream to read from the given file.
      Specified by:
      getInputStream in interface FileStore
      Parameters:
      path - the path to the file in the store
      Returns:
      an InputStream containing the requested file
      Throws:
      IOException
    • getSize

      public long getSize​(String path) throws IOException
      Gets the size of a file in the store, in bytes.
      Specified by:
      getSize in interface FileStore
      Parameters:
      path - the path to the file in the store
      Returns:
      the size of the file, in bytes
      Throws:
      FileNotFoundException - if path is not in the store
      IOException
    • getMTime

      public long getMTime​(String path) throws IOException
      Gets the modification time of a file in the store, in milliseconds since the epoch.
      Specified by:
      getMTime in interface FileStore
      Parameters:
      path - the path to the file in the store
      Returns:
      the mtime of the file
      Throws:
      FileNotFoundException - if path is not in the store
      IOException
    • getFiles

      public List<String> getFiles() throws IOException
      Gets the list of files in the store.
      Specified by:
      getFiles in interface FileStore
      Returns:
      the list of files in the store
      Throws:
      IOException
    • getFiles

      public List<String> getFiles​(String root) throws IOException
      Gets the list of files under a given directory of the store.
      Specified by:
      getFiles in interface FileStore
      Parameters:
      root - the directory
      Returns:
      the list of files under the given directory
      Throws:
      FileNotFoundException - if root is not in the store
      IOException
    • isClosed

      public boolean isClosed()
      Checks whether the store is closed.
      Specified by:
      isClosed in interface FileStore
      Returns:
      true if the archive is closed
    • close

      public void close()
      Closes the store.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface FileStore