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 Tree

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

    public class Tree

extends Object

Instances of this class provide an environment for the recursive data-structure of tree-elements without their formats.

Author:
  Ben Stöver

Field Summary
`static float` | `DEFAULT_LONGEST_PATH_LENGTH` The default length of the longest path from the root to a leaf in millimeters.
`private HashSet<ConcretePaintableElement>` | `elementSet`
`private GlobalFormats` | `formats`
`private Legends` | `legends`
`private EnumMap<PositionPaintType,DistanceDimension>` | `paintDimensions`
`private Node` | `paintStart`
`private ScaleBar` | `scaleBar`
`static String` | `UNIQUE_NAME_CHARS`
`static int` | `UNIQUE_NAME_LENGTH`
`private TreeMap<String,Node>` | `uniqueNameMap`

Constructor Summary
`Tree()`

Method Summary
`void` | `assignUniqueNames()` Assigns unique names to all nodes in the tree currently without one.
`private void` | `assignUniqueNamesToSubtree(Node root)` Assigns unique names to all nodes in the subtree under root currently without one.
`void` | `clear()` Removes all tree elements including all legends from this object.
`boolean` | `contains(ConcretePaintableElement element)` Tests if the given element is present in the tree.
`boolean` | `containsDecimal(NodeBranchDataAdapter adapter)` Tests if the tree contains a node which would be able to return a decimal value to the given adapter.
`static boolean` | `containsDecimal(NodeBranchDataAdapter adapter, Node root)` Tests if the subtree under `root` contains a node which would be able to return a decimal value to the given adapter.
`GlobalFormats` | `getFormats()`
`Legends` | `getLegends()`
`static Node` | `getLinkedNode(PaintableElement element)` Returns the linked node to the given element.
`Node` | `getNodeByUniqueName(String uniqueName)` Searches for a node with the given unique name in this tree.
`DistanceDimension` | `getPaintDimension(PositionPaintType type)` Returns the stored paint dimension (the size of the document) for the given painter ID.
`Node` | `getPaintStart()`
`ScaleBar` | `getScaleBar()`
`boolean` | `hasAllBranchLengths()` Tests is there are any branches without a defined length in the tree.
`static boolean` | `hasAllBranchLengths(Node root, boolean needsRootLength)` Tests is there are any branches without a defined length in the subtree under `root`.
`boolean` | `isEmpty()` Tests if there are tree elements present.
`double` | `longestPath()` Returns the longest path to a terminal in this tree.
`static double` | `longestPath(Node root, boolean includeRootBranch)` Returns the longest path to a terminal in the subtree of `root`.
`static Node` | `mostRecentCommonAncestor(Node n1, Node n2)`
`String` | `newUniqueName()` Generates a random unique name for a node which is currently not present in this tree.
`void` | `setPaintStart(Node paintStart)`
`void` | `setScaleBar(ScaleBar scaleBar)`
`void` | `updateElementSet()`

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

Field Detail

### DEFAULT_LONGEST_PATH_LENGTH

    public static final float DEFAULT_LONGEST_PATH_LENGTH

  The default length of the longest path from the root to a leaf in millimeters. (Used by `NewickReader` and `NexusReader`).)

  See Also:
    Constant Field Values

### UNIQUE_NAME_CHARS

    public static final String UNIQUE_NAME_CHARS

See Also:
  Constant Field Values

### UNIQUE_NAME_LENGTH

    public static final int UNIQUE_NAME_LENGTH

See Also:
  Constant Field Values

### paintStart

    private Node paintStart

### scaleBar

    private ScaleBar scaleBar

### legends

    private Legends legends

### paintDimensions

    private EnumMap<PositionPaintType,DistanceDimension> paintDimensions

### formats

    private GlobalFormats formats

### uniqueNameMap

    private TreeMap<String,Node> uniqueNameMap

### elementSet

    private HashSet<ConcretePaintableElement> elementSet

Constructor Detail

### Tree

    public Tree()

Method Detail

### getPaintStart

    public Node getPaintStart()

### setPaintStart

    public void setPaintStart(Node paintStart)

### getScaleBar

    public ScaleBar getScaleBar()

### setScaleBar

    public void setScaleBar(ScaleBar scaleBar)

### getLegends

    public Legends getLegends()

### getFormats

    public GlobalFormats getFormats()

### isEmpty

    public boolean isEmpty()

  Tests if there are tree elements present. Note that it is not testet weather there are legends present even if no tree elements are.

  Returns:
    true if tree elements (minimal a root node) are present

### clear

    public void clear()

  Removes all tree elements including all legends from this object.

### contains

    public boolean contains(ConcretePaintableElement element)

  Tests if the given element is present in the tree.

  Parameters:
    `element` - the element to search for
  Returns:
    true, if the element is found

### getPaintDimension

    public DistanceDimension getPaintDimension(PositionPaintType type)

  Returns the stored paint dimension (the size of the document) for the given painter ID. If none is stored an new empty instance of `DistanceDimension` is stored for this ID and returned.

  Parameters:
    `id` - the painter ID
  Returns:
    the stored paint dimension

### newUniqueName

    public String newUniqueName()

  Generates a random unique name for a node which is currently not present in this tree. Currently a unique name is 10 characters long and consists of the following characters: `abcdefghijklmnopqrstuvwxyz01234567890`. This means that there are 2710 ≈ 2 • 1014 different possible names.

  Returns:
    the new unique name

### assignUniqueNamesToSubtree

    private void assignUniqueNamesToSubtree(Node root)

  Assigns unique names to all nodes in the subtree under root currently without one.
  This method is used by `info.webinsel.treegraph.document.Tree.assignUniqueNames()`.

  Parameters:
    `root` - the root node of the subtree

### assignUniqueNames

    public void assignUniqueNames()

  Assigns unique names to all nodes in the tree currently without one.

### updateElementSet

    public void updateElementSet()

### getNodeByUniqueName

    public Node getNodeByUniqueName(String uniqueName)

  Searches for a node with the given unique name in this tree.

  Parameters:
    `uniqueName` - the searched unique name
  Returns:
    the node with the unique name or null if no node is found

### getLinkedNode

    public static Node getLinkedNode(PaintableElement element)

  Returns the linked node to the given element. The result differs by the type of `PaintableElement` as follows:
  - `Node`: The node itself
  - `Branch`: The target node of this branch
  - `Label`: The target node of the holding branch
  - `Legend`: `null`

  Parameters:
    `element` - the element which linked node shall be returned
  Returns:
    the linked node or null

### mostRecentCommonAncestor

    public static Node mostRecentCommonAncestor(Node n1,
                                                Node n2)

### hasAllBranchLengths

    public static boolean hasAllBranchLengths(Node root,
                                              boolean needsRootLength)

  Tests is there are any branches without a defined length in the subtree under `root`.

  Parameters:
    `root` - the root node of the tree
    `needsRootLength` - specifies whether the root node needs a defined branch length
  Returns:
    `true`, if there a no lengths missing or `root` was `null`.

### hasAllBranchLengths

    public boolean hasAllBranchLengths()

  Tests is there are any branches without a defined length in the tree. The root branch only needs to have a length if it is displayed. Calling this method is equivalent to `hasAllBranchLengths(getPaintStart(), getFormats().getShowRooted())`.

  Returns:
    `true`, if there a no necessary lengths missing

### longestPath

    public static double longestPath(Node root,
                                     boolean includeRootBranch)

  Returns the longest path to a terminal in the subtree of `root`. All branch lengths of the subtree under root must be defined except that of the root branch if `includeRootBranch` is `false`.

  Parameters:
    `root` - the root node of the tree
    `includeRootBranch` - indicates whether the length of the afferent branch of the root node shall be included
  Returns:
    the lengths in branch length units or `Double.NaN` if not all branch lengths are defined

### longestPath

    public double longestPath()

  Returns the longest path to a terminal in this tree. All branch lengths must be defined except that of the root branch if `getFormats().getShowRooted()` is `false`. If this tree is empty 0 is returned.

  Returns:
    the lengths in branch length units or `Double.NaN` if not all branch lengths are defined

### containsDecimal

    public static boolean containsDecimal(NodeBranchDataAdapter adapter,
                                          Node root)

  Tests if the subtree under `root` contains a node which would be able to return a decimal value to the given adapter.

  Parameters:
    `adapter` - the adapter to obtain the decimal value
    `root` - the root of the subtree to be checked
  Returns:
    `true` if at least one decimal value could be returned

### containsDecimal

    public boolean containsDecimal(NodeBranchDataAdapter adapter)

  Tests if the tree contains a node which would be able to return a decimal value to the given adapter.

  Parameters:
    `adapter` - the adapter to obtain the decimal value
  Returns:
    `true` if at least one decimal value could be returned

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