Class MapImageCacheEntry


  • public class MapImageCacheEntry
    extends java.lang.Object
    An image cache entry for one ImageType.
    • Constructor Summary

      Constructors 
      Constructor Description
      MapImageCacheEntry​(@NotNull CacheFiles cacheFiles, @NotNull java.awt.Image defaultImage, @NotNull java.lang.String prefix)
      Creates a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void flush​(@NotNull java.io.File mapFile)
      Removes the cached image for a map file.
      @NotNull java.awt.Image getDefaultImage()
      Returns the default image.
      @Nullable java.awt.Image lookupCache​(@NotNull java.io.File mapFile)
      Looks up an image from the cache.
      @NotNull java.awt.Image scaleImage​(@Nullable java.io.File mapFile, @NotNull java.awt.Image image, int width, int height)
      Scales an Image to the given size and updates the cache.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MapImageCacheEntry

        public MapImageCacheEntry​(@NotNull
                                  @NotNull CacheFiles cacheFiles,
                                  @NotNull
                                  @NotNull java.awt.Image defaultImage,
                                  @NotNull
                                  @NotNull java.lang.String prefix)
        Creates a new instance.
        Parameters:
        cacheFiles - the cache files for generating files for caching icons and previews
        defaultImage - the default image
        prefix - the directory prefix for the cache directory
    • Method Detail

      • flush

        public void flush​(@NotNull
                          @NotNull java.io.File mapFile)
        Removes the cached image for a map file. Both in-memory and on-disk cache are purged.
        Parameters:
        mapFile - the map file to flush
      • lookupCache

        @Nullable
        public @Nullable java.awt.Image lookupCache​(@NotNull
                                                    @NotNull java.io.File mapFile)
        Looks up an image from the cache.
        Parameters:
        mapFile - the map file to look up
        Returns:
        the image, or null if the cache does not contain an entry for mapFile or if the entry is outdated
      • getDefaultImage

        @NotNull
        public @NotNull java.awt.Image getDefaultImage()
        Returns the default image.
        Returns:
        the default image
      • scaleImage

        @NotNull
        public @NotNull java.awt.Image scaleImage​(@Nullable
                                                  @Nullable java.io.File mapFile,
                                                  @NotNull
                                                  @NotNull java.awt.Image image,
                                                  int width,
                                                  int height)
        Scales an Image to the given size and updates the cache. If an out of memory error occurs the default image is returned.
        Parameters:
        mapFile - the map file for the image
        image - the image to scale
        width - the scaled width
        height - the scaled height
        Returns:
        the scaled image