org.abego.treelayout
Interface TreeForTreeLayout<TreeNode>

Type Parameters:
TreeNode -
All Known Implementing Classes:
AbstractTreeForTreeLayout, DefaultTreeForTreeLayout

public interface TreeForTreeLayout<TreeNode>

Represents a tree to be used by the TreeLayout.

The TreeForTreeLayout interface is designed to best match the implemented layout algorithm and to ensure the algorithm's time complexity promises in all possible cases. However in most situation a client must not deal with all details of this interface and can directly use the AbstractTreeForTreeLayout to implement this interface or even use the DefaultTreeForTreeLayout class directly.

Also see this overview.

Author:
Udo Borkowski (ub@abego.org)

Method Summary
 Iterable<TreeNode> getChildren(TreeNode parentNode)
          Returns the children of a parent node.
 Iterable<TreeNode> getChildrenReverse(TreeNode parentNode)
          Returns the children of a parent node, in reverse order.
 TreeNode getFirstChild(TreeNode parentNode)
          Returns the first child of a parent node.
 TreeNode getLastChild(TreeNode parentNode)
          Returns the last child of a parent node.
 TreeNode getRoot()
          Returns the the root of the tree.
 boolean isChildOfParent(TreeNode node, TreeNode parentNode)
          Tells if a node is a child of a given parentNode.
 boolean isLeaf(TreeNode node)
          Tells if a node is a leaf in the tree.
 

Method Detail

getRoot

TreeNode getRoot()
Returns the the root of the tree.

Time Complexity: O(1)

Returns:
the root of the tree

isLeaf

boolean isLeaf(TreeNode node)
Tells if a node is a leaf in the tree.

Time Complexity: O(1)

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

isChildOfParent

boolean isChildOfParent(TreeNode node,
                        TreeNode parentNode)
Tells if a node is a child of a given parentNode.

Time Complexity: O(1)

Parameters:
node -
parentNode -
Returns:
true iff the node is a child of the given parentNode

getChildren

Iterable<TreeNode> getChildren(TreeNode parentNode)
Returns the children of a parent node.

Time Complexity: O(1)

Parameters:
parentNode - [!isLeaf(parentNode)]
Returns:
the children of the given parentNode, from first to last

getChildrenReverse

Iterable<TreeNode> getChildrenReverse(TreeNode parentNode)
Returns the children of a parent node, in reverse order.

Time Complexity: O(1)

Parameters:
parentNode - [!isLeaf(parentNode)]
Returns:
the children of given parentNode, from last to first

getFirstChild

TreeNode getFirstChild(TreeNode parentNode)
Returns the first child of a parent node.

Time Complexity: O(1)

Parameters:
parentNode - [!isLeaf(parentNode)]
Returns:
the first child of the parentNode

getLastChild

TreeNode getLastChild(TreeNode parentNode)
Returns the last child of a parent node.

Time Complexity: O(1)

Parameters:
parentNode - [!isLeaf(parentNode)]
Returns:
the last child of the parentNode


Copyright © 2011 abego Software GmbH, Germany. All Rights Reserved.