Class TreeNode
java.lang.Object
com.codename1.ui.chart.TreeNode
A node of hierarchical data for treemaps and sunbursts.
A leaf carries a value; a branch's value is the sum of its children.
TreeNode root = new TreeNode("Portfolio");
TreeNode tech = root.add(new TreeNode("Tech"));
tech.add(new TreeNode("ACME", 120));
tech.add(new TreeNode("Globex", 80));
root.add(new TreeNode("Energy", 60));
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceTold about every change to the tree under the node it is set on:setValueandaddon that node or any node below it. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a child.voidAdds a listener told about changes to this node and every node below it.getChild(int i) Childi.intThe number of children.getColor()The colour fixed for this node, or null to derive it from the palette.intgetDepth()The node's depth below the root, 0 for the root.intThis node's position among its parent's children, or 0 for a node without a parent.getLabel()The node name.The parent, or null for the root.getPath()The path from the root, names joined with " / ".doublegetValue()The leaf value, or the sum of the children's values for a branch.voidRemoves a listener added byaddChangeListener; nothing happens if it was not added.setColor(int rgb) Fixes this node's colour; its descendants use shades of it.setValue(double v) Changes a leaf's value.
-
Constructor Details
-
TreeNode
Creates a branch.
Parameters
label: the node name
-
TreeNode
Creates a leaf.
Parameters
-
label: the node name -
value: the leaf value
-
-
-
Method Details
-
add
-
getLabel
The node name. -
getValue
public double getValue()The leaf value, or the sum of the children's values for a branch. -
setValue
Changes a leaf's value.
Parameters
v: the new value
Returns
this node
-
getIndexInParent
public int getIndexInParent()This node's position among its parent's children, or 0 for a node without a parent.
Returns
the child index
-
addChangeListener
Adds a listener told about changes to this node and every node below it. Any number of listeners can watch one node: each
HierarchySeriesshowing a tree adds one to its root so changes to the tree animate.Parameters
l: the listener
-
removeChangeListener
Removes a listener added by
addChangeListener; nothing happens if it was not added.Parameters
l: the listener
-
getColor
The colour fixed for this node, or null to derive it from the palette. -
setColor
Fixes this node's colour; its descendants use shades of it.
Parameters
rgb: the colour
Returns
this node
-
getParent
The parent, or null for the root. -
getChildCount
public int getChildCount()The number of children. -
getChild
Childi. -
getDepth
public int getDepth()The node's depth below the root, 0 for the root. -
getPath
The path from the root, names joined with " / ".
-