TreeNode - Type of elements used as nodes in the treepublic class DefaultTreeForTreeLayout<TreeNode> extends AbstractTreeForTreeLayout<TreeNode>
TreeForTreeLayout
interface, applicable to any type of tree node.
It allows you to create a tree "from scratch", without creating any new class.
To create a tree you must provide the root of the tree (see
DefaultTreeForTreeLayout(Object). Then you can incrementally
construct the tree by adding children to the root or other nodes of the tree
(see addChild(Object, Object) and
addChildren(Object, Object...)).
| Constructor and Description |
|---|
DefaultTreeForTreeLayout(TreeNode root)
Creates a new instance with a given node as the root
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChild(TreeNode parentNode,
TreeNode node) |
void |
addChildren(TreeNode parentNode,
TreeNode... nodes) |
List<TreeNode> |
getChildrenList(TreeNode node)
Return the children of a node as a
List. |
TreeNode |
getParent(TreeNode node)
Returns the parent of a node, if it has one.
|
boolean |
hasNode(TreeNode node) |
getChildren, getChildrenReverse, getFirstChild, getLastChild, getRoot, isChildOfParent, isLeafpublic DefaultTreeForTreeLayout(TreeNode root)
root - the node to be used as the root.public TreeNode getParent(TreeNode node)
AbstractTreeForTreeLayoutTime Complexity: O(1)
getParent in class AbstractTreeForTreeLayout<TreeNode>node - public List<TreeNode> getChildrenList(TreeNode node)
AbstractTreeForTreeLayoutList.
Time Complexity: O(1)
Also the access to an item of the list must have time complexity O(1).
A client must not modify the returned list.
getChildrenList in class AbstractTreeForTreeLayout<TreeNode>node - public boolean hasNode(TreeNode node)
node - public void addChild(TreeNode parentNode, TreeNode node)
parentNode - [hasNode(parentNode)]node - [!hasNode(node)]Copyright © 2015 abego Software GmbH, Germany. All Rights Reserved.