at.tuwien.ifs.somtoolbox.visualization.clustering
Class ClusteringTree

java.lang.Object
  extended by edu.umd.cs.piccolo.PNode
      extended by at.tuwien.ifs.somtoolbox.visualization.clustering.ClusteringTree
All Implemented Interfaces:
Printable, Serializable, Cloneable

public class ClusteringTree
extends edu.umd.cs.piccolo.PNode
implements Serializable

Class for storing the clustering.

Version:
$Id: ClusteringTree.java 3938 2010-11-17 15:15:25Z mayer $
Author:
Angela Roiger
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  SortedMap<Integer,ClusterElementsStorage> allClusteringElements
          contains all currently shown clustering layers
static Font defaultFont
           
static float INITIAL_BORDER_WIDTH_MAGNIFICATION_FACTOR
           
private static EditLabelEventListener labelListener
           
private static long serialVersionUID
           
private  int startFontSize
           
private  ClusterNode topNode
           
private  int width
           
 
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
ClusteringTree(ClusterNode top, int width)
          Initializes the tree with the given top Node.
 
Method Summary
 void addEditLabelEventListenerToAll()
          Adds the EditLabelEventLister to all Labels.
private  void clearClusteringElements()
          Create a new allClusteringElements containing only the sticky layers from the previous version.
 void dumpAllClusteringElements()
          give some advanced debug output
 ClusterNode findClusterOf(GeneralUnitPNode unitPNode, int level)
          Find the ClusterNode that contains the given GeneralUnitPNode at the given level.
 ClusterNode findNode(ClusterNode start, int lvl)
           
 ClusterNode findNode(int lvl)
           
private  void getAllChildrenUntil(int level, ClusterNode start, ArrayList<ClusterNode> store)
          Searches the clusters that are less or equal lvl and stores their children (ClusterNodes) which are > lvl.
 SortedMap<Integer,ClusterElementsStorage> getAllClusteringElements()
           
 int[][] getClusterAssignment(int level, int xSize, int ySize)
           
 SortedMap<Integer,ClusterElementsStorage> getClusteringInto(int l)
          Returns the borders and the Labels of the clustering into l clusters and all other currently painted cluster's borders and labels
 SortedMap<Integer,ClusterElementsStorage> getClusteringInto(int l, boolean sticky)
          Recreates the ClusterElementsStorageNode for layer l.
 ArrayList<ClusterNode> getNodesAtLevel(int level)
           
 Color[] getPalette()
          Gest the current palette from the state.
 void printTree(ClusterNode start, int x)
           
 void recolorTree()
          Changes the colors of the tree according to the currently chosen palette.
private  void recolorTree(Color[] col, ClusterNode n)
          Function for recursion in recolorTree()
private  void resizeLabelsAndBorders(float borderWidthFactor)
          Resizes all labels so that labels of a lower layer are 1/3 smaller than the one above.
private  void resizeLabelsAndBorders(TreeSet<Integer> ts, int fontSize, float borderWidth)
           
 
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, getHeight, getIntegerAttribute, getInverseTransform, getListenerList, getLocalToGlobalTransform, getOccluded, getOffset, getPaint, getPaintInvalid, getParent, getPickable, getPropertyChangeParentMask, getRoot, getRotation, getScale, getTransform, getTransformReference, getTransparency, getUnionOfChildrenBounds, getVisible, getWidth, 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, 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

INITIAL_BORDER_WIDTH_MAGNIFICATION_FACTOR

public static final float INITIAL_BORDER_WIDTH_MAGNIFICATION_FACTOR
See Also:
Constant Field Values

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

topNode

private ClusterNode topNode

allClusteringElements

private SortedMap<Integer,ClusterElementsStorage> allClusteringElements
contains all currently shown clustering layers


labelListener

private static final EditLabelEventListener labelListener

startFontSize

private int startFontSize

width

private int width

defaultFont

public static final Font defaultFont
Constructor Detail

ClusteringTree

ClusteringTree(ClusterNode top,
               int width)
Initializes the tree with the given top Node.

Parameters:
top - the top Cluster
width - the width of the map in Units. The width is needed for initializing the Font size.
Method Detail

findNode

public ClusterNode findNode(int lvl)

findNode

public ClusterNode findNode(ClusterNode start,
                            int lvl)
Returns:
null if node could not be found

getClusteringInto

public SortedMap<Integer,ClusterElementsStorage> getClusteringInto(int l)
Returns the borders and the Labels of the clustering into l clusters and all other currently painted cluster's borders and labels

Parameters:
l - the number of clusters
Returns:
a PNode containing all borders and Labels as children

clearClusteringElements

private void clearClusteringElements()
Create a new allClusteringElements containing only the sticky layers from the previous version.


getClusteringInto

public SortedMap<Integer,ClusterElementsStorage> getClusteringInto(int l,
                                                                   boolean sticky)
Recreates the ClusterElementsStorageNode for layer l. Replaces allClusteringElements with a new HashMap containing all sticky layers from the previous version and the newly created layer l.

Parameters:
l - the number of clusters
sticky - should this clustering stay visible
Returns:
the updated allClusteringElements

dumpAllClusteringElements

public void dumpAllClusteringElements()
give some advanced debug output


resizeLabelsAndBorders

private void resizeLabelsAndBorders(TreeSet<Integer> ts,
                                    int fontSize,
                                    float borderWidth)

resizeLabelsAndBorders

private void resizeLabelsAndBorders(float borderWidthFactor)
Resizes all labels so that labels of a lower layer are 1/3 smaller than the one above. The maximum font size/border width is set by the constructor.


getAllClusteringElements

public SortedMap<Integer,ClusterElementsStorage> getAllClusteringElements()

getAllChildrenUntil

private void getAllChildrenUntil(int level,
                                 ClusterNode start,
                                 ArrayList<ClusterNode> store)
Searches the clusters that are less or equal lvl and stores their children (ClusterNodes) which are > lvl. Used to get a clustering into lvl+1 clusters.

Parameters:
level - the level.
start - the top ClusterNode
store - a ArrayList to store the results

findClusterOf

public ClusterNode findClusterOf(GeneralUnitPNode unitPNode,
                                 int level)
Find the ClusterNode that contains the given GeneralUnitPNode at the given level.


printTree

public void printTree(ClusterNode start,
                      int x)

addEditLabelEventListenerToAll

public void addEditLabelEventListenerToAll()
Adds the EditLabelEventLister to all Labels. Used after deserialization.


recolorTree

public void recolorTree()
Changes the colors of the tree according to the currently chosen palette. In each step the palette is split in 2 halves and each child cluster gets one half. The color of a cluster shown on the screen is the color "in the middle" of its palette. This means in the worst case there are 2^n colors needed to paint n clusters, but this also means that close clusters will have more similar colors than outliers.


recolorTree

private void recolorTree(Color[] col,
                         ClusterNode n)
Function for recursion in recolorTree()

Parameters:
col - Color[] contaning the Palette

getPalette

public Color[] getPalette()
Gest the current palette from the state.

Returns:
the curren palette.

getClusterAssignment

public int[][] getClusterAssignment(int level,
                                    int xSize,
                                    int ySize)

getNodesAtLevel

public ArrayList<ClusterNode> getNodesAtLevel(int level)