Top Description Fields Constructors Methods
org.abego.treelayout.util

public abstract Class AbstractTreeForTreeLayout<TreeNode>

extends Object
implements TreeForTreeLayout<TreeNode>
Class Inheritance
All Implemented Interfaces
org.abego.treelayout.TreeForTreeLayout
Known Direct Subclasses
org.abego.treelayout.util.DefaultTreeForTreeLayout
Type Parameters
<TreeNode>
Type of elements used as nodes in the tree
Imports
java.util.List, org.abego.treelayout.TreeForTreeLayout, org.abego.treelayout.internal.util.java.lang.IterableUtil, org.abego.treelayout.internal.util.java.util.ListUtil

Provides an easy way to implement the org.abego.treelayout.TreeForTreeLayout interface by defining just two simple methods and a constructor.

To use this class the underlying tree must provide the children as a list (see getChildrenList(Object) and give direct access to the parent of a node (see getParent(Object)).

See also DefaultTreeForTreeLayout.

Author
Udo Borkowski ([email protected])

Field Summary

Modifier and TypeField and Description
private final TreeNode

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Iterable<TreeNode>
getChildren(TreeNode
[!isLeaf(parentNode)]
node
)

Implements org.abego.treelayout.TreeForTreeLayout.getChildren.

Returns the children of a parent node.
public abstract List<TreeNode>

Returns:

the children of the given node. When node is a leaf the list is empty.
getChildrenList
(TreeNode
 
node
)

Return the children of a node as a List.

public Iterable<TreeNode>
getChildrenReverse(TreeNode
[!isLeaf(parentNode)]
node
)

Implements org.abego.treelayout.TreeForTreeLayout.getChildrenReverse.

Returns the children of a parent node, in reverse order.
public TreeNode
getFirstChild(TreeNode
[!isLeaf(parentNode)]
parentNode
)

Implements org.abego.treelayout.TreeForTreeLayout.getFirstChild.

Returns the first child of a parent node.
public TreeNode
getLastChild(TreeNode
[!isLeaf(parentNode)]
parentNode
)

Implements org.abego.treelayout.TreeForTreeLayout.getLastChild.

Returns the last child of a parent node.
public abstract TreeNode

Returns:

[nullable] the parent of the node, or null when the node is a root.
getParent
(TreeNode
 
node
)

Returns the parent of a node, if it has one.

public TreeNode
getRoot()

Implements org.abego.treelayout.TreeForTreeLayout.getRoot.

Returns the the root of the tree.
public boolean
isChildOfParent(TreeNode
 
node
,
TreeNode
 
parentNode
)

Implements org.abego.treelayout.TreeForTreeLayout.isChildOfParent.

Tells if a node is a child of a given parentNode.
public boolean
isLeaf(TreeNode
 
node
)

Implements org.abego.treelayout.TreeForTreeLayout.isLeaf.

Tells if a node is a leaf in the tree.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

rootback to summary
private final TreeNode root

Constructor Detail

AbstractTreeForTreeLayoutback to summary
public AbstractTreeForTreeLayout(TreeNode root)

Method Detail

getChildrenback to summary
public Iterable<TreeNode> getChildren(TreeNode node)

Implements org.abego.treelayout.TreeForTreeLayout.getChildren.

Doc from org.abego.treelayout.TreeForTreeLayout.getChildren.

Returns the children of a parent node.

Time Complexity: O(1)

Parameters
node:TreeNode

[!isLeaf(parentNode)]

Returns:Iterable<TreeNode>

the children of the given parentNode, from first to last

Annotations
@Override
getChildrenListback to summary
public abstract List<TreeNode> getChildrenList(TreeNode node)

Return the children of a node as a List.

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.

Parameters
node:TreeNode

 

Returns:List<TreeNode>

the children of the given node. When node is a leaf the list is empty.

getChildrenReverseback to summary
public Iterable<TreeNode> getChildrenReverse(TreeNode node)

Implements org.abego.treelayout.TreeForTreeLayout.getChildrenReverse.

Doc from org.abego.treelayout.TreeForTreeLayout.getChildrenReverse.

Returns the children of a parent node, in reverse order.

Time Complexity: O(1)

Parameters
node:TreeNode

[!isLeaf(parentNode)]

Returns:Iterable<TreeNode>

the children of given parentNode, from last to first

Annotations
@Override
getFirstChildback to summary
public TreeNode getFirstChild(TreeNode parentNode)

Implements org.abego.treelayout.TreeForTreeLayout.getFirstChild.

Doc from org.abego.treelayout.TreeForTreeLayout.getFirstChild.

Returns the first child of a parent node.

Time Complexity: O(1)

Parameters
parentNode:TreeNode

[!isLeaf(parentNode)]

Returns:TreeNode

the first child of the parentNode

Annotations
@Override
getLastChildback to summary
public TreeNode getLastChild(TreeNode parentNode)

Implements org.abego.treelayout.TreeForTreeLayout.getLastChild.

Doc from org.abego.treelayout.TreeForTreeLayout.getLastChild.

Returns the last child of a parent node.

Time Complexity: O(1)

Parameters
parentNode:TreeNode

[!isLeaf(parentNode)]

Returns:TreeNode

the last child of the parentNode

Annotations
@Override
getParentback to summary
public abstract TreeNode getParent(TreeNode node)

Returns the parent of a node, if it has one.

Time Complexity: O(1)

Parameters
node:TreeNode

 

Returns:TreeNode

[nullable] the parent of the node, or null when the node is a root.

getRootback to summary
public TreeNode getRoot()

Implements org.abego.treelayout.TreeForTreeLayout.getRoot.

Doc from org.abego.treelayout.TreeForTreeLayout.getRoot.

Returns the the root of the tree.

Time Complexity: O(1)

Returns:TreeNode

the root of the tree

Annotations
@Override
isChildOfParentback to summary
public boolean isChildOfParent(TreeNode node, TreeNode parentNode)

Implements org.abego.treelayout.TreeForTreeLayout.isChildOfParent.

Doc from org.abego.treelayout.TreeForTreeLayout.isChildOfParent.

Tells if a node is a child of a given parentNode.

Time Complexity: O(1)

Parameters
node:TreeNode

 

parentNode:TreeNode

 

Returns:boolean

true iff the node is a child of the given parentNode

Annotations
@Override
isLeafback to summary
public boolean isLeaf(TreeNode node)

Implements org.abego.treelayout.TreeForTreeLayout.isLeaf.

Doc from org.abego.treelayout.TreeForTreeLayout.isLeaf.

Tells if a node is a leaf in the tree.

Time Complexity: O(1)

Parameters
node:TreeNode

 

Returns:boolean

true iff node is a leaf in the tree, i.e. has no children.

Annotations
@Override