at.tuwien.ifs.somtoolbox.visualization
Class AbstractMatrixVisualizer

java.lang.Object
  extended by at.tuwien.ifs.somtoolbox.visualization.AbstractBackgroundImageVisualizer
      extended by at.tuwien.ifs.somtoolbox.visualization.AbstractMatrixVisualizer
All Implemented Interfaces:
BackgroundImageVisualizer, MatrixVisualizer, Comparable<BackgroundImageVisualizer>
Direct Known Subclasses:
AbstractItemVisualizer, AdaptiveCoordinatesVisualizer, ComparisonVisualizer, EntropyVisualizer, HitHistogramVisualizer, QuantizationErrorVisualizer, RegressionVisualiser, RhythmPatternsAttributeVisualizer, SearchResultHistogramVisualizer, SilhouetteVisualizer, SmoothedCountHistograms, SmoothedDataHistograms, UMatrix

public abstract class AbstractMatrixVisualizer
extends AbstractBackgroundImageVisualizer
implements MatrixVisualizer

Version:
$Id: AbstractMatrixVisualizer.java 3883 2010-11-02 17:13:23Z frank $
Author:
Thomas Lidy, Rudolf Mayer

Nested Class Summary
 
Nested classes/interfaces inherited from class at.tuwien.ifs.somtoolbox.visualization.AbstractBackgroundImageVisualizer
AbstractBackgroundImageVisualizer.ContourInterpolationMode, AbstractBackgroundImageVisualizer.ContourMode, AbstractBackgroundImageVisualizer.VisualizationControlPanel
 
Field Summary
protected  double maximumMatrixValue
           
protected  double minimumMatrixValue
           
protected  Palette palette
           
 
Fields inherited from class at.tuwien.ifs.somtoolbox.visualization.AbstractBackgroundImageVisualizer
cache, CACHE_KEY_SECTION_SEPARATOR, CACHE_KEY_SEPARATOR, contourInterpolationMode, contourMode, controlPanel, currentZDimSlice, inputObjects, interpolate, log, map, MAX_CACHE_SIZE_MB, neededInputObjects, NUM_VISUALIZATIONS, numberOfContours, opacity, preferredScaleFactor, VISUALIZATION_DESCRIPTIONS, VISUALIZATION_NAMES, VISUALIZATION_SHORT_NAMES, visualizationUpdateListener, zSize
 
Fields inherited from interface at.tuwien.ifs.somtoolbox.visualization.BackgroundImageVisualizer
DEFAULT_BACKGROUND_VISUALIZATION_SCALE
 
Constructor Summary
AbstractMatrixVisualizer()
           
 
Method Summary
protected  cern.colt.matrix.DoubleMatrix2D computeHitHistogram(GrowingSOM gsom)
          Computes the hit-histogram from the given GrowingSOM.
protected  flanagan.interpolation.BiCubicSplineFast computeSpline(GrowingSOM gsom, cern.colt.matrix.DoubleMatrix2D matrix, int width, int height, int unitWidth, int unitHeight)
           
protected  int constrainWithinPalette(int ci)
           
protected  BufferedImage createImage(GrowingSOM gsom, cern.colt.matrix.DoubleMatrix2D matrix, int width, int height, boolean interpolate)
          Creates an image from a matrix of heights.
protected  void drawContour(Graphics2D g, cern.colt.matrix.DoubleMatrix2D matrix, int width, int height, boolean fill)
           
protected  String getCacheKey(GrowingSOM gsom, int index, 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.
 Palette getCurrentPalette()
          Returns the Palette this visualisation currently is set to.
 double getMaximumMatrixValue()
           
 double getMinimumMatrixValue()
           
 Color[] getPalette()
          Gets the currently used palette.
 String getPreferredPaletteName()
          Default implementation using Palettes.getDefaultPalette().
 BufferedImage getVisualization(int index, GrowingSOM gsom, int width, int height)
          overriding the method in the superclass as we have a different cache key, and to set the min & max matrix values to -1
 void invalidateCache(Palette palette)
          Deletes all cached elements that use the Palette with the given index.
 void reversePalette()
          Reverts the currently used palette.
protected  void setInterpolate(boolean interpolate)
           
 void setPalette(Palette newPalette)
          Sets a new palette.
 
Methods inherited from class at.tuwien.ifs.somtoolbox.visualization.AbstractBackgroundImageVisualizer
appendToCacheKey, buildCacheKey, checkNeededObjectsAvailable, checkVariantIndex, clearVisualisationCache, compareTo, createVisualization, createVisualization, drawBackground, getControlPanel, getHTMLVisualisationControl, getNumberOfVisualizations, getPreferredScaleFactor, getVariantException, getVisualizationDescription, getVisualizationDescriptions, getVisualizationFlavours, getVisualizationFlavours, getVisualizationFlavours, getVisualizationName, getVisualizationNames, getVisualizationShortName, getVisualizationShortNames, invalidateCache, logImageCache, needsAdditionalFiles, setInputObjects, setMap, setSOMData, setVisualizationUpdateListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

palette

protected Palette palette

minimumMatrixValue

protected double minimumMatrixValue

maximumMatrixValue

protected double maximumMatrixValue
Constructor Detail

AbstractMatrixVisualizer

public AbstractMatrixVisualizer()
Method Detail

getMinimumMatrixValue

public double getMinimumMatrixValue()

getMaximumMatrixValue

public double getMaximumMatrixValue()

getVisualization

public BufferedImage getVisualization(int index,
                                      GrowingSOM gsom,
                                      int width,
                                      int height)
                               throws SOMToolboxException
overriding the method in the superclass as we have a different cache key, and to set the min & max matrix values to -1

Specified by:
getVisualization in interface BackgroundImageVisualizer
Overrides:
getVisualization in class AbstractBackgroundImageVisualizer
Parameters:
index - the index of the variant to use
gsom - the GrowingSOM to take build the visualisation for
width - the desired width of the image, in pixels
height - the desired height of the image, in pixels
Returns:
an image for this visualisation
Throws:
SOMToolboxException - If there was an error creating the visualisation
See Also:
BackgroundImageVisualizer.getVisualization(int, at.tuwien.ifs.somtoolbox.models.GrowingSOM, int, int)

getCacheKey

protected String getCacheKey(GrowingSOM gsom,
                             int index,
                             int width,
                             int height)
Description copied from class: AbstractBackgroundImageVisualizer
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.

Overrides:
getCacheKey in class AbstractBackgroundImageVisualizer

setInterpolate

protected void setInterpolate(boolean interpolate)

drawContour

protected void drawContour(Graphics2D g,
                           cern.colt.matrix.DoubleMatrix2D matrix,
                           int width,
                           int height,
                           boolean fill)
                    throws SOMToolboxException
Throws:
SOMToolboxException

createImage

protected BufferedImage createImage(GrowingSOM gsom,
                                    cern.colt.matrix.DoubleMatrix2D matrix,
                                    int width,
                                    int height,
                                    boolean interpolate)
                             throws SOMToolboxException
Creates an image from a matrix of heights.

Parameters:
gsom - The GrowingSOM to generate the image for
matrix - The matrix with the calucalted heights.
width - the desired width of the image, in pixels
height - the desired height of the image, in pixels.
interpolate - indicates whether the image should be interpolated if the widht or height exceeds the matrix dimensions.
Returns:
the BufferedImage for those settings
Throws:
SOMToolboxException

computeSpline

protected flanagan.interpolation.BiCubicSplineFast computeSpline(GrowingSOM gsom,
                                                                 cern.colt.matrix.DoubleMatrix2D matrix,
                                                                 int width,
                                                                 int height,
                                                                 int unitWidth,
                                                                 int unitHeight)

constrainWithinPalette

protected int constrainWithinPalette(int ci)

getPalette

public Color[] getPalette()
Description copied from interface: MatrixVisualizer
Gets the currently used palette.

Specified by:
getPalette in interface MatrixVisualizer
Returns:
the currently used palette

setPalette

public void setPalette(Palette newPalette)
Description copied from interface: MatrixVisualizer
Sets a new palette.

Specified by:
setPalette in interface MatrixVisualizer
Parameters:
newPalette - the new palette

reversePalette

public void reversePalette()
Description copied from interface: MatrixVisualizer
Reverts the currently used palette.

Specified by:
reversePalette in interface MatrixVisualizer

getCurrentPalette

public Palette getCurrentPalette()
Description copied from interface: MatrixVisualizer
Returns the Palette this visualisation currently is set to.

Specified by:
getCurrentPalette in interface MatrixVisualizer

getPreferredPaletteName

public String getPreferredPaletteName()
Default implementation using Palettes.getDefaultPalette(). Subclasses that want to use a different palette should overwrite this method.

Specified by:
getPreferredPaletteName in interface MatrixVisualizer

invalidateCache

public void invalidateCache(Palette palette)
Deletes all cached elements that use the Palette with the given index.


computeHitHistogram

protected cern.colt.matrix.DoubleMatrix2D computeHitHistogram(GrowingSOM gsom)
                                                       throws LayerAccessException
Computes the hit-histogram from the given GrowingSOM. Also sets the values of minimumMatrixValue and maximumMatrixValue

Throws:
LayerAccessException