Class TreeLayoutObserver.TreeNode
java.lang.Object
org.eclipse.zest.layouts.algorithms.TreeLayoutObserver.TreeNode
- Enclosing class:
- TreeLayoutObserver
Represents a node in a tree structure and stores all information related to
 it. May be subclassed if additional data and behavior is necessary.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final List<TreeLayoutObserver.TreeNode> protected intprotected booleanprotected intprotected booleanprotected final NodeLayoutprotected intprotected intprotected intprotected final TreeLayoutObserverprotected TreeLayoutObserver.TreeNode
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedTreeNode(NodeLayout node, TreeLayoutObserver owner) Creates a tree node related to given layout node
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidAdds given node to the list of this node's children and set its parent to this node.protected voidFinds a node that is the best parent for this node.List<? extends TreeLayoutObserver.TreeNode> intgetDepth()intgetNode()intintintgetOrder()Returns order in which nodes are visited during Deep First Search.getOwner()booleanisAncestorOf(TreeLayoutObserver.TreeNode descendant) protected booleanisBetterParent(TreeLayoutObserver.TreeNode potentialParent) Checks if a potential parent would be better for this node than its current parent.booleanbooleanprotected voidPerforms a DFS on the tree structure and calculates all parameters of its nodes.
- 
Field Details- 
node
- 
owner
- 
heightprotected int height
- 
depthprotected int depth
- 
numOfLeavesprotected int numOfLeaves
- 
numOfDescendantsprotected int numOfDescendants
- 
orderprotected int order
- 
children
- 
parent
- 
firstChildprotected boolean firstChild
- 
lastChildprotected boolean lastChild
 
- 
- 
Constructor Details- 
TreeNodeCreates a tree node related to given layout node- Parameters:
- node- the layout node
- owner-- TreeLayoutObserverowning created node
 
 
- 
- 
Method Details- 
getNode- Returns:
- node layout related to this tree node (null for
         Super Root)
 
- 
getOwner- Returns:
- TreeLayoutObserverowning this tree node
 
- 
getHeightpublic int getHeight()- Returns:
- height of this node in the tree (the longest distance to a leaf, 0 for a leaf itself)
 
- 
getDepthpublic int getDepth()- Returns:
- depth of this node in the tree (distance from root, 0 for a root and
         -1 for Super Root
 
- 
getNumOfLeavespublic int getNumOfLeaves()- Returns:
- number of all leaves descending from this node (1 for a leaf itself)
 
- 
getNumOfDescendantspublic int getNumOfDescendants()- Returns:
- total number of descendants of this node (0 for leafs)
 
- 
getOrderpublic int getOrder()Returns order in which nodes are visited during Deep First Search. Children are visited in the same order as they were added to their layout context, unlessTreeLayoutObserver.recomputeTree()was called after the nodes were added. In that case the order is determined by order of nodes returned byNodeLayout.getSuccessingNodes(). Leaves are assigned successive numbers starting from 0, other nodes have order equal to the smallest order of their children.- Returns:
- order of this node
 
- 
getChildren- Returns:
- an unmodifiable list of this node's children
 
- 
getParent- Returns:
- this node's parent
 
- 
isFirstChildpublic boolean isFirstChild()- Returns:
- true if this node is the first child of its parent (has the smallest order)
 
- 
isLastChildpublic boolean isLastChild()- Returns:
- true if this node is the last child of its parent (has the highest order)
 
- 
addChildAdds given node to the list of this node's children and set its parent to this node.- Parameters:
- child- node to add
 
- 
precomputeTreeprotected void precomputeTree()Performs a DFS on the tree structure and calculates all parameters of its nodes. Should be called onSuper Root. Uses recurrence to go through all the nodes.
- 
findNewParentprotected void findNewParent()Finds a node that is the best parent for this node. Add this node as a child of the found node.
- 
isBetterParentChecks if a potential parent would be better for this node than its current parent. A better parent has smaller depth (with exception toSuper Root, which has depth equal to -1 but is never a better parent than any other node).- Parameters:
- potentialParent- potential parent to check
- Returns:
- true if potentialParent can be a parent of this node and is better than its current parent
 
- 
isAncestorOf- Parameters:
- descendant-
- Returns:
- true if this node is an ancestor if given descendant node
 
 
-