at.tuwien.ifs.somtoolbox.apps.viewer
Class MapPNode

java.lang.Object
  extended by edu.umd.cs.piccolo.PNode
      extended by at.tuwien.ifs.somtoolbox.apps.viewer.MapPNode
All Implemented Interfaces:
Printable, Serializable, Cloneable

public class MapPNode
extends edu.umd.cs.piccolo.PNode

The graphical representation of a map in the SOMViewer application. This class makes use of the Piccolo framework and is the top PNode for all map-level visualisations. The class holds several other PNodes as children:

Version:
$Id: MapPNode.java 3939 2010-11-17 16:06:14Z frank $
Author:
Michael Dittenbach
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class edu.umd.cs.piccolo.PNode
edu.umd.cs.piccolo.PNode.PSceneGraphDelegate
 
Field Summary
private  edu.umd.cs.piccolo.nodes.PImage backgroundImage
           
private  boolean backgroundImageVisible
           
private  SOMLibClassInformation classInfo
           
private  TreeBuilder clusteringTreeBuilder
           
private  SortedMap<Integer,ClusterElementsStorage> currentClusteringElements
           
private  ClusteringTree currentClusteringTree
           
private  BackgroundImageVisualizer currentVisualization
           
protected  edu.umd.cs.piccolo.nodes.PImage currentVisualizationImage
           
private  int currentVisualizationVariant
           
private  SOMLibDataInformation dataInfo
           
static Font DEFAULT_TOOLTIP_FONT
           
static Font DEFAULT_TOOLTIP_FONT_UNITINFO
           
static int DEFAULT_UNIT_HEIGHT
           
static int DEFAULT_UNIT_WIDTH
           
private  GrowingSOM gsom
           
private  edu.umd.cs.piccolo.PNode inputCorrectionsPNode
           
private  edu.umd.cs.piccolo.nodes.PPath inputLinkagePath
           
private  SharedSOMVisualisationData inputObjects
           
private  edu.umd.cs.piccolo.PNode manualLabels
           
private  BufferedImage originalBackgroundImage
           
private  AbstractMatrixVisualizer overlayVis
           
private  int overlayVis_index
           
private  edu.umd.cs.piccolo.nodes.PImage overlayVisualizationImage
           
private  JFrame parentFrame
           
private static long serialVersionUID
           
private  CommonSOMViewerStateData state
           
private  int UNIT_HEIGHT
           
private  int UNIT_WIDTH
           
private  GeneralUnitPNode[][] units
           
private  edu.umd.cs.piccolo.PNode unitsNode
           
private  BackgroundImageVisualizer[] visualizations
          Deprecated. use Visualizations instead
 
Fields inherited from class edu.umd.cs.piccolo.PNode
PROPERTY_BOUNDS, PROPERTY_CHILDREN, PROPERTY_CHILDREN_PICKABLE, PROPERTY_CLIENT_PROPERTIES, PROPERTY_CODE_BOUNDS, PROPERTY_CODE_CHILDREN, PROPERTY_CODE_CHILDREN_PICKABLE, PROPERTY_CODE_CLIENT_PROPERTIES, PROPERTY_CODE_FULL_BOUNDS, PROPERTY_CODE_PAINT, PROPERTY_CODE_PARENT, PROPERTY_CODE_PICKABLE, PROPERTY_CODE_TRANSFORM, PROPERTY_CODE_TRANSPARENCY, PROPERTY_CODE_VISIBLE, PROPERTY_FULL_BOUNDS, PROPERTY_PAINT, PROPERTY_PARENT, PROPERTY_PICKABLE, PROPERTY_TRANSFORM, PROPERTY_TRANSPARENCY, PROPERTY_VISIBLE, SCENE_GRAPH_DELEGATE
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
MapPNode(JFrame parentFrame, GrowingSOM gsom, GrowingLayer growingLayer, CommonSOMViewerStateData state)
          Constructor for a already loaded GrowingLayer - can be used for visualize sublayers of a ghsom!
MapPNode(JFrame parentFrame, SOMLibFormatInputReader inputReader, CommonSOMViewerStateData state, boolean inizializeVis)
          Constructor if input files have already been read.
MapPNode(JFrame parentFrame, String weightVectorFileName, String unitDescriptionFileName, String mapDescriptionFileName, CommonSOMViewerStateData state)
          Default constructors - reading of input files not yet done.
 
Method Summary
 void buildTree(ClusteringTree tree)
          Rebuilds a clustering from the given tree.
 void buildTree(TreeBuilder builder)
          Creates new TreeBuilder.
 boolean changePalette(Palette palette)
           
 void clearHistogramOverlayVisualization()
          Removes temporary histogram based visualization
 void clearInputCorrections()
           
 void clearInputCorrections(InputCorrections.CreationType type)
           
 void createInputCorrectionArrows()
           
 void createLabel()
          Adds a manual label to the map.
 ArrayList<edu.umd.cs.piccolo.PNode> getAllClusterLabels()
           
 BufferedImage getBackgroundImage()
           
private  int getBackgroundImageHeight()
           
private  int getBackgroundImageWidth()
           
 Color[] getClassLegendColors()
           
 String[] getClassLegendNames()
           
 ClusteringTree getClusteringTree()
           
 TreeBuilder getClusteringTreeBuilder()
           
 ArrayList<edu.umd.cs.piccolo.PNode>[] getClusterLabelsByLevel()
           
 ClusteringTree getCurrentClusteringTree()
           
 BackgroundImageVisualizer getCurrentVisualization()
           
 GeneralUnitPNode getGeneralUnitPNodeAtPos(double x, double y)
           
 GeneralUnitPNode getGeneralUnitPNodeAtPos(float x, float y)
           
 GeneralUnitPNode getGeneralUnitPNodeAtPos(Point2D p)
           
 GrowingSOM getGsom()
           
 double getHeight()
          Return the map height in pixels, i.e.
 edu.umd.cs.piccolo.PNode getInputCorrectionsPNode()
           
 SharedSOMVisualisationData getInputObjects()
           
 edu.umd.cs.piccolo.PNode getManualLabels()
           
 JFrame getParentFrame()
           
private  Point getPointLocation(String name)
          Calculates the absolute position of an input on the MapPNode.
private  int getScaledBackgroundImageHeight()
           
private  int getScaledBackgroundImageHeight(BackgroundImageVisualizer visualization)
           
private  int getScaledBackgroundImageWidth()
           
private  int getScaledBackgroundImageWidth(BackgroundImageVisualizer visualization)
           
 Point[] getStarCoords(Unit unit, int unitSize)
           
 CommonSOMViewerStateData getState()
           
 ThematicClassMapVisualizer getThematicClassMapVisualizer()
          Deprecated. use Visualizations instead
 GeneralUnitPNode getUnit(int x, int y)
          Return the GeneralUnitPNode at the unit index x/y.
 GeneralUnitPNode getUnit(Unit u)
          Return the GeneralUnitPNode at the unit index x/y.
 int getUnitHeight()
          Return the unit height in pixels.
 edu.umd.cs.piccolo.PNode getUnitsNode()
           
 int getUnitWidth()
          Return the unit width in pixles.
private  BufferedImage getVisualisation()
          Gets the visualisation variant from the current currentVisualization obtaining the values from currentVisualizationVariant, getScaledBackgroundImageWidth() and getScaledBackgroundImageHeight().
 BackgroundImageVisualizer[] getVisualizations()
          Deprecated. use Visualizations.singleton instead
 double getWidth()
          Return the map width in pixels, i.e.
private  void init(JFrame parentFrame, SOMLibFormatInputReader inputReader, CommonSOMViewerStateData state, GrowingLayer growingLayer, boolean inizializeVis)
           
private  void initCurrentVisualisation()
           
private  Point[][] initInputLocations(Unit unit)
          Computes the locations of each input vector within a specific unit
 boolean isBackgroundImageVisible()
           
 void reInitLabels()
           
 void reInitUnitDetails()
           
 void reInitUnitPNodes(int detailLevel)
           
 boolean reloadPaletteAfterEditing(Palette palette)
          Reloads the given palette after it has been edited with the PaletteEditor, i.e.
 void resetArrows()
          Resets the list of arrows originating from a unit for each unit on the map.
 boolean reversePalette()
           
 void setBackgroundImage(BufferedImage background)
           
 void setBackgroundImageVisibility(boolean visible)
           
 boolean setBounds(double x, double y, double width, double height)
           
 void setClassColor(int index, Color color)
           
 void setClassColors(Color[] colors)
           
 void setClusteringElements(SortedMap<Integer,ClusterElementsStorage> elements)
          Replaces currentClusteringElements with elements and makes sure the correct stuff is displayed.
 boolean setInitialVisualizationOnStartup(BackgroundImageVisualizer vis, int variant)
          Method to be used for setting the initial visualisation on startup - does not actually create the image, just sets the currentVisualization and currentVisualizationVariant.
 void setInputCorrectionsVisible(boolean visible)
           
 void setLinkageVisibilityMode(boolean visible)
           
 void setNoVisualization()
           
 void setShowOnlySelectedClasses(boolean selectedClassesOnly)
           
 boolean setVisualization(BackgroundImageVisualizer vis, int variant)
           
 boolean setVisualization(int vis, int variant)
           
 void showClusters(int count)
          Display the specified number of clusters
 void showClusters(int count, boolean sticky)
          Display the specified number of Clusters.
 void showHistogramOverlayVisualization(int[][] hist, int vis_index)
          Creates a histogram based visualization, which is *temporarily* placed over the current visualization
 void updateClassInfo(SOMLibClassInformation classInfo)
           
 void updateClassSelection(int[] indices)
           
 void updateClassVisibility()
           
 void updateDetailsAfterMoving()
           
 void updatePointLocations()
           
 void updateVisualization()
           
 
Methods inherited from class edu.umd.cs.piccolo.PNode
addActivity, addAttribute, addChild, addChild, addChildren, addClientProperty, addInputEventListener, addPropertyChangeListener, addPropertyChangeListener, animateToBounds, animateToColor, animateToPositionScaleRotation, animateToTransform, animateToTransparency, animateTransformToBounds, centerBoundsOnPoint, centerFullBoundsOnPoint, clone, computeFullBounds, endResizeBounds, findIntersectingNodes, fireChildPropertyChange, firePropertyChange, fullIntersects, fullPaint, fullPick, getAllNodes, getAllNodes, getAttribute, getAttribute, getBooleanAttribute, getBounds, getBoundsChanged, getBoundsReference, getBoundsVolatile, getChild, getChildBoundsInvalid, getChildBoundsVolatile, getChildPaintInvalid, getChildrenCount, getChildrenIterator, getChildrenPickable, getChildrenReference, getClientProperties, getClientProperty, getClientPropertyKeysEnumeration, getClientPropertyKeysIterator, getDoubleAttribute, getFullBounds, getFullBoundsInvalid, getFullBoundsReference, getGlobalBounds, getGlobalFullBounds, getGlobalRotation, getGlobalScale, getGlobalToLocalTransform, getGlobalTranslation, getIntegerAttribute, getInverseTransform, getListenerList, getLocalToGlobalTransform, getOccluded, getOffset, getPaint, getPaintInvalid, getParent, getPickable, getPropertyChangeParentMask, getRoot, getRotation, getScale, getTransform, getTransformReference, getTransparency, getUnionOfChildrenBounds, getVisible, getX, getXOffset, getY, getYOffset, globalToLocal, globalToLocal, globalToLocal, indexOfChild, internalUpdateBounds, intersects, invalidateFullBounds, invalidateLayout, invalidatePaint, isAncestorOf, isDescendentOf, isDescendentOfRoot, isOpaque, layoutChildren, lerp, localToGlobal, localToGlobal, localToGlobal, localToParent, localToParent, localToParent, moveInBackOf, moveInFrontOf, moveToBack, moveToFront, offset, paint, paintAfterChildren, paramString, parentBoundsChanged, parentToLocal, parentToLocal, parentToLocal, pick, pickAfterChildren, position, print, print, removeAllChildren, removeChild, removeChild, removeChildren, removeFromParent, removeInputEventListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaintFrom, reparent, replaceWith, resetBounds, rotate, rotateAboutPoint, rotateAboutPoint, rotateInPlace, scale, scaleAboutPoint, scaleAboutPoint, setBounds, setBoundsChanged, setChildBoundsInvalid, setChildBoundsVolatile, setChildPaintInvalid, setChildrenPickable, setFullBoundsInvalid, setGlobalRotation, setGlobalScale, setGlobalTranslation, setHeight, setOccluded, setOffset, setOffset, setPaint, setPaintInvalid, setParent, setPickable, setPropertyChangeParentMask, setRotation, setScale, setTransform, setTransparency, setVisible, setWidth, setX, setY, signalBoundsChanged, startResizeBounds, toImage, toImage, toImage, toString, transformBy, translate, validateFullBounds, validateFullPaint
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

DEFAULT_UNIT_HEIGHT

public static final int DEFAULT_UNIT_HEIGHT
See Also:
Constant Field Values

DEFAULT_UNIT_WIDTH

public static final int DEFAULT_UNIT_WIDTH
See Also:
Constant Field Values

DEFAULT_TOOLTIP_FONT

public static final Font DEFAULT_TOOLTIP_FONT

DEFAULT_TOOLTIP_FONT_UNITINFO

public static final Font DEFAULT_TOOLTIP_FONT_UNITINFO

gsom

private GrowingSOM gsom

classInfo

private SOMLibClassInformation classInfo

dataInfo

private SOMLibDataInformation dataInfo

units

private GeneralUnitPNode[][] units

UNIT_WIDTH

private int UNIT_WIDTH

UNIT_HEIGHT

private int UNIT_HEIGHT

visualizations

@Deprecated
private BackgroundImageVisualizer[] visualizations
Deprecated. use Visualizations instead

currentVisualization

private BackgroundImageVisualizer currentVisualization

currentVisualizationVariant

private int currentVisualizationVariant

backgroundImage

private edu.umd.cs.piccolo.nodes.PImage backgroundImage

currentVisualizationImage

protected edu.umd.cs.piccolo.nodes.PImage currentVisualizationImage

overlayVis

private AbstractMatrixVisualizer overlayVis

overlayVis_index

private int overlayVis_index

overlayVisualizationImage

private edu.umd.cs.piccolo.nodes.PImage overlayVisualizationImage

currentClusteringElements

private SortedMap<Integer,ClusterElementsStorage> currentClusteringElements

currentClusteringTree

private ClusteringTree currentClusteringTree

manualLabels

private edu.umd.cs.piccolo.PNode manualLabels

unitsNode

private edu.umd.cs.piccolo.PNode unitsNode

inputCorrectionsPNode

private edu.umd.cs.piccolo.PNode inputCorrectionsPNode

inputObjects

private SharedSOMVisualisationData inputObjects

parentFrame

private JFrame parentFrame

state

private CommonSOMViewerStateData state

originalBackgroundImage

private BufferedImage originalBackgroundImage

backgroundImageVisible

private boolean backgroundImageVisible

inputLinkagePath

private edu.umd.cs.piccolo.nodes.PPath inputLinkagePath

clusteringTreeBuilder

private TreeBuilder clusteringTreeBuilder
Constructor Detail

MapPNode

public MapPNode(JFrame parentFrame,
                String weightVectorFileName,
                String unitDescriptionFileName,
                String mapDescriptionFileName,
                CommonSOMViewerStateData state)
         throws FileNotFoundException,
                SOMLibFileFormatException
Default constructors - reading of input files not yet done.

Throws:
FileNotFoundException
SOMLibFileFormatException

MapPNode

public MapPNode(JFrame parentFrame,
                SOMLibFormatInputReader inputReader,
                CommonSOMViewerStateData state,
                boolean inizializeVis)
Constructor if input files have already been read.


MapPNode

public MapPNode(JFrame parentFrame,
                GrowingSOM gsom,
                GrowingLayer growingLayer,
                CommonSOMViewerStateData state)
Constructor for a already loaded GrowingLayer - can be used for visualize sublayers of a ghsom!

Parameters:
parentFrame - The frame containing the MapPNode
gsom - The SOM containing the growing layer
growingLayer - The layer for which the MapPNode is generated
state - The state of the SOMViewer
Method Detail

init

private void init(JFrame parentFrame,
                  SOMLibFormatInputReader inputReader,
                  CommonSOMViewerStateData state,
                  GrowingLayer growingLayer,
                  boolean inizializeVis)

createInputCorrectionArrows

public void createInputCorrectionArrows()

updateDetailsAfterMoving

public void updateDetailsAfterMoving()

getPointLocation

private Point getPointLocation(String name)
Calculates the absolute position of an input on the MapPNode.


getStarCoords

public Point[] getStarCoords(Unit unit,
                             int unitSize)

initInputLocations

private Point[][] initInputLocations(Unit unit)
Computes the locations of each input vector within a specific unit


getVisualizations

@Deprecated
public BackgroundImageVisualizer[] getVisualizations()
Deprecated. use Visualizations.singleton instead


getThematicClassMapVisualizer

@Deprecated
public ThematicClassMapVisualizer getThematicClassMapVisualizer()
Deprecated. use Visualizations instead


getCurrentVisualization

public BackgroundImageVisualizer getCurrentVisualization()

setNoVisualization

public void setNoVisualization()

updateVisualization

public void updateVisualization()

initCurrentVisualisation

private void initCurrentVisualisation()

showHistogramOverlayVisualization

public void showHistogramOverlayVisualization(int[][] hist,
                                              int vis_index)
Creates a histogram based visualization, which is *temporarily* placed over the current visualization

Parameters:
hist - int[][] with histogram data, e.g. unit counts
vis_index - visualization variant index (0 = flat, 1 = smoothed)

clearHistogramOverlayVisualization

public void clearHistogramOverlayVisualization()
Removes temporary histogram based visualization


reversePalette

public boolean reversePalette()
                       throws SOMToolboxException
Throws:
SOMToolboxException

reloadPaletteAfterEditing

public boolean reloadPaletteAfterEditing(Palette palette)
                                  throws SOMToolboxException
Reloads the given palette after it has been edited with the PaletteEditor, i.e. basically invalidates the cache for all visualisations and then calls changePalette(Palette)

Throws:
SOMToolboxException

changePalette

public boolean changePalette(Palette palette)
                      throws SOMToolboxException
Throws:
SOMToolboxException

showClusters

public void showClusters(int count)
Display the specified number of clusters


showClusters

public void showClusters(int count,
                         boolean sticky)
Display the specified number of Clusters.

Parameters:
sticky - should this level ov clustering stay visible when other levels of clustering are displayed.

buildTree

public void buildTree(TreeBuilder builder)
               throws ClusteringAbortedException
Creates new TreeBuilder. if the builder is null, the current clustering is removed.

Throws:
ClusteringAbortedException

buildTree

public void buildTree(ClusteringTree tree)
Rebuilds a clustering from the given tree. Used for deserialization.


getCurrentClusteringTree

public ClusteringTree getCurrentClusteringTree()

setClusteringElements

public void setClusteringElements(SortedMap<Integer,ClusterElementsStorage> elements)
Replaces currentClusteringElements with elements and makes sure the correct stuff is displayed. Also accepts null -> just removes.


createLabel

public void createLabel()
Adds a manual label to the map. Pops up a Dialog asking for the text. The created label has the size 10x number of units in width.


getManualLabels

public edu.umd.cs.piccolo.PNode getManualLabels()

getAllClusterLabels

public ArrayList<edu.umd.cs.piccolo.PNode> getAllClusterLabels()

getClusterLabelsByLevel

public ArrayList<edu.umd.cs.piccolo.PNode>[] getClusterLabelsByLevel()

getClusteringTree

public ClusteringTree getClusteringTree()

getScaledBackgroundImageWidth

private int getScaledBackgroundImageWidth()

getScaledBackgroundImageWidth

private int getScaledBackgroundImageWidth(BackgroundImageVisualizer visualization)

getScaledBackgroundImageHeight

private int getScaledBackgroundImageHeight()

getScaledBackgroundImageHeight

private int getScaledBackgroundImageHeight(BackgroundImageVisualizer visualization)

getBackgroundImageWidth

private int getBackgroundImageWidth()

getBackgroundImageHeight

private int getBackgroundImageHeight()

setVisualization

public boolean setVisualization(int vis,
                                int variant)
                         throws SOMToolboxException
Throws:
SOMToolboxException

setInitialVisualizationOnStartup

public boolean setInitialVisualizationOnStartup(BackgroundImageVisualizer vis,
                                                int variant)
                                         throws SOMToolboxException
Method to be used for setting the initial visualisation on startup - does not actually create the image, just sets the currentVisualization and currentVisualizationVariant.

Throws:
SOMToolboxException

getVisualisation

private BufferedImage getVisualisation()
                                throws SOMToolboxException
Gets the visualisation variant from the current currentVisualization obtaining the values from currentVisualizationVariant, getScaledBackgroundImageWidth() and getScaledBackgroundImageHeight().

Throws:
SOMToolboxException

setVisualization

public boolean setVisualization(BackgroundImageVisualizer vis,
                                int variant)
                         throws SOMToolboxException
Throws:
SOMToolboxException

getUnit

public GeneralUnitPNode getUnit(int x,
                                int y)
Return the GeneralUnitPNode at the unit index x/y.


getUnit

public GeneralUnitPNode getUnit(Unit u)
Return the GeneralUnitPNode at the unit index x/y.


getUnitWidth

public int getUnitWidth()
Return the unit width in pixles.


getUnitHeight

public int getUnitHeight()
Return the unit height in pixels.


getWidth

public double getWidth()
Return the map width in pixels, i.e. the unit width times the xSize of the map.

Overrides:
getWidth in class edu.umd.cs.piccolo.PNode

getHeight

public double getHeight()
Return the map height in pixels, i.e. the height width times the ySize of the map.

Overrides:
getHeight in class edu.umd.cs.piccolo.PNode

setBounds

public boolean setBounds(double x,
                         double y,
                         double width,
                         double height)
Overrides:
setBounds in class edu.umd.cs.piccolo.PNode

setLinkageVisibilityMode

public void setLinkageVisibilityMode(boolean visible)

reInitUnitDetails

public void reInitUnitDetails()

getClassLegendColors

public Color[] getClassLegendColors()

setClassColor

public void setClassColor(int index,
                          Color color)

setClassColors

public void setClassColors(Color[] colors)

getClassLegendNames

public String[] getClassLegendNames()

setShowOnlySelectedClasses

public void setShowOnlySelectedClasses(boolean selectedClassesOnly)

updateClassSelection

public void updateClassSelection(int[] indices)

updatePointLocations

public void updatePointLocations()

getInputObjects

public SharedSOMVisualisationData getInputObjects()

updateClassInfo

public void updateClassInfo(SOMLibClassInformation classInfo)

updateClassVisibility

public void updateClassVisibility()

getGsom

public GrowingSOM getGsom()

setBackgroundImage

public void setBackgroundImage(BufferedImage background)

setBackgroundImageVisibility

public void setBackgroundImageVisibility(boolean visible)

reInitLabels

public void reInitLabels()

getBackgroundImage

public BufferedImage getBackgroundImage()

isBackgroundImageVisible

public boolean isBackgroundImageVisible()

getState

public CommonSOMViewerStateData getState()

getParentFrame

public JFrame getParentFrame()

resetArrows

public void resetArrows()
Resets the list of arrows originating from a unit for each unit on the map.


reInitUnitPNodes

public void reInitUnitPNodes(int detailLevel)

getInputCorrectionsPNode

public edu.umd.cs.piccolo.PNode getInputCorrectionsPNode()

setInputCorrectionsVisible

public void setInputCorrectionsVisible(boolean visible)

clearInputCorrections

public void clearInputCorrections()

clearInputCorrections

public void clearInputCorrections(InputCorrections.CreationType type)

getClusteringTreeBuilder

public TreeBuilder getClusteringTreeBuilder()
Returns:
Returns the builder.

getGeneralUnitPNodeAtPos

public GeneralUnitPNode getGeneralUnitPNodeAtPos(Point2D p)

getGeneralUnitPNodeAtPos

public GeneralUnitPNode getGeneralUnitPNodeAtPos(double x,
                                                 double y)

getGeneralUnitPNodeAtPos

public GeneralUnitPNode getGeneralUnitPNodeAtPos(float x,
                                                 float y)

getUnitsNode

public edu.umd.cs.piccolo.PNode getUnitsNode()