public class MapImageCache<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
extends java.lang.Object
ICON_WIDTHxICON_HEIGHT pixels); previews are scaled down from the
normal size by the factor PREVIEW_SCALE.| Constructor and Description |
|---|
MapImageCache(@NotNull MapManager<G,A,R> mapManager,
@NotNull java.awt.Image defaultIcon,
@NotNull java.awt.Image defaultPreview,
@NotNull RendererFactory<G,A,R> rendererFactory,
@NotNull CacheFiles cacheFiles)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addMapImageCacheListener(@NotNull MapImageCacheListener<G,A,R> listener)
Adds a
MapImageCacheListener to be notified. |
void |
flush(@NotNull java.io.File mapFile)
Removes the cached images for a map file.
|
@Nullable java.awt.Image |
getIcon(@NotNull java.io.File mapFile)
Returns the icon
Image for a given map file. |
@Nullable java.awt.Image |
getOrCreateIcon(@NotNull java.io.File mapFile)
Returns an icon
Image for a given map file. |
@NotNull java.awt.Image |
getOrCreateIcon(@NotNull MapControl<G,A,R> mapControl)
Returns an icon
Image for a given map. |
@Nullable java.awt.Image |
getOrCreatePreview(@NotNull java.io.File mapFile)
Returns a preview
Image for a given map file. |
@NotNull java.awt.Image |
getOrCreatePreview(@NotNull MapControl<G,A,R> mapControl)
Returns a preview
Image for a given map. |
@Nullable java.awt.Image |
getPreview(@NotNull java.io.File mapFile)
Returns a preview
Image for a given map file. |
void |
removeMapImageCacheListener(@NotNull MapImageCacheListener<G,A,R> listener)
Removes a
MapControlListener to be notified. |
public MapImageCache(@NotNull
@NotNull MapManager<G,A,R> mapManager,
@NotNull
@NotNull java.awt.Image defaultIcon,
@NotNull
@NotNull java.awt.Image defaultPreview,
@NotNull
@NotNull RendererFactory<G,A,R> rendererFactory,
@NotNull
@NotNull CacheFiles cacheFiles)
mapManager - the map manager for loading mapsdefaultIcon - the default icon to return if no icon can be created
for a mapdefaultPreview - the default preview image to return if no preview
can be created for a maprendererFactory - the renderer factory for creating rendererscacheFiles - the cache files for generating files for cached icons
and previewspublic void flush(@NotNull
@NotNull java.io.File mapFile)
mapFile - the map file to purge@Nullable
public @Nullable java.awt.Image getIcon(@NotNull
@NotNull java.io.File mapFile)
Image for a given map file. If no image is
cached (or if the cached image is outdated), returns null.mapFile - the map filenull@Nullable
public @Nullable java.awt.Image getOrCreateIcon(@NotNull
@NotNull java.io.File mapFile)
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 filenull for directories@NotNull
public @NotNull java.awt.Image getOrCreateIcon(@NotNull
@NotNull MapControl<G,A,R> mapControl)
Image for a given map. If no image is cached (or
if the cached image is outdated), (re-)creates it.mapControl - the map@Nullable
public @Nullable java.awt.Image getPreview(@NotNull
@NotNull java.io.File mapFile)
Image for a given map file. If no image is
cached (or if the cached image is outdated), returns null.mapFile - the map filenull@Nullable
public @Nullable java.awt.Image getOrCreatePreview(@NotNull
@NotNull java.io.File mapFile)
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 filenull for directories@NotNull
public @NotNull java.awt.Image getOrCreatePreview(@NotNull
@NotNull MapControl<G,A,R> mapControl)
Image for a given map. If no image is cached
(or if the cached image is outdated), (re-)creates the image.mapControl - the mappublic void addMapImageCacheListener(@NotNull
@NotNull MapImageCacheListener<G,A,R> listener)
MapImageCacheListener to be notified.listener - the listener to addpublic void removeMapImageCacheListener(@NotNull
@NotNull MapImageCacheListener<G,A,R> listener)
MapControlListener to be notified.listener - the listener to remove