|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectat.tuwien.ifs.somtoolbox.visualization.AbstractBackgroundImageVisualizer
public abstract class AbstractBackgroundImageVisualizer
This class provides basic support for classes implementing BackgroundImageVisualizer
.
Nested Class Summary | |
---|---|
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. |
Field Summary | |
---|---|
protected static LeastRecentelyUsedImageCache |
cache
The cache of generated images, to allow faster switching between different visualisations and palettes. |
protected static String |
CACHE_KEY_SECTION_SEPARATOR
|
static 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
|
protected SharedSOMVisualisationData |
inputObjects
|
protected boolean |
interpolate
|
protected Logger |
log
The standard log for visualisations to write to |
protected MapPNode |
map
|
static long |
MAX_CACHE_SIZE_MB
|
protected 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 String[] |
VISUALIZATION_DESCRIPTIONS
Longer description for the visualiation variants. |
protected String[] |
VISUALIZATION_NAMES
The names of the visualisation variants. |
protected String[] |
VISUALIZATION_SHORT_NAMES
|
protected VisualizationUpdateListener |
visualizationUpdateListener
The listener registered to act on changing visualisation variants or other properties. |
int |
zSize
|
Fields inherited from interface at.tuwien.ifs.somtoolbox.visualization.BackgroundImageVisualizer |
---|
DEFAULT_BACKGROUND_VISUALIZATION_SCALE |
Constructor Summary | |
---|---|
AbstractBackgroundImageVisualizer()
Initialises the control panel, if GraphicsEnvironment.isHeadless() reports to be in a non-headless
environment. |
Method Summary | |
---|---|
String |
appendToCacheKey(GrowingSOM gsom,
int currentVariant,
int width,
int height,
Object... parts)
|
static String |
buildCacheKey(Object... parts)
|
protected void |
checkNeededObjectsAvailable(GrowingSOM gsom)
|
protected void |
checkVariantIndex(int index,
Class<?> klass)
|
static void |
clearVisualisationCache()
Clears the visualisation cache |
int |
compareTo(BackgroundImageVisualizer o)
|
abstract BufferedImage |
createVisualization(int variantIndex,
GrowingSOM gsom,
int width,
int height)
Creates a visualisation image. |
BufferedImage |
createVisualization(String variantName,
GrowingSOM gsom,
int width,
int height)
Creates a visualisation for the given variant name. |
protected void |
drawBackground(int width,
int height,
Graphics2D g)
Draws a background image on the given graphics object, and sets the Composite according to the currentely set opacity value. |
private String |
getBasicCacheKey(GrowingSOM gsom,
int currentVariant,
int width,
int height)
|
protected 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. |
String |
getHTMLVisualisationControl(Map params)
Returns HTML control elements (inputs) to be used by the webserver version of the SOM. |
int |
getNumberOfVisualizations()
|
int |
getPreferredScaleFactor()
Default implementation returning preferredScaleFactor . |
protected SOMToolboxException |
getVariantException(int index,
Class<?> klass)
|
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. |
String |
getVisualizationDescription(int index)
Gets the descriptions of a specified visualisation variant. |
String[] |
getVisualizationDescriptions()
Gets the descriptions of all visualisation variants provided by this visualiser. |
HashMap<String,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. |
HashMap<String,BufferedImage> |
getVisualizationFlavours(int index,
GrowingSOM gsom,
int width,
int height,
int maxFlavours)
Default implementation equal to getVisualizationFlavours(int, GrowingSOM, int, int) . |
HashMap<String,BufferedImage> |
getVisualizationFlavours(int index,
GrowingSOM gsom,
int width,
int height,
Map<String,String> flavourParameters)
Default implementation equal to getVisualizationFlavours(int, GrowingSOM, int, int) . |
String |
getVisualizationName(int index)
Gets the name of a specified visualisation variant. |
String[] |
getVisualizationNames()
Gets the names of all visualisation variants provided by this visualiser. |
String |
getVisualizationShortName(int index)
Gets the short name of a specified visualisation variant. |
String[] |
getVisualizationShortNames()
Gets the short names of all visualisation variants provided by this visualiser. |
protected void |
invalidateCache(String visualizationName)
Deletes all cached elements from the given visualisation. |
protected void |
logImageCache(String cacheKey)
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String CACHE_KEY_SEPARATOR
public static final long MAX_CACHE_SIZE_MB
protected static final String CACHE_KEY_SECTION_SEPARATOR
protected int NUM_VISUALIZATIONS
protected String[] VISUALIZATION_NAMES
protected String[] VISUALIZATION_SHORT_NAMES
protected String[] VISUALIZATION_DESCRIPTIONS
protected AbstractBackgroundImageVisualizer.VisualizationControlPanel controlPanel
protected static final LeastRecentelyUsedImageCache cache
protected Logger log
protected VisualizationUpdateListener visualizationUpdateListener
protected SharedSOMVisualisationData inputObjects
protected String[] neededInputObjects
protected MapPNode map
protected int opacity
protected boolean interpolate
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()
Constructor Detail |
---|
public AbstractBackgroundImageVisualizer()
GraphicsEnvironment.isHeadless()
reports to be in a non-headless
environment.
Method Detail |
---|
protected String getCacheKey(GrowingSOM gsom, int currentVariant, int width, int height)
private String getBasicCacheKey(GrowingSOM gsom, int currentVariant, int width, int height)
public 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 BackgroundImageVisualizer
index
- 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
SOMToolboxException
- If there was an error creating the visualisationBackgroundImageVisualizer.getVisualization(int,
at.tuwien.ifs.somtoolbox.models.GrowingSOM, int, int)
protected void logImageCache(String cacheKey)
public String appendToCacheKey(GrowingSOM gsom, int currentVariant, int width, int height, Object... parts)
public static String buildCacheKey(Object... parts)
protected void invalidateCache(String visualizationName)
public abstract 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.
SOMToolboxException
public BufferedImage createVisualization(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
.
SOMToolboxException
public int getNumberOfVisualizations()
getNumberOfVisualizations
in interface BackgroundImageVisualizer
protected void checkVariantIndex(int index, Class<?> klass) throws SOMToolboxException
SOMToolboxException
protected SOMToolboxException getVariantException(int index, Class<?> klass)
public String getVisualizationDescription(int index)
BackgroundImageVisualizer
getVisualizationDescription
in interface BackgroundImageVisualizer
index
- the index of the variant to use
public String[] getVisualizationDescriptions()
BackgroundImageVisualizer
getVisualizationDescriptions
in interface BackgroundImageVisualizer
public String getVisualizationName(int index)
BackgroundImageVisualizer
getVisualizationName
in interface BackgroundImageVisualizer
index
- the index of the variant to use
public String[] getVisualizationNames()
BackgroundImageVisualizer
getVisualizationNames
in interface BackgroundImageVisualizer
public String getVisualizationShortName(int index)
BackgroundImageVisualizer
getVisualizationShortName
in interface BackgroundImageVisualizer
index
- the index of the variant to use
public String[] getVisualizationShortNames()
BackgroundImageVisualizer
getVisualizationShortNames
in interface BackgroundImageVisualizer
public String[] needsAdditionalFiles()
BackgroundImageVisualizer
needsAdditionalFiles
in interface BackgroundImageVisualizer
protected void checkNeededObjectsAvailable(GrowingSOM gsom) throws SOMToolboxException
SOMToolboxException
public AbstractBackgroundImageVisualizer.VisualizationControlPanel getControlPanel()
BackgroundImageVisualizer
getControlPanel
in interface BackgroundImageVisualizer
public void setVisualizationUpdateListener(VisualizationUpdateListener listener)
BackgroundImageVisualizer
setVisualizationUpdateListener
in interface BackgroundImageVisualizer
listener
- the new listener to be registeredpublic void setInputObjects(SharedSOMVisualisationData inputObjects)
setInputObjects
in interface BackgroundImageVisualizer
inputObjects
- the new input objectsSOMVisualisationData
public void setSOMData(SOMInputReader reader)
setSOMData
in interface BackgroundImageVisualizer
reader
- the som input readerpublic void setMap(MapPNode map)
BackgroundImageVisualizer
setMap
in interface BackgroundImageVisualizer
map
- the mapprotected void drawBackground(int width, int height, 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 String getHTMLVisualisationControl(Map params)
BackgroundImageVisualizer
getHTMLVisualisationControl
in interface BackgroundImageVisualizer
params
- 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 BackgroundImageVisualizer
public int compareTo(BackgroundImageVisualizer o)
compareTo
in interface Comparable<BackgroundImageVisualizer>
public HashMap<String,BufferedImage> getVisualizationFlavours(int index, GrowingSOM gsom, int width, int height) throws SOMToolboxException
getVisualizationFlavours
in interface BackgroundImageVisualizer
SOMToolboxException
public HashMap<String,BufferedImage> getVisualizationFlavours(int index, GrowingSOM gsom, int width, int height, int maxFlavours) throws SOMToolboxException
getVisualizationFlavours(int, GrowingSOM, int, int)
.
getVisualizationFlavours
in interface BackgroundImageVisualizer
SOMToolboxException
public HashMap<String,BufferedImage> getVisualizationFlavours(int index, GrowingSOM gsom, int width, int height, Map<String,String> flavourParameters) throws SOMToolboxException
getVisualizationFlavours(int, GrowingSOM, int, int)
.
getVisualizationFlavours
in interface BackgroundImageVisualizer
SOMToolboxException
public static void clearVisualisationCache()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |