Home / Development / Documentation / 2.0.44 / Node
TreeGraph 2
 


info.bioinfweb.treegraph.document
Class Node

java.lang.Object
  extended by info.bioinfweb.treegraph.document.ConcretePaintableElement
      extended by info.bioinfweb.treegraph.document.AbstractTextElement
          extended by info.bioinfweb.treegraph.document.Node
All Implemented Interfaces:
CornerRadiusElement, HiddenDataElement, LineElement, PaintableElement, TextElement, TreeElement, Cloneable

public class Node
extends AbstractTextElement
implements LineElement, CornerRadiusElement, HiddenDataElement, TreeElement, Cloneable

This class represents a node of a tree in the TreeGraph data structure.

Author:
Ben Stöver

Field Summary
private  Branch afferentBranch
           
private  HashMap<String,Object> attributeMap
           
private  ArrayList<Node> children
           
private  NodeFormats formats
           
private  HiddenDataMap hiddenDataMap
           
private  Node parent
           
private  String uniqueName
           
 
Fields inherited from class info.bioinfweb.treegraph.document.ConcretePaintableElement
positions
 
Constructor Summary
Node()
           
 
Method Summary
 Node clone()
          Returns a deep copy of this node not including the subtrees.
 Node clone(boolean keepUniqheNames)
          Returns a deep copy of this node not including the subtrees.
 Node cloneWithSubtree(boolean keepUniqueNames)
          Clones this object and all objects in this subtree and its afferent branch.
 boolean containedInSubtree(ConcretePaintableElement element)
          Tests whether an element is contained in the subtree under this node.
 Branch getAfferentBranch()
           
 HashMap<String,Object> getAttributeMap()
          The attribute map can store data that is specific to special tasks like ladderizing or tree merging.
 List<Node> getChildren()
           
 NodeFormats getFormats()
           
 HiddenDataMap getHiddenDataMap()
           
 Node getHighestChild()
          Returns the upper most subnode of this node (e.g. needed for legend positioning).
static Node getInstanceWithBranch()
           
 Node getLinkedNode()
           
 Node getLowestChild()
          Returns the lowest subnode of this node (e.g. needed for legend positioning).
 Node getNext()
           
 Node getNextLeaf()
           
 Node getParent()
           
 NodePositionData getPosition(PositionPaintType type)
          Returns the stored DataPosition-object of an for an positioner- identifier.
 Node getPrevious()
           
 Node getPreviousLeaf()
           
 String getUniqueName()
          The unique name is used to identify nodes in the XML-file which are associated with legends.
 boolean hasAfferentBranch()
           
 boolean hasParent()
           
 boolean hasUniqueName()
          Test if this node has a unique name specified
 boolean isChildOf(Node ancestor)
          Tests if the specified node is an ancestor of this node.
 boolean isFirst()
           
 boolean isLast()
           
 boolean isLeaf()
          Tests if this Node is at the deepest level of the tree (has no subnodes).
 boolean isOnlySubelement()
          Tests if this element is the only Node under the parent node.
 Vector<String> leafNames()
           
private  void searchLeafNames(Node root, Vector<String> names)
           
 void setAfferentBranch(Branch afferentBranch)
          Sets the specified branch as the afferent branch of this node and additionally sets this node as the target node of the specified branch.
 void setFormats(ElementFormats formats)
           
 void setParent(Node node)
           
 void setUniqueName(String uniqueName)
          The unique name is used to identify nodes in the XML-file which are associated with legends.
 
Methods inherited from class info.bioinfweb.treegraph.document.AbstractTextElement
assignTextElementData, getData, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

private Node parent

children

private ArrayList<Node> children

afferentBranch

private Branch afferentBranch

formats

private NodeFormats formats

uniqueName

private String uniqueName

hiddenDataMap

private HiddenDataMap hiddenDataMap

attributeMap

private HashMap<String,Object> attributeMap
Constructor Detail

Node

public Node()
Method Detail

getInstanceWithBranch

public static Node getInstanceWithBranch()

getPosition

public NodePositionData getPosition(PositionPaintType type)
Description copied from interface: PaintableElement
Returns the stored DataPosition-object of an for an positioner- identifier. If no position-object has been stored for this identifier, one will be created.

Specified by:
getPosition in interface PaintableElement
Overrides:
getPosition in class ConcretePaintableElement
Returns:
the stored position

getParent

public Node getParent()

setParent

public void setParent(Node node)

getChildren

public List<Node> getChildren()

getAfferentBranch

public Branch getAfferentBranch()

setAfferentBranch

public void setAfferentBranch(Branch afferentBranch)
Sets the specified branch as the afferent branch of this node and additionally sets this node as the target node of the specified branch.

Parameters:
afferentBranch - the new afferent branch

getAttributeMap

public HashMap<String,Object> getAttributeMap()
The attribute map can store data that is specific to special tasks like ladderizing or tree merging. Several special routines can store custom objects under their own key here.

Returns:
the attribute map

isLeaf

public boolean isLeaf()
Tests if this Node is at the deepest level of the tree (has no subnodes).

Returns:
true if there are no subnodes or branches.

hasParent

public boolean hasParent()

hasAfferentBranch

public boolean hasAfferentBranch()

isOnlySubelement

public boolean isOnlySubelement()
Tests if this element is the only Node under the parent node.

Returns:
true, if the given element is the only element in the parent node

isFirst

public boolean isFirst()
Returns:
true, if this element is the fist

isLast

public boolean isLast()
Returns:
true, if this element is the last in its parent node

getPrevious

public Node getPrevious()

getNext

public Node getNext()

getPreviousLeaf

public Node getPreviousLeaf()

getNextLeaf

public Node getNextLeaf()

isChildOf

public boolean isChildOf(Node ancestor)
Tests if the specified node is an ancestor of this node. (The result of n.isAncestor(n) is false.)

Parameters:
ancestor -
Returns:

containedInSubtree

public boolean containedInSubtree(ConcretePaintableElement element)
Tests whether an element is contained in the subtree under this node. This also includes legends which are completely anchored inside this subtree.

Parameters:
element - the element to search for (either a Node, Branch, Label or Legend)
Returns:
true, if the element is found
See Also:
TreeSerializer

getFormats

public NodeFormats getFormats()
Specified by:
getFormats in interface CornerRadiusElement
Specified by:
getFormats in interface LineElement
Specified by:
getFormats in interface PaintableElement
Specified by:
getFormats in interface TextElement
Specified by:
getFormats in class AbstractTextElement

setFormats

public void setFormats(ElementFormats formats)
Specified by:
setFormats in interface PaintableElement

getUniqueName

public String getUniqueName()
The unique name is used to identify nodes in the XML-file which are associated with legends.

Returns:
the unique name or null if none is assigned

setUniqueName

public void setUniqueName(String uniqueName)
The unique name is used to identify nodes in the XML-file which are associated with legends.

Parameters:
uniqueName - the new unique name or null if it shall be deleted

hasUniqueName

public boolean hasUniqueName()
Test if this node has a unique name specified

Returns:
true if a unique name has been specified, false if the unique name is null

getHiddenDataMap

public HiddenDataMap getHiddenDataMap()
Specified by:
getHiddenDataMap in interface HiddenDataElement

getHighestChild

public Node getHighestChild()
Returns the upper most subnode of this node (e.g. needed for legend positioning).

Returns:
the upper most subnode

getLowestChild

public Node getLowestChild()
Returns the lowest subnode of this node (e.g. needed for legend positioning).

Returns:
the lowest subnode

searchLeafNames

private void searchLeafNames(Node root,
                             Vector<String> names)

leafNames

public Vector<String> leafNames()

getLinkedNode

public Node getLinkedNode()
Specified by:
getLinkedNode in interface TreeElement

clone

public Node clone()
Returns a deep copy of this node not including the subtrees. The attribute map and the unique names are not copied. Calling this method is equivalent to clone(false).

Specified by:
clone in interface TextElement
Specified by:
clone in class AbstractTextElement

clone

public Node clone(boolean keepUniqheNames)
Returns a deep copy of this node not including the subtrees. The attribute map is not copied.

Parameters:
keepUniqheNames - defines whether the copy should have the same unique name as the original.
Returns:
the copy

cloneWithSubtree

public Node cloneWithSubtree(boolean keepUniqueNames)
Clones this object and all objects in this subtree and its afferent branch. The parent node will be set to null.

Parameters:
keepUniqueNames - defines wheather the copied nodes should have the same unique names as the originals.
Returns:
the root of the cloned tree