Class AbstractTreeForTreeLayout<TreeNode>

  • Type Parameters:
    TreeNode -

    Adapted from https://code.google.com/p/treelayout/ to be available to GWT clients

    All Implemented Interfaces:
    TreeForTreeLayout<TreeNode>

    public abstract class AbstractTreeForTreeLayout<TreeNode>
    extends Object
    implements TreeForTreeLayout<TreeNode>
    Provides an easy way to implement the 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)).

    • Constructor Detail

      • AbstractTreeForTreeLayout

        public AbstractTreeForTreeLayout​(TreeNode root)
    • Method Detail

      • getParent

        public abstract TreeNode getParent​(TreeNode node)
        Returns the parent of a node, if it has one.

        Time Complexity: O(1)

        Parameters:
        node -
        Returns:
        [nullable] the parent of the node, or null when the node is a root.
      • getChildrenList

        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 -
        Returns:
        the children of the given node. When node is a leaf the list is empty.
      • isLeaf

        public boolean isLeaf​(TreeNode node)
        Description copied from interface: TreeForTreeLayout
        Tells if a node is a leaf in the tree.

        Time Complexity: O(1)

        Specified by:
        isLeaf in interface TreeForTreeLayout<TreeNode>
        Returns:
        true iff node is a leaf in the tree, i.e. has no children.