public static class TreeLayoutHelper.TreeNode
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.util.List<TreeLayoutHelper.TreeNode> |
children
The children of this node.
|
protected int |
depth
The depth of the node.
|
protected boolean |
firstChild
true if this node is the first child, otherwise
false . |
protected int |
height
The height of the node.
|
protected boolean |
lastChild
true if this node is the last child, otherwise
false . |
protected org.eclipse.gef.graph.Node |
node
The wrapped
Node . |
protected int |
numOfDescendants
The number of descendants.
|
protected int |
numOfLeaves
The number of leaves.
|
protected int |
order
The order of this node.
|
protected TreeLayoutHelper |
owner
The
TreeLayoutHelper that controls this TreeLayoutHelper.TreeNode . |
protected TreeLayoutHelper.TreeNode |
parent
The parent of this node.
|
Modifier | Constructor and Description |
---|---|
protected |
TreeNode(org.eclipse.gef.graph.Node node,
TreeLayoutHelper owner)
Creates a tree node related to given layout node
|
Modifier and Type | Method and Description |
---|---|
protected void |
addChild(TreeLayoutHelper.TreeNode child)
Adds given node to the list of this node's children and set its
parent to this node.
|
protected void |
findNewParent()
Finds a node that is the best parent for this node.
|
java.util.List<TreeLayoutHelper.TreeNode> |
getChildren() |
int |
getDepth() |
int |
getHeight() |
org.eclipse.gef.graph.Node |
getNode() |
int |
getNumOfDescendants() |
int |
getNumOfLeaves() |
int |
getOrder()
Returns order in which nodes are visited during Deep First Search.
|
TreeLayoutHelper |
getOwner() |
TreeLayoutHelper.TreeNode |
getParent() |
boolean |
isAncestorOf(TreeLayoutHelper.TreeNode descendant) |
protected boolean |
isBetterParent(TreeLayoutHelper.TreeNode potentialParent)
Checks if a potential parent would be better for this node than its
current parent.
|
boolean |
isFirstChild() |
boolean |
isLastChild() |
protected void |
precomputeTree()
Performs a DFS on the tree structure and calculates all parameters of
its nodes.
|
protected final org.eclipse.gef.graph.Node node
Node
.protected final TreeLayoutHelper owner
TreeLayoutHelper
that controls this TreeLayoutHelper.TreeNode
.protected int height
protected int depth
protected int numOfLeaves
protected int numOfDescendants
protected int order
protected final java.util.List<TreeLayoutHelper.TreeNode> children
protected TreeLayoutHelper.TreeNode parent
protected boolean firstChild
true
if this node is the first child, otherwise
false
.protected boolean lastChild
true
if this node is the last child, otherwise
false
.protected TreeNode(org.eclipse.gef.graph.Node node, TreeLayoutHelper owner)
node
- the layout nodeowner
- TreeLayoutObserver
owning created nodepublic org.eclipse.gef.graph.Node getNode()
Super Root
)public TreeLayoutHelper getOwner()
TreeLayoutObserver
owning this tree nodepublic int getHeight()
public int getDepth()
Super
Root
public int getNumOfLeaves()
public int getNumOfDescendants()
public int getOrder()
TreeLayoutHelper.computeTree(Node[])
was called after the nodes were added. In that case the order is
determined by order of nodes returned by
Node.getAllSuccessorNodes()
. Leaves are assigned successive
numbers starting from 0, other nodes have order equal to the smallest
order of their children.public java.util.List<TreeLayoutHelper.TreeNode> getChildren()
public TreeLayoutHelper.TreeNode getParent()
public boolean isFirstChild()
public boolean isLastChild()
protected void addChild(TreeLayoutHelper.TreeNode child)
child
- node to addprotected void precomputeTree()
Super Root
. Uses recurrence to go through all the nodes.protected void findNewParent()
protected boolean isBetterParent(TreeLayoutHelper.TreeNode potentialParent)
Super Root
, which has depth
equal to -1 but is never a better parent than any other node).potentialParent
- potential parent to checkpublic boolean isAncestorOf(TreeLayoutHelper.TreeNode descendant)
descendant
- The TreeLayoutHelper.TreeNode
in question.Copyright (c) 2014 itemis AG and others. All rights reserved.