public abstract class AbstractBackgroundImageVisualizer extends java.lang.Object implements BackgroundImageVisualizer
BackgroundImageVisualizer.| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractBackgroundImageVisualizer.ContourInterpolationMode |
protected static class |
AbstractBackgroundImageVisualizer.ContourMode |
class |
AbstractBackgroundImageVisualizer.VisualizationControlPanel
A basic visualisation control panel, providing a JSpinner to control the opacity.
|
| Modifier and Type | Field and Description |
|---|---|
protected static LeastRecentelyUsedImageCache |
cache
The cache of generated images, to allow faster switching between different visualisations and palettes.
|
protected static java.lang.String |
CACHE_KEY_SEPARATOR |
protected AbstractBackgroundImageVisualizer.ContourInterpolationMode |
contourInterpolationMode |
protected AbstractBackgroundImageVisualizer.ContourMode |
contourMode |
protected AbstractBackgroundImageVisualizer.VisualizationControlPanel |
controlPanel
The panel to control the behaviour of the visualisation.
|
int |
currentZDimSlice |
private int |
defaultOpacity |
protected SharedSOMVisualisationData |
inputObjects |
protected java.util.logging.Logger |
log
The standard log for visualisations to write to
|
protected MapPNode |
map |
static long |
MAX_CACHE_SIZE_MB |
protected java.lang.String[] |
neededInputObjects |
protected int |
NUM_VISUALIZATIONS
The number of visualisation variants this visualizer provides
|
protected int |
numberOfContours |
protected int |
opacity
The opacity (transparency) value for this visualisation.
|
protected int |
preferredScaleFactor
Initialised with the default value from
BackgroundImageVisualizer.DEFAULT_BACKGROUND_VISUALIZATION_SCALE. |
protected java.lang.String[] |
VISUALIZATION_DESCRIPTIONS
Longer description for the visualiation variants.
|
protected java.lang.String[] |
VISUALIZATION_NAMES
The names of the visualisation variants.
|
protected java.lang.String[] |
VISUALIZATION_SHORT_NAMES |
protected VisualizationUpdateListener |
visualizationUpdateListener
The listener registered to act on changing visualisation variants or other properties.
|
int |
zSize |
CACHE_KEY_SECTION_SEPARATOR, DEFAULT_BACKGROUND_VISUALIZATION_SCALE| Constructor and Description |
|---|
AbstractBackgroundImageVisualizer()
Initialises the control panel, if
GraphicsEnvironment.isHeadless() reports to be in a non-headless
environment. |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
buildCacheKey(java.lang.Object... parts) |
protected void |
checkNeededObjectsAvailable(GrowingSOM gsom) |
protected void |
checkVariantIndex(int index,
java.lang.Class<?> klass) |
static void |
clearVisualisationCache()
Clears the visualisation cache
|
int |
compareTo(BackgroundImageVisualizer o) |
abstract java.awt.image.BufferedImage |
createVisualization(int variantIndex,
GrowingSOM gsom,
int width,
int height)
Creates a visualisation image.
|
java.awt.image.BufferedImage |
createVisualization(java.lang.String variantName,
GrowingSOM gsom,
int width,
int height)
Creates a visualisation for the given variant name.
|
protected void |
drawBackground(int width,
int height,
java.awt.Graphics2D g)
Draws a background image on the given graphics object, and sets the Composite according to the currentely set
opacity value.
|
static java.lang.String |
escapeFileName(java.lang.String key) |
private java.lang.String |
getBasicCacheKey(GrowingSOM gsom,
int currentVariant,
int width,
int height) |
static LeastRecentelyUsedImageCache |
getCache() |
protected java.lang.String |
getCacheKey(GrowingSOM gsom,
int currentVariant,
int width,
int height)
The key of a cache is created as follows: VisualisationShortName + Hashcode of the SOM + Width + Height +
Opacity.
Sub-classes might add more information to the cache, if needed. |
AbstractBackgroundImageVisualizer.VisualizationControlPanel |
getControlPanel()
Gets the visualisation control panel.
|
java.lang.String |
getDefaultVisualisationFileName(int currentVariant)
Generates the default file name for the current visualisation
|
static java.lang.String |
getDefaultVisualisationFileName(java.lang.String cacheKey) |
java.lang.String |
getHTMLVisualisationControl(java.util.Map params)
Returns HTML control elements (inputs) to be used by the webserver version of the SOM.
|
int |
getNumberOfVisualizations() |
private java.lang.String |
getOpacityCacheKeyComponent() |
int |
getPreferredScaleFactor()
Default implementation returning
preferredScaleFactor. |
protected SOMToolboxException |
getVariantException(int index,
java.lang.Class<?> klass) |
protected java.lang.String |
getVisualisationSpecificCacheKey(int currentVariant) |
java.awt.image.BufferedImage |
getVisualization(int index,
GrowingSOM gsom,
int width,
int height)
Returns the requested visualization image, either by retrieving it from the image cache, or by invoking
createVisualization(int, GrowingSOM, int, int) to create the image new. |
java.lang.String |
getVisualizationDescription(int index)
Gets the descriptions of a specified visualisation variant.
|
java.lang.String[] |
getVisualizationDescriptions()
Gets the descriptions of all visualisation variants provided by this visualiser.
|
java.util.HashMap<java.lang.String,java.awt.image.BufferedImage> |
getVisualizationFlavours(int index,
GrowingSOM gsom,
int width,
int height)
Default implementation which returns a map of size 1 with the standard, unparameterised visualisation of the
given variant.
|
java.util.HashMap<java.lang.String,java.awt.image.BufferedImage> |
getVisualizationFlavours(int index,
GrowingSOM gsom,
int width,
int height,
int maxFlavours)
Default implementation equal to
getVisualizationFlavours(int, GrowingSOM, int, int). |
java.util.HashMap<java.lang.String,java.awt.image.BufferedImage> |
getVisualizationFlavours(int index,
GrowingSOM gsom,
int width,
int height,
java.util.Map<java.lang.String,java.lang.String> flavourParameters)
Default implementation equal to
getVisualizationFlavours(int, GrowingSOM, int, int). |
java.lang.String |
getVisualizationName(int index)
Gets the name of a specified visualisation variant.
|
java.lang.String[] |
getVisualizationNames()
Gets the names of all visualisation variants provided by this visualiser.
|
java.lang.String |
getVisualizationShortName(int index)
Gets the short name of a specified visualisation variant.
|
java.lang.String[] |
getVisualizationShortNames()
Gets the short names of all visualisation variants provided by this visualiser.
|
protected void |
invalidateCache(java.lang.String visualizationName)
Deletes all cached elements from the given visualisation.
|
protected void |
logImageCache(java.lang.String cacheKey) |
java.lang.String[] |
needsAdditionalFiles()
Checks whether this visualisation still needs some input files to generate an image.
|
void |
setInputObjects(SharedSOMVisualisationData inputObjects)
Implementing sub-classes shall override this method if they need to set some specific input object related
information.
|
void |
setMap(MapPNode map)
Sets the map this visualiser operates on.
|
void |
setSOMData(SOMInputReader reader)
Implementing sub-classes shall override this method if they need to set some specific input-data related
information.
|
void |
setVisualizationUpdateListener(VisualizationUpdateListener listener)
Sets a new listener for visualisation update events.
|
protected static final java.lang.String CACHE_KEY_SEPARATOR
public static final long MAX_CACHE_SIZE_MB
protected int NUM_VISUALIZATIONS
protected java.lang.String[] VISUALIZATION_NAMES
protected java.lang.String[] VISUALIZATION_SHORT_NAMES
protected java.lang.String[] VISUALIZATION_DESCRIPTIONS
protected AbstractBackgroundImageVisualizer.VisualizationControlPanel controlPanel
protected static final LeastRecentelyUsedImageCache cache
protected java.util.logging.Logger log
protected VisualizationUpdateListener visualizationUpdateListener
protected SharedSOMVisualisationData inputObjects
protected java.lang.String[] neededInputObjects
protected MapPNode map
private int defaultOpacity
protected int opacity
protected AbstractBackgroundImageVisualizer.ContourMode contourMode
protected int numberOfContours
protected AbstractBackgroundImageVisualizer.ContourInterpolationMode contourInterpolationMode
public int zSize
public int currentZDimSlice
protected int preferredScaleFactor
BackgroundImageVisualizer.DEFAULT_BACKGROUND_VISUALIZATION_SCALE.
Visualisations that need a specific scale shall set this value differently (e.g. in the constructor), or
overwrite getPreferredScaleFactor()public AbstractBackgroundImageVisualizer()
GraphicsEnvironment.isHeadless() reports to be in a non-headless
environment.protected final java.lang.String getCacheKey(GrowingSOM gsom, int currentVariant, int width, int height)
public final java.lang.String getDefaultVisualisationFileName(int currentVariant)
BackgroundImageVisualizergetDefaultVisualisationFileName in interface BackgroundImageVisualizerpublic static final java.lang.String getDefaultVisualisationFileName(java.lang.String cacheKey)
public static java.lang.String escapeFileName(java.lang.String key)
protected java.lang.String getVisualisationSpecificCacheKey(int currentVariant)
private java.lang.String getBasicCacheKey(GrowingSOM gsom, int currentVariant, int width, int height)
private java.lang.String getOpacityCacheKeyComponent()
public java.awt.image.BufferedImage getVisualization(int index,
GrowingSOM gsom,
int width,
int height)
throws SOMToolboxException
createVisualization(int, GrowingSOM, int, int) to create the image new. Subclasses should not overwrite
this method, unless they implement their own caching mechanism, or do not want any caching.getVisualization in interface BackgroundImageVisualizerindex - the index of the variant to usegsom - the GrowingSOM to take build the visualisation forwidth - the desired width of the image, in pixelsheight - the desired height of the image, in pixelsSOMToolboxException - If there was an error creating the visualisationBackgroundImageVisualizer.getVisualization(int,
at.tuwien.ifs.somtoolbox.models.GrowingSOM, int, int)protected void logImageCache(java.lang.String cacheKey)
public static java.lang.String buildCacheKey(java.lang.Object... parts)
protected void invalidateCache(java.lang.String visualizationName)
public abstract java.awt.image.BufferedImage createVisualization(int variantIndex,
GrowingSOM gsom,
int width,
int height)
throws SOMToolboxException
variantIndex - the index of the variant to usegsom - the GrowingSOM to take build the visualisation forwidth - the desired width of the image, in pixelsheight - the desired height of the image, in pixels.SOMToolboxExceptionpublic java.awt.image.BufferedImage createVisualization(java.lang.String variantName,
GrowingSOM gsom,
int width,
int height)
throws SOMToolboxException
createVisualization(int, GrowingSOM, int, int), but throws a SOMToolboxException if the given
variant name is not known in either the VISUALIZATION_NAMES nor VISUALIZATION_SHORT_NAMES.SOMToolboxExceptionpublic int getNumberOfVisualizations()
getNumberOfVisualizations in interface BackgroundImageVisualizerprotected void checkVariantIndex(int index,
java.lang.Class<?> klass)
throws SOMToolboxException
SOMToolboxExceptionprotected SOMToolboxException getVariantException(int index, java.lang.Class<?> klass)
public java.lang.String getVisualizationDescription(int index)
BackgroundImageVisualizergetVisualizationDescription in interface BackgroundImageVisualizerindex - the index of the variant to usepublic java.lang.String[] getVisualizationDescriptions()
BackgroundImageVisualizergetVisualizationDescriptions in interface BackgroundImageVisualizerpublic java.lang.String getVisualizationName(int index)
BackgroundImageVisualizergetVisualizationName in interface BackgroundImageVisualizerindex - the index of the variant to usepublic java.lang.String[] getVisualizationNames()
BackgroundImageVisualizergetVisualizationNames in interface BackgroundImageVisualizerpublic java.lang.String getVisualizationShortName(int index)
BackgroundImageVisualizergetVisualizationShortName in interface BackgroundImageVisualizerindex - the index of the variant to usepublic java.lang.String[] getVisualizationShortNames()
BackgroundImageVisualizergetVisualizationShortNames in interface BackgroundImageVisualizerpublic java.lang.String[] needsAdditionalFiles()
BackgroundImageVisualizerneedsAdditionalFiles in interface BackgroundImageVisualizerprotected void checkNeededObjectsAvailable(GrowingSOM gsom) throws SOMToolboxException
SOMToolboxExceptionpublic AbstractBackgroundImageVisualizer.VisualizationControlPanel getControlPanel()
BackgroundImageVisualizergetControlPanel in interface BackgroundImageVisualizerpublic void setVisualizationUpdateListener(VisualizationUpdateListener listener)
BackgroundImageVisualizersetVisualizationUpdateListener in interface BackgroundImageVisualizerlistener - the new listener to be registeredpublic void setInputObjects(SharedSOMVisualisationData inputObjects)
setInputObjects in interface BackgroundImageVisualizerinputObjects - the new input objectsSOMVisualisationDatapublic void setSOMData(SOMInputReader reader)
setSOMData in interface BackgroundImageVisualizerreader - the som input readerpublic void setMap(MapPNode map)
BackgroundImageVisualizersetMap in interface BackgroundImageVisualizermap - the mapprotected void drawBackground(int width,
int height,
java.awt.Graphics2D g)
width - the desired width of the background image, in pixelsheight - the desired height of the background image, in pixelsg - the graphics to draw on.public java.lang.String getHTMLVisualisationControl(java.util.Map params)
BackgroundImageVisualizergetHTMLVisualisationControl in interface BackgroundImageVisualizerparams - the parameters as passed by the web request - used to select the values in the inputs.public int getPreferredScaleFactor()
preferredScaleFactor. Visualisations that need a specific scale factor
shall set the value of this field differently (e.g. in their constructor), or overwrite this method.getPreferredScaleFactor in interface BackgroundImageVisualizerpublic int compareTo(BackgroundImageVisualizer o)
compareTo in interface java.lang.Comparable<BackgroundImageVisualizer>public java.util.HashMap<java.lang.String,java.awt.image.BufferedImage> getVisualizationFlavours(int index,
GrowingSOM gsom,
int width,
int height)
throws SOMToolboxException
getVisualizationFlavours in interface BackgroundImageVisualizerSOMToolboxExceptionpublic java.util.HashMap<java.lang.String,java.awt.image.BufferedImage> getVisualizationFlavours(int index,
GrowingSOM gsom,
int width,
int height,
int maxFlavours)
throws SOMToolboxException
getVisualizationFlavours(int, GrowingSOM, int, int).getVisualizationFlavours in interface BackgroundImageVisualizerSOMToolboxExceptionpublic java.util.HashMap<java.lang.String,java.awt.image.BufferedImage> getVisualizationFlavours(int index,
GrowingSOM gsom,
int width,
int height,
java.util.Map<java.lang.String,java.lang.String> flavourParameters)
throws SOMToolboxException
getVisualizationFlavours(int, GrowingSOM, int, int).getVisualizationFlavours in interface BackgroundImageVisualizerSOMToolboxExceptionpublic static void clearVisualisationCache()
public static LeastRecentelyUsedImageCache getCache()