ca.ucalgary.innovis
Class NAryTree

java.lang.Object
  extended by ca.ucalgary.innovis.NAryTree
All Implemented Interfaces:
javax.swing.tree.TreeModel

public class NAryTree
extends java.lang.Object
implements javax.swing.tree.TreeModel

This class is an implementation of the TreeModel interface.

Version:
1.2 - now implements TreeModel
Author:
Petra Neumann

Constructor Summary
NAryTree(NAryTreeNodeModel root)
           
 
Method Summary
 void addTreeModelListener(javax.swing.event.TreeModelListener arg0)
          I Not implemented
 java.lang.Object getChild(java.lang.Object parent, int index)
          Returns the child of parent at index index in the parent's child array.
 int getChildCount(java.lang.Object node)
          Returns the number of children of node
 int getDepth(boolean recalculate)
          Returns the depth of this tree.
 int getIndexOfChild(java.lang.Object arg0, java.lang.Object arg1)
          Not implemented
 int getLeafCount(boolean recalculate)
          Returns the number of leaves in the tree.
 int getNodeCount(boolean recalculate)
          Returns the number of nodes in the tree.
 java.lang.Object getRoot()
          Returns the root of the tree
 boolean isLeaf(java.lang.Object node)
          Finds out if a given node is a leaf node
 void removeTreeModelListener(javax.swing.event.TreeModelListener arg0)
          Not implemented
 void valueForPathChanged(javax.swing.tree.TreePath arg0, java.lang.Object arg1)
          Not implemented
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NAryTree

public NAryTree(NAryTreeNodeModel root)
Method Detail

getRoot

public java.lang.Object getRoot()
Returns the root of the tree

Specified by:
getRoot in interface javax.swing.tree.TreeModel

getChild

public java.lang.Object getChild(java.lang.Object parent,
                                 int index)
Returns the child of parent at index index in the parent's child array.

Specified by:
getChild in interface javax.swing.tree.TreeModel
Parameters:
parent - the node's parent
index - index of the child

getChildCount

public int getChildCount(java.lang.Object node)
Returns the number of children of node

Specified by:
getChildCount in interface javax.swing.tree.TreeModel
Parameters:
node - the node whose children are counted
Returns:
the number of children of node

isLeaf

public boolean isLeaf(java.lang.Object node)
Finds out if a given node is a leaf node

Specified by:
isLeaf in interface javax.swing.tree.TreeModel
Parameters:
node - the node to be checked for leaf status
Returns:
true if node is a leaf, false if not

getDepth

public int getDepth(boolean recalculate)
Returns the depth of this tree. The depth of a tree is length of the longest path from the root to one of the leaves. This method is called once automatically when the tree is initialized witha root.

Parameters:
recalculate - Determines whether the number should be traversed. Only set true if you have made any changes to the tree since its initialization.
Returns:
the depth of the tree

getNodeCount

public int getNodeCount(boolean recalculate)
Returns the number of nodes in the tree. This method is called once automatically when the tree is initialized.

Parameters:
recalculate - Only set this to true if you have made changes to the tree.
Returns:
The number of nodes in the tree.

getLeafCount

public int getLeafCount(boolean recalculate)
Returns the number of leaves in the tree. This method is called once automatically when the tree is initialized.

Parameters:
recalculate - Only set this to true if you have made changes to the tree.
Returns:
The number of leaves in the tree.

valueForPathChanged

public void valueForPathChanged(javax.swing.tree.TreePath arg0,
                                java.lang.Object arg1)
Not implemented

Specified by:
valueForPathChanged in interface javax.swing.tree.TreeModel

getIndexOfChild

public int getIndexOfChild(java.lang.Object arg0,
                           java.lang.Object arg1)
Not implemented

Specified by:
getIndexOfChild in interface javax.swing.tree.TreeModel

addTreeModelListener

public void addTreeModelListener(javax.swing.event.TreeModelListener arg0)
I Not implemented

Specified by:
addTreeModelListener in interface javax.swing.tree.TreeModel

removeTreeModelListener

public void removeTreeModelListener(javax.swing.event.TreeModelListener arg0)
Not implemented

Specified by:
removeTreeModelListener in interface javax.swing.tree.TreeModel