y.layout.tree
Class TreeMapLayouter.NodeWeightComparator
java.lang.Object
y.layout.tree.TreeMapLayouter.NodeWeightComparator
- All Implemented Interfaces:
- java.util.Comparator
- Enclosing class:
- TreeMapLayouter
public static class TreeMapLayouter.NodeWeightComparator
- extends java.lang.Object
- implements java.util.Comparator
A Comparator
that compares two nodes with respect to their weight value defined
via the DataProvider
registered with TreeMapLayouter.NODE_WEIGHT_DPKEY
.
Nodes are sorted in descending order, i.e., nodes with a higher weight (and consequently larger
area in the tree map) are placed first.
The sum of the child weights is used as the weight value for nodes that have children.
-
- To sort nodes in ascending order, subclass this
Comparator
and swap the sign of the
comparison method return value.
-
-
Method Summary |
int |
compare(java.lang.Object o1,
java.lang.Object o2)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
equals |
TreeMapLayouter.NodeWeightComparator
public TreeMapLayouter.NodeWeightComparator()
compare
public int compare(java.lang.Object o1,
java.lang.Object o2)
- Specified by:
compare
in interface java.util.Comparator