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

java.lang.Object
  extended by at.tuwien.ifs.somtoolbox.visualization.clustering.ClusterNode
All Implemented Interfaces:
Serializable

public class ClusterNode
extends Object
implements Serializable

Class containing one node in the cluster tree.

Version:
$Id: ClusterNode.java 3938 2010-11-17 15:15:25Z mayer $
Author:
Angela Roiger
See Also:
Serialized Form

Field Summary
private  BorderPNode border
           
private  Color borderColor
           
private  double centroidX
           
private  double centroidY
           
private  ClusterNode child1
           
private  ClusterNode child2
           
private  ColoredClusterPNode colorNode
           
private  double factorValue
           
private  double height
           
static Color INTIAL_BORDER_COLOUR
           
private  boolean labelContainsValues
           
private  edu.umd.cs.piccolo.PNode labelNode
           
private  ClusterLabel[] labels
           
private  int level
           
private  double[] mean
           
private  double mergeCost
           
(package private)  int numberOfInputs
           
private static long serialVersionUID
           
private  GeneralUnitPNode[] unitNodes
           
private  double width
           
private  double x
           
private  double y
           
 
Constructor Summary
ClusterNode(ClusterNode n1, ClusterNode n2, int level)
          Connects two ClusterNodes to one cluster
ClusterNode(ClusterNode n1, ClusterNode n2, int level, double mergeCost)
           
ClusterNode(GeneralUnitPNode leaf, int level)
          Creates an initial ClusterNode with only one Node inside.
 
Method Summary
private  void calcLabel(double factorValue, double factorQe, double factorNumber, boolean withValue)
          Calculates and sets new Labels with the given parameters.
 boolean containsAllNodes(Collection<GeneralUnitPNode> nodes)
           
 boolean containsNode(GeneralUnitPNode node)
           
 edu.umd.cs.piccolo.PNode getBorder()
           
 edu.umd.cs.piccolo.PNode getBorder(Color borderColor)
           
 Point2D.Double getCentroid()
           
 ClusterNode getChild1()
          returns the first child cluster
 ClusterNode getChild2()
          returns the second child cluster
 ColoredClusterPNode getColoredCluster()
           
 double getFactorValue()
           
 double getHeight()
          get/set Height/Width/X/Y: used for the bounding rectangle of the cluster.
 edu.umd.cs.piccolo.PNode getLabelNode()
           
 ClusterLabel[] getLabels()
          returns current label or null in case label is not set
 ClusterLabel[] getLabels(double fValue, boolean withValue)
          calculates and sets the current labels in case label is not set yet or the values have changed and returns it
 int getLevel()
          in which level of the clustering tree is this node (1 = top node)
 double[] getMeanVector()
          Returns the mean vector of the cluster's weight vectors.
 double getMergeCost()
           
 GeneralUnitPNode[] getNodes()
          Returns all the GeneralUnitPNodes contained in this cluster
 int getNumberOfInputs()
          Returns the number of input vectors inside this cluster
 double getWidth()
          get/set Height/Width/X/Y: used for the bounding rectangle of the cluster.
 boolean getWithValue()
          Does the Label of this Cluster contain a value
 double getX()
          get/set Height/Width/X/Y: used for the bounding rectangle of the cluster.
 double getY()
          get/set Height/Width/X/Y: used for the bounding rectangle of the cluster.
private  BorderPNode makeBorder()
          Returns a border for this cluster
 void setBorderColor(Color c)
          Changes the colour of the cluster borders
 void setFactorValue(double d)
          Set the factor for the value in calculation of the labels - beween 0 and 1.
 void setHeight(double height)
          get/set Height/Width/X/Y: used for the bounding rectangle of the cluster.
 void setLabelNode(edu.umd.cs.piccolo.PNode n)
           
 void setPaint(Paint newPaint)
          Sets the color of the cluster.
 void setWidth(double width)
          get/set Height/Width/X/Y: used for the bounding rectangle of the cluster.
 void setWithValue(boolean b)
          Should the label contain a value in the text.
 void setX(double x)
          get/set Height/Width/X/Y: used for the bounding rectangle of the cluster.
 void setY(double y)
          get/set Height/Width/X/Y: used for the bounding rectangle of the cluster.
private  void writeLabelInfos(GeneralUnitPNode node)
          Sets this.label and this.numberOfInputs for this cluster.
private static void xorBorderLine(ArrayList<Rectangle2D> lines, double x1, double y1, double x2, double y2)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTIAL_BORDER_COLOUR

public static final Color INTIAL_BORDER_COLOUR

borderColor

private Color borderColor

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

unitNodes

private GeneralUnitPNode[] unitNodes

border

private BorderPNode border

colorNode

private ColoredClusterPNode colorNode

labelNode

private edu.umd.cs.piccolo.PNode labelNode

level

private int level

child1

private ClusterNode child1

child2

private ClusterNode child2

labelContainsValues

private boolean labelContainsValues

factorValue

private double factorValue

labels

private ClusterLabel[] labels

mergeCost

private double mergeCost

numberOfInputs

int numberOfInputs

centroidX

private double centroidX

centroidY

private double centroidY

mean

private double[] mean

x

private double x

y

private double y

width

private double width

height

private double height
Constructor Detail

ClusterNode

public ClusterNode(ClusterNode n1,
                   ClusterNode n2,
                   int level)
Connects two ClusterNodes to one cluster

Parameters:
level - The level of the new cluster.

ClusterNode

public ClusterNode(ClusterNode n1,
                   ClusterNode n2,
                   int level,
                   double mergeCost)

ClusterNode

public ClusterNode(GeneralUnitPNode leaf,
                   int level)
Creates an initial ClusterNode with only one Node inside.

Parameters:
leaf - the GeneralUnitPNode to be put in the cluster
level - a number >= the number of total units.
Method Detail

getMeanVector

public double[] getMeanVector()
Returns the mean vector of the cluster's weight vectors. Calculates it if it is not set yet.

Returns:
the mean vector of the cluster's weight vectors

getCentroid

public Point2D.Double getCentroid()
Returns:
the Centroid of the cluster on the map

setLabelNode

public void setLabelNode(edu.umd.cs.piccolo.PNode n)

getLabelNode

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

writeLabelInfos

private void writeLabelInfos(GeneralUnitPNode node)
Sets this.label and this.numberOfInputs for this cluster. Used only during initialisation when there is only one node per cluster.

Parameters:
node - the GeneralUnitPNode inside this "Cluster"

calcLabel

private void calcLabel(double factorValue,
                       double factorQe,
                       double factorNumber,
                       boolean withValue)
Calculates and sets new Labels with the given parameters. After calling this function you have to set factorValue and labelContainsValues.

Parameters:
factorValue - A double value between 0 and 1 to determine how much the mean value should influence the label.
factorQe - A double value between 0 and 1 to determine how much the qe value should influence the label.
factorNumber - Currently unused. Should determine the influence of the number of input vectors of the clusters.
withValue - set to true if you want a label with values

getLabels

public ClusterLabel[] getLabels()
returns current label or null in case label is not set


getLabels

public ClusterLabel[] getLabels(double fValue,
                                boolean withValue)
calculates and sets the current labels in case label is not set yet or the values have changed and returns it


getNumberOfInputs

public int getNumberOfInputs()
Returns the number of input vectors inside this cluster

Returns:
the number of input vectors

getFactorValue

public double getFactorValue()

getWithValue

public boolean getWithValue()
Does the Label of this Cluster contain a value


setFactorValue

public void setFactorValue(double d)
Set the factor for the value in calculation of the labels - beween 0 and 1. The factor for the qe is automatically calculated as 1-d

Parameters:
d - the factor for the value

setWithValue

public void setWithValue(boolean b)
Should the label contain a value in the text.


getChild1

public ClusterNode getChild1()
returns the first child cluster


getChild2

public ClusterNode getChild2()
returns the second child cluster


getLevel

public int getLevel()
in which level of the clustering tree is this node (1 = top node)


getNodes

public GeneralUnitPNode[] getNodes()
Returns all the GeneralUnitPNodes contained in this cluster


containsNode

public boolean containsNode(GeneralUnitPNode node)

containsAllNodes

public boolean containsAllNodes(Collection<GeneralUnitPNode> nodes)

makeBorder

private BorderPNode makeBorder()
Returns a border for this cluster

Returns:
PNode containing the borders as children

getBorder

public edu.umd.cs.piccolo.PNode getBorder(Color borderColor)

getBorder

public edu.umd.cs.piccolo.PNode getBorder()
Returns:
the border elements of this cluster in a PNode

xorBorderLine

private static void xorBorderLine(ArrayList<Rectangle2D> lines,
                                  double x1,
                                  double y1,
                                  double x2,
                                  double y2)

setPaint

public void setPaint(Paint newPaint)
Sets the color of the cluster.

Parameters:
newPaint - The new color of the cluster

getColoredCluster

public ColoredClusterPNode getColoredCluster()

getHeight

public double getHeight()
get/set Height/Width/X/Y: used for the bounding rectangle of the cluster.


setHeight

public void setHeight(double height)
get/set Height/Width/X/Y: used for the bounding rectangle of the cluster.


getWidth

public double getWidth()
get/set Height/Width/X/Y: used for the bounding rectangle of the cluster.


setWidth

public void setWidth(double width)
get/set Height/Width/X/Y: used for the bounding rectangle of the cluster.


getX

public double getX()
get/set Height/Width/X/Y: used for the bounding rectangle of the cluster.


setX

public void setX(double x)
get/set Height/Width/X/Y: used for the bounding rectangle of the cluster.


getY

public double getY()
get/set Height/Width/X/Y: used for the bounding rectangle of the cluster.


setY

public void setY(double y)
get/set Height/Width/X/Y: used for the bounding rectangle of the cluster.


setBorderColor

public void setBorderColor(Color c)
Changes the colour of the cluster borders


getMergeCost

public double getMergeCost()
Returns:
Returns the mergeCost.