|
Gridarta Editor
|
Caches icon and preview images for map files. More...
Inheritance diagram for net.sf.gridarta.gui.mapimagecache.MapImageCache< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:
Collaboration diagram for net.sf.gridarta.gui.mapimagecache.MapImageCache< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:Public Member Functions | |
| void | addMapImageCacheListener (@NotNull final MapImageCacheListener< G, A, R > listener) |
| Adds a MapImageCacheListener to be notified. More... | |
| void | flush (@NotNull final File mapFile) |
| Removes the cached images for a map file. More... | |
| Image | getIcon (@NotNull final File mapFile) |
| Returns the icon Image for a given map file. More... | |
| Image | getOrCreateIcon (@NotNull final File mapFile) |
| Returns an icon Image for a given map file. More... | |
| Image | getOrCreateIcon (@NotNull final MapControl< G, A, R > mapControl) |
| Returns an icon Image for a given map. More... | |
| Image | getOrCreatePreview (@NotNull final File mapFile) |
| Returns a preview Image for a given map file. More... | |
| Image | getOrCreatePreview (@NotNull final MapControl< G, A, R > mapControl) |
| Returns a preview Image for a given map. More... | |
| Image | getPreview (@NotNull final File mapFile) |
| Returns a preview Image for a given map file. More... | |
| MapImageCache (@NotNull final MapManager< G, A, R > mapManager, @NotNull final Image defaultIcon, @NotNull final Image defaultPreview, @NotNull final RendererFactory< G, A, R > rendererFactory, @NotNull final CacheFiles cacheFiles) | |
| Creates a new instance. More... | |
| void | removeMapImageCacheListener (@NotNull final MapImageCacheListener< G, A, R > listener) |
| Removes a MapControlListener to be notified. More... | |
Private Member Functions | |
| Image | getOrCreate (@NotNull final MapControl< G, A, R > mapControl, @NotNull final ImageType imageType) |
| Returns an icon or preview Image for a given map. More... | |
| Image | getOrCreate (@NotNull final File mapFile, @NotNull final ImageType imageType) |
| Returns a preview Image for a given map file. More... | |
| MapRenderer | getRenderer (@NotNull final MapControl< G, A, R > mapControl) |
| Returns a MapRenderer for a map. More... | |
| Image | updateCaches (@NotNull final File mapFile, final ImageType imageType) |
| Updates the cached icon and preview Images for one map file. More... | |
| Image | updateCaches (@Nullable final File mapFile, @NotNull final MapControl< G, A, R > mapControl, final ImageType imageType) |
| Updates the cached icon and preview Images for one map file. More... | |
Private Attributes | |
| final Map< ImageType, MapImageCacheEntry > | entries = new EnumMap<>(ImageType.class) |
| The cache entries. More... | |
| final EventListenerList2< MapImageCacheListener< G, A, R > > | listenerList = new EventListenerList2<>(MapImageCacheListener.class) |
| The registered event listeners. More... | |
| final MapControlListener< G, A, R > | mapControlListener |
| The MapControlListener attached to all MapControls. More... | |
| final MapManager< G, A, R > | mapManager |
| The MapManager for loading maps. More... | |
| final Map< MapControl< G, A, R >, SoftReference< MapRenderer > > | mapRendererReferences = new HashMap<>() |
| Maps MapControl instance to MapRenderer which is only used to get images. More... | |
| final RendererFactory< G, A, R > | rendererFactory |
| The RendererFactory for creating renderers. More... | |
Static Private Attributes | |
| static final int | ICON_HEIGHT = 23 |
| The height of icons in pixels. More... | |
| static final int | ICON_WIDTH = 48 |
| The width of icons in pixels. More... | |
| static final int | PREVIEW_SCALE = 8 |
| The scale factor for preview images. More... | |
Caches icon and preview images for map files.
Cached images are cached both on disk and in memory using weak references. Icons have a fixed size (ICON_WIDTHxICON_HEIGHT pixels); previews are scaled down from the normal size by the factor PREVIEW_SCALE.
Definition at line 53 of file MapImageCache.java.
| net.sf.gridarta.gui.mapimagecache.MapImageCache< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.MapImageCache | ( | @NotNull final MapManager< G, A, R > | mapManager, |
| @NotNull final Image | defaultIcon, | ||
| @NotNull final Image | defaultPreview, | ||
| @NotNull final RendererFactory< G, A, R > | rendererFactory, | ||
| @NotNull final CacheFiles | cacheFiles | ||
| ) |
Creates a new instance.
| mapManager | the map manager for loading maps |
| defaultIcon | the default icon to return if no icon can be created for a map |
| defaultPreview | the default preview image to return if no preview can be created for a map |
| rendererFactory | the renderer factory for creating renderers |
| cacheFiles | the cache files for generating files for cached icons and previews |
Purges cached renderers from MapImageCache#mapRendererReferences when a map is closed.
Definition at line 130 of file MapImageCache.java.
| void net.sf.gridarta.gui.mapimagecache.MapImageCache< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.addMapImageCacheListener | ( | @NotNull final MapImageCacheListener< G, A, R > | listener | ) |
Adds a MapImageCacheListener to be notified.
| listener | the listener to add |
Definition at line 324 of file MapImageCache.java.
| void net.sf.gridarta.gui.mapimagecache.MapImageCache< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.flush | ( | @NotNull final File | mapFile | ) |
Removes the cached images for a map file.
| mapFile | the map file to purge |
Definition at line 172 of file MapImageCache.java.
Referenced by net.sf.gridarta.gui.map.MapPreviewAccessory.genPreview().
Here is the caller graph for this function:| Image net.sf.gridarta.gui.mapimagecache.MapImageCache< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getIcon | ( | @NotNull final File | mapFile | ) |
Returns the icon Image for a given map file.
If no image is cached (or if the cached image is outdated), returns
.
| mapFile | the map file |
Definition at line 185 of file MapImageCache.java.
Referenced by net.sf.gridarta.gui.map.MapPreviewAccessory.getMapIcon().
Here is the caller graph for this function:
|
private |
Returns an icon or preview Image for a given map.
If no image is cached (or if the cached image is outdated), (re-)creates the image.
| mapControl | the map |
| imageType | the image type to use |
Definition at line 344 of file MapImageCache.java.
Referenced by net.sf.gridarta.gui.mapimagecache.MapImageCache<?, ?, ?>.getOrCreateIcon(), and net.sf.gridarta.gui.mapimagecache.MapImageCache<?, ?, ?>.getOrCreatePreview().
Here is the caller graph for this function:
|
private |
Returns a preview Image for a given map file.
If no image is cached (or if the cached image is outdated), loads the map and creates the image.
| mapFile | the map file |
| imageType | the image type to return |
Definition at line 365 of file MapImageCache.java.
| Image net.sf.gridarta.gui.mapimagecache.MapImageCache< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getOrCreateIcon | ( | @NotNull final File | mapFile | ) |
Returns an icon Image for a given map file.
If no image is cached (or if the cached image is outdated), loads the map and creates the icon.
| mapFile | the map file |
Definition at line 197 of file MapImageCache.java.
Referenced by net.sf.gridarta.gui.map.MapPreviewAccessory.getMapIcon(), net.sf.gridarta.gui.mapdesktop.MapDesktop< G, A, R >.updateFrameIcon(), and net.sf.gridarta.gui.mapmenu.MapMenuEntryTreeCellRenderer.visit().
Here is the caller graph for this function:| Image net.sf.gridarta.gui.mapimagecache.MapImageCache< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getOrCreateIcon | ( | @NotNull final MapControl< G, A, R > | mapControl | ) |
Returns an icon Image for a given map.
If no image is cached (or if the cached image is outdated), (re-)creates it.
| mapControl | the map |
Definition at line 208 of file MapImageCache.java.
| Image net.sf.gridarta.gui.mapimagecache.MapImageCache< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getOrCreatePreview | ( | @NotNull final File | mapFile | ) |
Returns a preview Image for a given map file.
If no image is cached (or if the cached image is outdated), loads the map and creates the image.
| mapFile | the map file |
Definition at line 231 of file MapImageCache.java.
Referenced by net.sf.gridarta.gui.map.MapPreviewAccessory.genPreview(), net.sf.gridarta.gui.map.MapPreviewAccessory.getMapPreview(), and net.sf.gridarta.gui.dialog.bookmarks.MapMenuEntryIcons.visit().
Here is the caller graph for this function:| Image net.sf.gridarta.gui.mapimagecache.MapImageCache< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getOrCreatePreview | ( | @NotNull final MapControl< G, A, R > | mapControl | ) |
Returns a preview Image for a given map.
If no image is cached (or if the cached image is outdated), (re-)creates the image.
| mapControl | the map |
Definition at line 242 of file MapImageCache.java.
| Image net.sf.gridarta.gui.mapimagecache.MapImageCache< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getPreview | ( | @NotNull final File | mapFile | ) |
Returns a preview Image for a given map file.
If no image is cached (or if the cached image is outdated), returns
.
| mapFile | the map file |
Definition at line 219 of file MapImageCache.java.
Referenced by net.sf.gridarta.gui.map.MapPreviewAccessory.getMapPreview().
Here is the caller graph for this function:
|
private |
Returns a MapRenderer for a map.
If no renderer is cached a new one is created and returned.
| mapControl | the map to get the renderer for |
Definition at line 307 of file MapImageCache.java.
Referenced by net.sf.gridarta.gui.mapimagecache.MapImageCache<?, ?, ?>.updateCaches().
Here is the caller graph for this function:| void net.sf.gridarta.gui.mapimagecache.MapImageCache< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.removeMapImageCacheListener | ( | @NotNull final MapImageCacheListener< G, A, R > | listener | ) |
Removes a MapControlListener to be notified.
| listener | the listener to remove |
Definition at line 332 of file MapImageCache.java.
|
private |
Updates the cached icon and preview Images for one map file.
| mapFile | the map file |
| imageType | the type of the image to return |
Definition at line 254 of file MapImageCache.java.
Referenced by net.sf.gridarta.gui.mapimagecache.MapImageCache<?, ?, ?>.getOrCreate(), and net.sf.gridarta.gui.mapimagecache.MapImageCache<?, ?, ?>.updateCaches().
Here is the caller graph for this function:
|
private |
Updates the cached icon and preview Images for one map file.
| mapFile | the map file or null |
| mapControl | the map control instance corresponding to mapFile |
| imageType | the type of the image to return |
Definition at line 279 of file MapImageCache.java.
|
private |
The cache entries.
Maps ImageType to associated entry. All entries exist.
Definition at line 93 of file MapImageCache.java.
|
staticprivate |
The height of icons in pixels.
Definition at line 63 of file MapImageCache.java.
|
staticprivate |
The width of icons in pixels.
Definition at line 58 of file MapImageCache.java.
|
private |
The registered event listeners.
Definition at line 86 of file MapImageCache.java.
|
private |
The MapControlListener attached to all MapControls.
It updates the cached icon and preview for saved maps.
Definition at line 106 of file MapImageCache.java.
|
private |
The MapManager for loading maps.
Definition at line 74 of file MapImageCache.java.
Referenced by net.sf.gridarta.gui.mapimagecache.MapImageCache<?, ?, ?>.MapImageCache().
|
private |
Maps MapControl instance to MapRenderer which is only used to get images.
Definition at line 100 of file MapImageCache.java.
|
staticprivate |
The scale factor for preview images.
Definition at line 68 of file MapImageCache.java.
|
private |
The RendererFactory for creating renderers.
Definition at line 80 of file MapImageCache.java.
Referenced by net.sf.gridarta.gui.mapimagecache.MapImageCache<?, ?, ?>.MapImageCache().