br.usp.ime.klava.segmentit.structures
Class HierarchyNode

java.lang.Object
  extended by br.usp.ime.klava.segmentit.structures.HierarchyNode
Direct Known Subclasses:
HierarchyInternalNode, HierarchyLeaf

public abstract class HierarchyNode
extends java.lang.Object

Abstract node of a hierarchy of nested partitions.

Author:
Bruno Klava

Method Summary
abstract  javax.swing.tree.MutableTreeNode buildSubTree()
          Returns a MutableTreeNode representation of this HierarchyNode for visualization in a tree view.
abstract  void deactivateSubTree()
          Sets active to false to all the basins under this HierarchyNode in the hierarchy.
 java.lang.String description()
          Returns a String representation of the subtree of the hierarchy rooted by this HierarchyNode.
abstract  java.lang.String description(int level)
          Returns a String representation of the subtree of the hierarchy rooted by this HierarchyNode.
abstract  java.util.Collection<HierarchyNode> getChildren()
          Returns the HierarchyNodes from which this HierarchyNode was constructed.
 java.awt.Color getColor()
          Returns the random Color associated to this HierarchyNode .
 int getLabel()
          Returns the label of this HierarchyNode.
 HierarchyNode getMaximumBasin()
          Returns the currently highest HierarchyNode of the hierarchy that contains this HierarchyNode.
 AbstractMetric getMetric()
          Returns the AbstractMetric associated with this HierarchyNode.
abstract  int getNumPixels()
          Returns the number of pixels in this HierarchyNode.
 HierarchyInternalNode getParent()
          Returns the HierarchyInternalNode that contains directly this HierarchyNode (its parent in the TreeOfCriticalLakes).
 int getValue(int waterLevel)
          Returns the value of the metric of this HierarchyNode according to the metric used to build the hierarchy.
 boolean isActive()
          Returns if this HierarchyNode is currently active in the hierarchy (if it belongs to the selected partition).
 void merge()
          Activates this HierarchyNode, deactivating all its descendants.
 void paint(java.awt.image.BufferedImage image)
          Paints this HierarchyNode with the color associated to its label in the hierarchy.
abstract  void paint(java.awt.image.BufferedImage image, java.awt.Color color)
          Paints this HierarchyNode with the given color .
abstract  void paintHierarchy(java.awt.image.BufferedImage image)
          Paints the partition selected on the hierarchy (according to the active values) limited to the region that this HierarchyNode represents.
 void randomizeColor()
          Assigns a random Color to this HierarchyNode.
 void refine()
          Deactivates this HierarchyNode, activating its children.
 void resetHierarchy()
          Disconnects this HierarchyNode from a hierarchy, setting its parent to null.
 void setActive(boolean active)
          Sets if this HierarchyNode belongs to the selected partition of the hierarchy.
 void setParent(HierarchyInternalNode parent)
          Sets the HierarchyInternalNode that contains this HierarchyNode.
abstract  void setThreshold(int threshold)
          Selects a partition on the hierarchy according to a threshold value.
 java.lang.String toString()
          Returns the label of this HierarchyNode.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

isActive

public boolean isActive()
Returns if this HierarchyNode is currently active in the hierarchy (if it belongs to the selected partition).

Returns:
true if this HierarchyNode is a region of the selected partition in the hierarchy

setActive

public void setActive(boolean active)
Sets if this HierarchyNode belongs to the selected partition of the hierarchy.

Parameters:
active - indicates if this HierarchyNode belongs to the selected partition of the hierarchy

getLabel

public int getLabel()
Returns the label of this HierarchyNode.

Returns:
the label of this HierarchyNode

getParent

public HierarchyInternalNode getParent()
Returns the HierarchyInternalNode that contains directly this HierarchyNode (its parent in the TreeOfCriticalLakes).

Returns:
the HierarchyInternalNode parent of this HierarchyNode

setParent

public void setParent(HierarchyInternalNode parent)
Sets the HierarchyInternalNode that contains this HierarchyNode.

Parameters:
parent - the HierarchyInternalNode that contains this HierarchyNode

getMetric

public AbstractMetric getMetric()
Returns the AbstractMetric associated with this HierarchyNode.

Returns:
the AbstractMetric associated with this HierarchyNode

getChildren

public abstract java.util.Collection<HierarchyNode> getChildren()
Returns the HierarchyNodes from which this HierarchyNode was constructed.

Returns:
the HierarchyNodes from which this HierarchyNode was constructed

buildSubTree

public abstract javax.swing.tree.MutableTreeNode buildSubTree()
Returns a MutableTreeNode representation of this HierarchyNode for visualization in a tree view.

Returns:
a tree view representation of this HierarchyNode and all HierarchyNodes below it in the hierarchy

paint

public abstract void paint(java.awt.image.BufferedImage image,
                           java.awt.Color color)
Paints this HierarchyNode with the given color .

Parameters:
image - the image where this HierarchyNode will be painted
color - the Color to be used to paint this HierarchyNode

paintHierarchy

public abstract void paintHierarchy(java.awt.image.BufferedImage image)
Paints the partition selected on the hierarchy (according to the active values) limited to the region that this HierarchyNode represents.

Parameters:
image - the image where the partition will be painted

setThreshold

public abstract void setThreshold(int threshold)
Selects a partition on the hierarchy according to a threshold value.

Parameters:
threshold - the threshold value to select a partition in the hierarchy

deactivateSubTree

public abstract void deactivateSubTree()
Sets active to false to all the basins under this HierarchyNode in the hierarchy.


description

public abstract java.lang.String description(int level)
Returns a String representation of the subtree of the hierarchy rooted by this HierarchyNode.

Parameters:
level - the indentation level to be used in the description
Returns:
a String representation of the hierarchy under this HierarchyNode

getNumPixels

public abstract int getNumPixels()
Returns the number of pixels in this HierarchyNode.

Returns:
the number of pixels in this HierarchyNode

refine

public void refine()
Deactivates this HierarchyNode, activating its children.


merge

public void merge()
Activates this HierarchyNode, deactivating all its descendants.


resetHierarchy

public void resetHierarchy()
Disconnects this HierarchyNode from a hierarchy, setting its parent to null.


getValue

public int getValue(int waterLevel)
Returns the value of the metric of this HierarchyNode according to the metric used to build the hierarchy.

Parameters:
waterLevel - the current level of the water used to calculate the metric
Returns:
the value of the metric of this HierarchyNode

getMaximumBasin

public HierarchyNode getMaximumBasin()
Returns the currently highest HierarchyNode of the hierarchy that contains this HierarchyNode.

Returns:
the currently highest HierarchyNode of the hierarchy that contains this HierarchyNode

getColor

public java.awt.Color getColor()
Returns the random Color associated to this HierarchyNode .

Returns:
the Color associated to this HierarchyNode

randomizeColor

public void randomizeColor()
Assigns a random Color to this HierarchyNode.


paint

public void paint(java.awt.image.BufferedImage image)
Paints this HierarchyNode with the color associated to its label in the hierarchy.

Parameters:
image - the image where this HierarchyNode will be painted

toString

public java.lang.String toString()
Returns the label of this HierarchyNode.

Overrides:
toString in class java.lang.Object

description

public java.lang.String description()
Returns a String representation of the subtree of the hierarchy rooted by this HierarchyNode.

Returns:
a String representation of the hierarchy under this HierarchyNode