Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## info.bioinfweb.treegraph.document
Class TreePath

    java.lang.Object
      info.bioinfweb.treegraph.document.TreePath

    public class TreePath

extends Object

This class stores the path to an node from the root of the tree or a specified ancestor. It can be used to find equivalent nodes in different trees.

Author:
  Ben Stöver

Field Summary
`private Vector<Integer>` | `path`

Constructor Summary
`TreePath(Node leaf)` Creates a path from the specified leaf to the root of the tree.
`TreePath(Node leaf, Node ancestor)` Creates a path from the specified leaf to the specified ancestor (not including the ancestor itself).

Method Summary
`int` | `comparePosition(TreePath other)` Calculates which of the two target nodes is further upwards in the tree.
`Node` | `findNode(Node root)` Finds the node specidied by the stored path relative to the given root node.
`int` | `getPosition(int level)` Returns the position in this path on the specified level.
`int` | `length()` Returns the length of the path.
`private void` | `setPath(Node end, Node ancestor)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### path

    private Vector<Integer> path

Constructor Detail

### TreePath

    public TreePath(Node leaf)

  Creates a path from the specified leaf to the root of the tree.

  Parameters:
    `leaf` -

### TreePath

    public TreePath(Node leaf,
                    Node ancestor)

  Creates a path from the specified leaf to the specified ancestor (not including the ancestor itself).

  Parameters:
    `leaf` -
    `ancestor` -
  Since:
    2.0.25

Method Detail

### setPath

    private void setPath(Node end,
                         Node ancestor)

### findNode

    public Node findNode(Node root)

  Finds the node specidied by the stored path relative to the given root node.

  Parameters:
    `root` - the start of the path
  Returns:
    the end of the path

### comparePosition

    public int comparePosition(TreePath other)

  Calculates which of the two target nodes is further upwards in the tree.

  Parameters:
    `other` - the path that leads to the node that should be compared with the target of this path (The given path has to allude to the same tree as the path contained in this object.)
  Returns:
    -1 if the target of the comapared path is further upwards, 1 if the target of this path is further upwards or 0 if both paths lead to the same node

### getPosition

    public int getPosition(int level)

  Returns the position in this path on the specified level.

  Parameters:
    `level` - the level in the path where the leaf is on the deepest level (with the highest index)
  Returns:
  Since:
    2.0.25

### length

    public int length()

  Returns the length of the path.

  Since:
    2.0.25

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD