|
Gridarta Editor
|
An image cache entry for one ImageType. More...
Collaboration diagram for net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry:Public Member Functions | |
| void | flush (@NotNull final File mapFile) |
| Removes the cached image for a map file. More... | |
| Image | getDefaultImage () |
| Returns the default image. More... | |
| Image | lookupCache (@NotNull final File mapFile) |
| Looks up an image from the cache. More... | |
| MapImageCacheEntry (@NotNull final CacheFiles cacheFiles, @NotNull final Image defaultImage, @NotNull final String prefix) | |
| Creates a new instance. More... | |
| Image | scaleImage (@Nullable final File mapFile, @NotNull final Image image, final int width, final int height) |
| Scales an Image to the given size and updates the cache. More... | |
Private Member Functions | |
| Image | getImageIcon (@NotNull final File mapFile) |
| Returns the Image for a given map file. More... | |
| Image | loadImageFile (@NotNull final File mapFile) |
| Loads an image file from disk. More... | |
| void | saveImageFile (@NotNull final File mapFile, @NotNull final Image image) |
| Saves an PNG image file for a map file. More... | |
Static Private Member Functions | |
| static void | deleteCacheFile (@NotNull final File cacheFile) |
| Deletes a cache file if it exists. More... | |
Private Attributes | |
| final CacheFiles | cacheFiles |
| The CacheFiles for generating files for cached icons and previews. More... | |
| final Image | defaultImage |
| The default image. More... | |
| final Map< File, WeakReference< Image > > | images = new HashMap<>() |
| The cached icons. More... | |
| final String | prefix |
| The directory prefix name for the cache directory. More... | |
| final Map< File, Long > | timestamps = new HashMap<>() |
| The timestamps of the cached icons. More... | |
Static Private Attributes | |
| static final Category | LOG = Logger.getLogger(MapImageCacheEntry.class) |
| The logger for printing log messages. More... | |
An image cache entry for one ImageType.
Definition at line 42 of file MapImageCacheEntry.java.
| net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.MapImageCacheEntry | ( | @NotNull final CacheFiles | cacheFiles, |
| @NotNull final Image | defaultImage, | ||
| @NotNull final String | prefix | ||
| ) |
Creates a new instance.
| cacheFiles | the cache files for generating files for caching icons and previews |
| defaultImage | the default image |
| prefix | the directory prefix for the cache directory |
Definition at line 87 of file MapImageCacheEntry.java.
References net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.cacheFiles, net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.defaultImage, and net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.prefix.
|
staticprivate |
Deletes a cache file if it exists.
Logs a warning message if the file cannot be deleted.
| cacheFile | the cache file to delete |
Definition at line 109 of file MapImageCacheEntry.java.
Referenced by net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.flush(), and net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.loadImageFile().
Here is the caller graph for this function:| void net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.flush | ( | @NotNull final File | mapFile | ) |
Removes the cached image for a map file.
Both in-memory and on-disk cache are purged.
| mapFile | the map file to flush |
Definition at line 98 of file MapImageCacheEntry.java.
References net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.deleteCacheFile(), and net.sf.gridarta.model.io.CacheFiles.getCacheFile().
Here is the call graph for this function:| Image net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.getDefaultImage | ( | ) |
Returns the default image.
Definition at line 250 of file MapImageCacheEntry.java.
References net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.defaultImage.
|
private |
Returns the Image for a given map file.
| mapFile | the map file |
Definition at line 121 of file MapImageCacheEntry.java.
Referenced by net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.lookupCache().
Here is the caller graph for this function:
|
private |
Loads an image file from disk.
If the file does not exists, cannot be loaded, or is outdated, return
.
| mapFile | the map file name |
Definition at line 179 of file MapImageCacheEntry.java.
References net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.deleteCacheFile(), and net.sf.gridarta.model.io.CacheFiles.getCacheFile().
Referenced by net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.lookupCache().
Here is the call graph for this function:
Here is the caller graph for this function:| Image net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.lookupCache | ( | @NotNull final File | mapFile | ) |
Looks up an image from the cache.
| mapFile | the map file to look up |
Definition at line 223 of file MapImageCacheEntry.java.
References net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.getImageIcon(), and net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.loadImageFile().
Here is the call graph for this function:
|
private |
Saves an PNG image file for a map file.
| mapFile | the map file to save the image of |
| image | the image to save |
Definition at line 140 of file MapImageCacheEntry.java.
References net.sf.gridarta.model.io.CacheFiles.getCacheFile().
Referenced by net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.scaleImage().
Here is the call graph for this function:
Here is the caller graph for this function:| Image net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.scaleImage | ( | @Nullable final File | mapFile, |
| @NotNull final Image | image, | ||
| final int | width, | ||
| final 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.
| mapFile | the map file for the image |
| image | the image to scale |
| width | the scaled width |
| height | the scaled height |
Definition at line 264 of file MapImageCacheEntry.java.
References net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.defaultImage, net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.saveImageFile(), and net.sf.gridarta.utils.ImageUtils.scaleImage().
Here is the call graph for this function:
|
private |
The CacheFiles for generating files for cached icons and previews.
Definition at line 55 of file MapImageCacheEntry.java.
Referenced by net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.MapImageCacheEntry().
|
private |
The default image.
Definition at line 61 of file MapImageCacheEntry.java.
Referenced by net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.getDefaultImage(), net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.MapImageCacheEntry(), and net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.scaleImage().
|
private |
|
staticprivate |
The logger for printing log messages.
Definition at line 48 of file MapImageCacheEntry.java.
|
private |
The directory prefix name for the cache directory.
Definition at line 66 of file MapImageCacheEntry.java.
Referenced by net.sf.gridarta.gui.mapimagecache.MapImageCacheEntry.MapImageCacheEntry().
|
private |
The timestamps of the cached icons.
Maps map file to timestamp.
Definition at line 78 of file MapImageCacheEntry.java.