infovis
Interface Tree

All Superinterfaces:
Column, Constants, DynamicTable, IntComparator, Metadata, RowComparator, Serializable, Table, TableModel, TreeModel
All Known Implementing Classes:
DefaultTree, IcicleTreeVisualization, NodeLinkTreeVisualization, TreeAsGraph, TreemapVisualization, TreeProxy, TreeVisualization

public interface Tree
extends DynamicTable, TreeModel

Container for a rooted tree structure (hierarchy).

A tree is a table that maintains its topological information stored as four columns. An index represents a node number, with all associated values stored in the columns. The four internal columns are:

The root of a Tree is always at index 0 so a tree is never empty, it always contain at least a root.

Version:
$Revision: 1.38 $
Author:
Jean-Daniel Fekete

Field Summary
static int ROOT
          Value of the tree's ROOT.
static String TREE_METADATA
          Metadata to get the tree from the table.
 
Fields inherited from interface infovis.Table
FILTER_COLUMN, INTERNAL_PREFIX, NIL, SELECTION_COLUMN
 
Fields inherited from interface infovis.metadata.Constants
CONTRIBUTOR, COVERAGE, CREATOR, DATE, DESCRITION, FORMAT, IDENTIFIER, LANGUAGE, PUBLISHER, RELATION, RIGHTS, SOURCE, SUBJECT, TITLE, TYPE
 
Method Summary
 int addNode(int par)
          Adds a node to the tree.
 RowIterator childrenIterator(int node)
          Returns the iterator over the children of a node.
 int getChild(int node, int index)
          Returns the nth child of a node.
 int getChildCount(int node)
          Returns the number of children of a node.
 int getDepth(int node)
          Returns the depth of a node using either a depth column if it has been computed or the computeDepth method.
 int getNodeCount()
          Returns the number of proper nodes in the Tree.
 int getParent(int node)
          Returns the parent of a node.
 boolean isAncestor(int node, int par)
          Returns true if the first node has the second node as ancestor.
 boolean isLeaf(int node)
          Returns true if the node is a leaf_node.
 int nextNode()
          Returns the next node to be returned by addNode.
 boolean removeNode(int node)
          Removes a node from the tree.
 void reparent(int node, int newparent)
          Change the parent of a specified node, changing the structure.
 
Methods inherited from interface infovis.DynamicTable
addRow, removeRow
 
Methods inherited from interface infovis.Table
addColumn, clear, getColumn, getColumnAt, getColumnCount, getLastRow, getRowCount, getTable, indexOf, indexOf, isRowValid, removeColumn, reverseIterator, setColumnAt
 
Methods inherited from interface infovis.Column
addChangeListener, addValue, addValueOrNull, capacity, disableNotify, enableNotify, ensureCapacity, getFormat, getMaxIndex, getMinIndex, getName, getValueAt, getValueClass, hasUndefinedValue, isEmpty, isInternal, isValueUndefined, iterator, removeChangeListener, setFormat, setName, setSize, setValueAt, setValueOrNullAt, setValueUndefined, size
 
Methods inherited from interface infovis.Metadata
getClientProperty, getMetadata
 
Methods inherited from interface cern.colt.function.IntComparator
compare, equals
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnClass, getColumnName, getValueAt, isCellEditable, removeTableModelListener, setValueAt
 
Methods inherited from interface javax.swing.tree.TreeModel
addTreeModelListener, getChild, getChildCount, getIndexOfChild, getRoot, isLeaf, removeTreeModelListener, valueForPathChanged
 

Field Detail

TREE_METADATA

static final String TREE_METADATA
Metadata to get the tree from the table.

See Also:
Constant Field Values

ROOT

static final int ROOT
Value of the tree's ROOT.

See Also:
Constant Field Values
Method Detail

getChild

int getChild(int node,
             int index)
Returns the nth child of a node.

Parameters:
node - the node
index - the index if the requested child
Returns:
the requested child or NIL if node has not so many children.

getParent

int getParent(int node)
Returns the parent of a node.

Parameters:
node - the node
Returns:
the parent or the NIL value if node is the top node

childrenIterator

RowIterator childrenIterator(int node)
Returns the iterator over the children of a node.

Parameters:
node - the node
Returns:
the iterator over the children of the node

addNode

int addNode(int par)
Adds a node to the tree.

Parameters:
par - the parent of the node.
Returns:
the created node.

removeNode

boolean removeNode(int node)
Removes a node from the tree.

Parameters:
node - the node to remove
Returns:
true if the node has been removed.

getNodeCount

int getNodeCount()
Returns the number of proper nodes in the Tree. Can be different than the value returned by getRowCount if nodes have been removed.

Returns:
the number of proper nodes in the Tree.

nextNode

int nextNode()
Returns the next node to be returned by addNode.

Returns:
the next node to be returned by addNode.

reparent

void reparent(int node,
              int newparent)
Change the parent of a specified node, changing the structure.

Parameters:
node - the node.
newparent - the new parent.

isAncestor

boolean isAncestor(int node,
                   int par)
Returns true if the first node has the second node as ancestor.

Parameters:
node - the node.
par - the tested ancestor.
Returns:
true if the first node has the second node as ancestor.

getDepth

int getDepth(int node)
Returns the depth of a node using either a depth column if it has been computed or the computeDepth method.

Parameters:
node - the node.
Returns:
the depth of the node.

getChildCount

int getChildCount(int node)
Returns the number of children of a node.

Parameters:
node - the node.
Returns:
the number of children of a node.

isLeaf

boolean isLeaf(int node)
Returns true if the node is a leaf_node. Use this method rather than degree(node)==0

Parameters:
node - the node
Returns:
true if the node is a leaf_node.


Copyright © 2005 by Jean-Daniel Fekete and INRIA, France All rights reserved.