public class TreeMapNode extends java.lang.Object implements javax.swing.tree.MutableTreeNode, java.lang.Comparable<TreeMapNode>, java.lang.Iterable<TreeMapNode>
Constructor and Description |
---|
TreeMapNode(java.lang.String label)
Creates a node with the given label.
|
TreeMapNode(java.lang.String label,
double order,
java.lang.Float sizeValue,
java.lang.Float colourValue)
Creates a node with the given label, order, size value and colour value.
|
TreeMapNode(java.lang.String label,
double order,
java.lang.Float sizeValue,
java.lang.Float colourValue,
java.awt.geom.Point2D location)
Creates a node with the given label, order, size value, colour value and location.
|
TreeMapNode(java.lang.String label,
float sizeValue)
Creates a node with the given label and size.
|
TreeMapNode(java.lang.String label,
java.lang.Float sizeValue)
Creates a node with the given label and size value.
|
Modifier and Type | Method and Description |
---|---|
void |
add(TreeMapNode child)
Adds the given child node to this one.
|
java.awt.geom.Rectangle2D |
calcGeoBounds()
Reports the bounding rectangle of this node in georeferenced coordinates.
|
java.util.Enumeration<TreeMapNode> |
children()
Reports the children of this node.
|
int |
compareTo(TreeMapNode node)
Compares this node with another.
|
TreeMapNode |
findNode(java.lang.String nodeLabel)
Performs a breadth-first search looking for the first node with the given label.
|
double |
getAccumSize()
Reports the accumulated numeric values of this node and its children.
|
boolean |
getAllowsChildren()
Reports whether this node allows children.
|
double |
getArea()
Reports the area of this node.
|
TreeMapNode |
getChildAt(int index)
Reports the child at the given index.
|
int |
getChildCount()
Reports the number of children held by this node.
|
java.util.List<TreeMapNode> |
getChildren()
Reports the children of this node.
|
java.lang.Float |
getColourValue()
Reports the numeric value associated with colour of node.
|
static java.util.Comparator<TreeMapNode> |
getEWComparator()
Provides a spatial comparator that can be used for ordering nodes in an west-east direction.
|
int |
getIndex(javax.swing.tree.TreeNode node)
Reports the index of the given node in this node's list of children.
|
java.lang.String |
getLabel()
Reports the text label associated with the node.
|
int |
getLevel()
Reports the depth of this node.
|
java.awt.geom.Point2D |
getLocation()
Reports the location of this node.
|
int |
getMaxDepth()
Reports the maximum depth that can be found by traversing from this node downward.
|
java.util.List<TreeMapNode> |
getNeighbours()
Reports the nodes that are immediate neighbours of this one.
|
static java.util.Comparator<TreeMapNode> |
getNSComparator()
Provides a spatial comparator that can be used for ordering nodes in an south-north direction.
|
int |
getNumLeaves()
Reports the number of leaves attached to this node and any of its descendants in the tree.
|
double |
getOrder()
Reports the value used to determine node order.
|
TreeMapNode |
getParent()
Reports the parent of this node.
|
java.lang.String |
getPath()
Reports the path from the root node to this one (line of antecedents).
|
java.awt.geom.Rectangle2D.Double |
getRectangle()
Reports the rectangle representing the tree-map coordinates of this node.
|
double |
getSizeValue()
Reports the numeric value associated with size of node.
|
void |
insert(javax.swing.tree.MutableTreeNode child,
int index)
Adds the given child node to this one.
|
boolean |
isLeaf()
Reports whether not not this is a leaf node.
|
java.util.Iterator<TreeMapNode> |
iterator()
Provides an iterator that will perform a breadth-first iteration over the hierarchy starting with
this node and its children.
|
void |
remove(int index)
Removes the child node at the given index.
|
void |
remove(javax.swing.tree.MutableTreeNode child)
Removes the given child node.
|
void |
removeFromParent()
Removes this node from its parent if it has one.
|
void |
setLabel(java.lang.String label)
Sets the label associated with this node.
|
void |
setLocation(java.awt.geom.Point2D newLocation)
Sets a new geographic location of this node.
|
void |
setParent(javax.swing.tree.MutableTreeNode parent)
Sets the new given parent of this node.
|
void |
setSizeValue(java.lang.Float newSizeValue)
Sets a new size value for this node.
|
void |
setUserObject(java.lang.Object object)
Would set the new user object to be carried by this node, but does nothing
in this case except report an error.
|
void |
sortAtLevel(int sortLevel)
Sorts all nodes at the given level in the hierarchy into descending order.
|
void |
sortChildren()
Sorts the immediate child nodes into descending order.
|
void |
sortChildren(java.util.Comparator<TreeMapNode> comparator)
Sorts the immediate child nodes using the given comparator.
|
void |
sortDescendants()
Sorts all descendants into descending order.
|
void |
sortDescendants(java.util.Comparator<TreeMapNode> comparator)
Sorts all of the descendants of this node using the given comparator.
|
java.lang.String |
toString()
Provides a textual description of the node.
|
public TreeMapNode(java.lang.String label)
label
- Text label of the node.public TreeMapNode(java.lang.String label, float sizeValue)
label
- Text label of the node.sizeValue
- Numeric value to be associated with the size of the node. If this value is negative,
this node is treated as a dummy node with the size of abs(sizeValue)
.public TreeMapNode(java.lang.String label, java.lang.Float sizeValue)
label
- Text label of the node.sizeValue
- Numeric value to be associated with the size of the node or null if it is to be found
from the accumulated values of its descendants. If this is a leaf node (ie it has no
descendants) and sizeValue
is null, its size is assumed to be 1. If this
value is negative, this node is treated as a dummy node with the size of abs(sizeValue)
.public TreeMapNode(java.lang.String label, double order, java.lang.Float sizeValue, java.lang.Float colourValue)
label
- Text label of the node.order
- Value indicating relative order of node. This value is compared with the order of any
sibling nodes when sorting them. If order values are the same, nodes are sorted by size
then colour value.sizeValue
- Numeric value to be associated with the size of the node or null if it is to be found
from the accumulated values of its descendants. If this is a leaf node (ie it has no
descendants) and sizeValue
is null, its size is assumed to be 1. If this
value is negative, this node is treated as a dummy node with the size of abs(sizeValue)
.colourValue
- Numeric value to be associated with the colour of the node or null if colour to be generated.public TreeMapNode(java.lang.String label, double order, java.lang.Float sizeValue, java.lang.Float colourValue, java.awt.geom.Point2D location)
label
- Text label of the node.order
- Value indicating relative order of node. This value is compared with the order value of all
sibling nodes when sorting them. If order values are the same, nodes are sorted by size
then colour value.sizeValue
- Numeric value to be associated with the size of the node or null if it is to be found
from the accumulated values of its descendants. If this is a leaf node (ie it has no
descendants) and sizeValue
is null, its size is assumed to be 1. If this
value is negative, this node is treated as a dummy node with the size of abs(sizeValue)
.colourValue
- Numeric value to be associated with the colour of the node or null if colour to be generated.location
- Spatial location of node (can be null if not spatially referenced).public void add(TreeMapNode child)
TreeMapNode
s may not return correct values for getLevel()
or
getMaxDepth()
until either updateTree()
or TreeMappa
's
buildTreeMap()
method has been called.child
- Child node to add.public TreeMapNode findNode(java.lang.String nodeLabel)
nodeLabel
- Text to search for.public void sortChildren()
public void sortChildren(java.util.Comparator<TreeMapNode> comparator)
comparator
- Comparator to use to compare a pair of TreeMapNodes.public void sortDescendants(java.util.Comparator<TreeMapNode> comparator)
comparator
- Comparator to use to compare a pair of TreeMapNodes.public void sortDescendants()
public void sortAtLevel(int sortLevel)
sortLevel
- Hierarchy level at which to apply sorting, where 0 is root level.public java.lang.String getPath()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getLabel()
public double getOrder()
public double getSizeValue()
public java.lang.Float getColourValue()
public double getAccumSize()
public double getArea()
public java.awt.geom.Point2D getLocation()
public java.awt.geom.Rectangle2D calcGeoBounds()
getRect()
is returned
(ie the pixel coordinates of the node).public int getLevel()
public int getMaxDepth()
public int getNumLeaves()
public void setLabel(java.lang.String label)
label
- New label.public void setSizeValue(java.lang.Float newSizeValue)
TreeMappa
's buildTreeMap()
method will be necessary.newSizeValue
- Numeric value to be associated with the size of the node or null if it is to be found
from the accumulated values of its descendants. If this is a leaf node (ie it has no
descendants) and sizeValue
is null, its size is assumed to be 1. If this
value is negative, this node is treated as a dummy node with the size of abs(sizeValue)
.public void setLocation(java.awt.geom.Point2D newLocation)
TreeMappa
's buildTreeMap()
method will be necessary.newLocation
- New location to be associated with the node or null if it is to be found from the mean centre
of its descendants. If this is a leaf node (ie it has no descendants) and location
is null, it is assumed this node has no location.public java.awt.geom.Rectangle2D.Double getRectangle()
TreeMappa
's buildTreeMap()
method since a change to any of this node's
properties that might affect geometry.public java.util.List<TreeMapNode> getChildren()
public java.util.List<TreeMapNode> getNeighbours()
public int compareTo(TreeMapNode node)
Comparator
object when calling sortChildren()
or sortDescendants()
.compareTo
in interface java.lang.Comparable<TreeMapNode>
node
- Node with which to compare this one.public void insert(javax.swing.tree.MutableTreeNode child, int index)
insert
in interface javax.swing.tree.MutableTreeNode
child
- Child node to add.index
- Position in list of children to add.public void remove(int index)
remove
in interface javax.swing.tree.MutableTreeNode
index
- Position in list of children to remove.public void remove(javax.swing.tree.MutableTreeNode child)
remove
in interface javax.swing.tree.MutableTreeNode
child
- Child node to remove.public void removeFromParent()
removeFromParent
in interface javax.swing.tree.MutableTreeNode
public void setParent(javax.swing.tree.MutableTreeNode parent)
setParent
in interface javax.swing.tree.MutableTreeNode
parent
- New parent to link with this one.public void setUserObject(java.lang.Object object)
setUserObject
in interface javax.swing.tree.MutableTreeNode
object
- Object to store (ignored).public java.util.Enumeration<TreeMapNode> children()
children
in interface javax.swing.tree.TreeNode
public boolean getAllowsChildren()
getAllowsChildren
in interface javax.swing.tree.TreeNode
public TreeMapNode getChildAt(int index)
getChildAt
in interface javax.swing.tree.TreeNode
index
- Index representing position of the child.public int getChildCount()
getChildCount
in interface javax.swing.tree.TreeNode
public int getIndex(javax.swing.tree.TreeNode node)
getIndex
in interface javax.swing.tree.TreeNode
node
- Node to search for.public TreeMapNode getParent()
getParent
in interface javax.swing.tree.TreeNode
public boolean isLeaf()
isLeaf
in interface javax.swing.tree.TreeNode
public java.util.Iterator<TreeMapNode> iterator()
iterator
in interface java.lang.Iterable<TreeMapNode>
public static java.util.Comparator<TreeMapNode> getEWComparator()
public static java.util.Comparator<TreeMapNode> getNSComparator()