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 java.lang.Object

Intances of this class provide an enviroment for the rcursive 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 GlobalFormats` | `formats`
`private Legends` | `legends`
`private java.util.EnumMap<PositionPaintType,DistanceDimension>` | `paintDimensions`
`private Node` | `paintStart`
`private ScaleBar` | `scaleBar`
`static java.lang.String` | `UNIQUE_NAME_CHARS`
`static int` | `UNIQUE_NAME_LENGTH`

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 unter `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.
`static Node` | `getNodeByUniqueName(Node root, java.lang.String uniqueName)` Searches for a node with the given unique name in the subtree under root.
`Node` | `getNodeByUniqueName(java.lang.String uniqueName)` Searches for a node with the given unique name in this tree.
`DistanceDimension` | `getPaintDimension(PositionPaintType type)` Returnes 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)`
`java.lang.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)`

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 java.lang.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 java.util.EnumMap<PositionPaintType,DistanceDimension> paintDimensions

### formats

    private GlobalFormats formats

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)

  Returnes 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 java.lang.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 consits 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.

### getNodeByUniqueName

    public Node getNodeByUniqueName(java.lang.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

### getNodeByUniqueName

    public static Node getNodeByUniqueName(Node root,
                                           java.lang.String uniqueName)

  Searches for a node with the given unique name in the subtree under root.

  Parameters:
    `root-` - the root of the subtree to be searched
    `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 itsself
  - `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 execpt 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 execpt 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 unter `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