Class MapImageCacheEntry
- java.lang.Object
-
- net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry
-
public class MapImageCacheEntry extends java.lang.ObjectAn image cache entry for oneImageType.
-
-
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 voidflush(@NotNull java.io.File mapFile)Removes the cached image for a map file.@NotNull java.awt.ImagegetDefaultImage()Returns the default image.@Nullable java.awt.ImagelookupCache(@NotNull java.io.File mapFile)Looks up an image from the cache.@NotNull java.awt.ImagescaleImage(@Nullable java.io.File mapFile, @NotNull java.awt.Image image, int width, int height)Scales anImageto the given size and updates the cache.
-
-
-
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 previewsdefaultImage- the default imageprefix- 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
nullif the cache does not contain an entry formapFileor 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 anImageto 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 imageimage- the image to scalewidth- the scaled widthheight- the scaled height- Returns:
- the scaled image
-
-