prefuse.data.tree
Class AbstractDeclarativeTree<N extends Node<N,E>,E extends Edge<N,E>>

java.lang.Object
  extended by prefuse.data.tree.AbstractDeclarativeTree<N,E>
Type Parameters:
N -
E -
All Implemented Interfaces:
DeclarativeTree<N,E>
Direct Known Subclasses:
FilteredDeclarativeTree, NodeBasedDeclarativeTree

public abstract class AbstractDeclarativeTree<N extends Node<N,E>,E extends Edge<N,E>>
extends java.lang.Object
implements DeclarativeTree<N,E>

This is a base implementation for a declarative tree. Subclasses should override some of the more inefficient operations where possible.

Author:
Anton Marsden

Constructor Summary
AbstractDeclarativeTree()
           
AbstractDeclarativeTree(N root)
           
 
Method Summary
 int getDepth(N n)
          Get the depth of the given node in the tree.
 N getNextSibling(N node)
          Get the next sibling of the given node.
 int getNodeCount()
          Get the number of nodes in this graph.
protected  int getNodeCountFrom(N n)
           
 N getPreviousSibling(N node)
          Get the previous sibling of the given node.
 N getRoot()
          Get the root node.
protected  void setRoot(N root)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface prefuse.data.tree.DeclarativeTree
childEdges, children, getParent, getParentEdge
 

Constructor Detail

AbstractDeclarativeTree

public AbstractDeclarativeTree()

AbstractDeclarativeTree

public AbstractDeclarativeTree(N root)
Method Detail

getNodeCount

public int getNodeCount()
Description copied from interface: DeclarativeTree
Get the number of nodes in this graph.

Specified by:
getNodeCount in interface DeclarativeTree<N extends Node<N,E>,E extends Edge<N,E>>
Returns:
the number of nodes

getNodeCountFrom

protected int getNodeCountFrom(N n)

getRoot

public N getRoot()
Description copied from interface: DeclarativeTree
Get the root node.

Specified by:
getRoot in interface DeclarativeTree<N extends Node<N,E>,E extends Edge<N,E>>
Returns:
the root Node

setRoot

protected void setRoot(N root)

getNextSibling

public N getNextSibling(N node)
Description copied from interface: DeclarativeTree
Get the next sibling of the given node.

Specified by:
getNextSibling in interface DeclarativeTree<N extends Node<N,E>,E extends Edge<N,E>>
Parameters:
node - a node
Returns:
the next sibling, or null if there is no next sibling

getPreviousSibling

public N getPreviousSibling(N node)
Description copied from interface: DeclarativeTree
Get the previous sibling of the given node.

Specified by:
getPreviousSibling in interface DeclarativeTree<N extends Node<N,E>,E extends Edge<N,E>>
Parameters:
node - a node
Returns:
the previous sibling, or null if there is no previous sibling

getDepth

public int getDepth(N n)
Get the depth of the given node in the tree.

Specified by:
getDepth in interface DeclarativeTree<N extends Node<N,E>,E extends Edge<N,E>>
Parameters:
n - a node in the tree
Returns:
the depth of the node in tree. The root node is at a depth level of 0, with each child at a greater depth level. -1 is returned if the input node id is not in the tree.


Copyright © 2008 Regents of the University of California