infovis.tree.visualization
Class TreeVisualization

java.lang.Object
  extended by infovis.utils.ChangeManager
      extended by infovis.column.AbstractColumn
          extended by infovis.column.ColumnProxy
              extended by infovis.table.TableProxy
                  extended by infovis.visualization.DefaultVisualization
                      extended by infovis.tree.visualization.TreeVisualization
All Implemented Interfaces:
IntComparator, IntProcedure, Column, DynamicTable, Metadata, Constants, Table, Tree, RowComparator, Visualization, LabeledComponent, Orientable, Serializable, EventListener, ChangeListener, TableModelListener, SwingConstants, TableModel, TreeModel
Direct Known Subclasses:
IcicleTreeVisualization, NodeLinkTreeVisualization, TreemapVisualization

public class TreeVisualization
extends DefaultVisualization
implements Tree, IntProcedure

Abstract base class for tree visualizations.

Version:
$Revision: 1.41 $
Author:
Jean-Daniel Fekete
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface infovis.visualization.magicLens.LabeledComponent
LabeledComponent.LabeledItem
 
Field Summary
static String PROPERTY_ROOT
          Property name for the visible root field.
static String SORTEDCHILDREN_COLUMN
          Name of the column containing the sorted children of the tree.
static String WEIGHT_COLUMN
          Name of the column where the additive weights are computed.
 
Fields inherited from class infovis.column.AbstractColumn
MODIFIED_ALL, MODIFIED_NONE
 
Fields inherited from interface infovis.Tree
ROOT, TREE_METADATA
 
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
 
Fields inherited from interface infovis.Visualization
PROPERTY_INTERACTOR, PROPERTY_ITEM_RENDERER, PROPERTY_LAYOUT, PROPERTY_ORIENTATION, PROPERTY_PARENT, PROPERTY_PERMUTATION, PROPERTY_RULERS, VC_DESCRIPTOR_PROPERTY_PREFIX, VISUAL_ALPHA, VISUAL_COLOR, VISUAL_FILTER, VISUAL_HOVER, VISUAL_LABEL, VISUAL_SELECTION, VISUAL_SHAPE, VISUAL_SIZE
 
Fields inherited from interface infovis.visualization.Orientable
DIRECTION, NAME, ORIENTATION_CENTER, ORIENTATION_EAST, ORIENTATION_INVALID, ORIENTATION_NORTH, ORIENTATION_SOUTH, ORIENTATION_WEST, SQRT2
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
TreeVisualization(Tree tree)
          Constructor for TreeVisualization.
TreeVisualization(Tree tree, ItemRenderer ir)
          Constructor for TreeVisualization.
 
Method Summary
 int addNode(int par)
          Adds a node to the tree.
 int addRow()
          Creates a new row and returns it.
 void addTreeModelListener(TreeModelListener l)
          
 boolean apply(int node)
          
 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.
 Object getChild(Object parent, int index)
          
 int getChildCount(int node)
          Returns the number of children of a node.
 int getChildCount(Object parent)
          
 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 getFirstChild(int node)
          Returns the first child of a specified node or NIL.
 int getIndexOfChild(Object parent, Object child)
          
 int getNodeCount()
          Returns the number of proper nodes in the Tree.
 int getParent(int node)
          Returns the parent of a node.
 Object getRoot()
          
 DoubleFunction getTransformFunction()
          Returns the transform function applied to weights or null.
 Tree getTree()
          Returns the tree.
 int getVisibleRoot()
          Returns the visible root.
 NumberColumn getWeightColumn()
          Returns an additive weighted column from the specified size column.
 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.
 boolean isLeaf(Object node)
          
 int nextNode()
          Returns the next node to be returned by addNode.
 void paintItems(Graphics2D graphics, Rectangle2D bounds)
          Method for filtering and painting the items.
 boolean removeNode(int node)
          Removes a node from the tree.
 void removeRow(int row)
          Removes a specified row.
 void removeTreeModelListener(TreeModelListener l)
          
 void reparent(int node, int newparent)
          Change the parent of a specified node, changing the structure.
 RowIterator reverseIterator()
          Returns an iterator over the columns of this table in reverse order.
 void setPermutation(Permutation permutation)
          Sets the permutation.
 void setTransformFunction(DoubleFunction transformFunction)
          Sets the transform function applied to weights or null.
 void setVisibleRoot(int root)
          Sets the visible root.
 void valueForPathChanged(TreePath path, Object newValue)
          
 
Methods inherited from class infovis.visualization.DefaultVisualization
addPropertyChangeListener, addPropertyChangeListener, computeMinMax, computeMinMaxFiltered, computeShapes, createLabelItem, dispose, findRectAt, findVisualization, firePropertyChange, firePropertyChange, firePropertyChange, fireVisualColumnDescriptorChanged, freeRectAt, getBounds, getComponent, getFilter, getFisheye, getInteractor, getItemRenderer, getItemRenderer, getItemRenderer, getLayout, getOrientation, getParent, getPermutation, getPreferredSize, getRectAt, getRowAtIndex, getRowCount, getRowIndex, getRulerTable, getSelection, getShapeAt, getShapeBoundsAt, getShapes, getTable, getVisualColumn, getVisualColumnDescriptor, getVisualColumnIterator, getVisualization, getVisualizationBounds, invalidate, invalidate, isFiltered, isInvalidateColumn, isInvalidated, iterator, paint, paintItem, paintVisualizations, pickAll, pickAll, pickItem, pickTop, pickTop, print, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, setFisheye, setInteractor, setItemRenderer, setOrientation, setParent, setShapeAt, setVisualColumn, stateChanged, tableChanged, validateShapes
 
Methods inherited from class infovis.table.TableProxy
addColumn, addTableModelListener, clear, getColumn, getColumnAt, getColumnClass, getColumnCount, getColumnName, getLastRow, getValueAt, indexOf, indexOf, isCellEditable, isRowValid, removeColumn, removeTableModelListener, setColumnAt, setValueAt
 
Methods inherited from class infovis.column.ColumnProxy
addValue, addValueOrNull, capacity, compare, ensureCapacity, getClientProperty, getFormat, getMaxIndex, getMetadata, getMinIndex, getName, getValueAt, getValueClass, hasUndefinedValue, isEmpty, isInternal, isValueUndefined, setFormat, setName, setSize, setValueAt, setValueOrNullAt, setValueUndefined, size
 
Methods inherited from class infovis.column.AbstractColumn
addChangeListener, compareValues, computeValueMap, computeValueMap, equalObj, equals, getLastModifiedRow, toString
 
Methods inherited from class infovis.utils.ChangeManager
disableNotify, enableNotify, getModCount, removeChangeListener
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface infovis.Table
addColumn, clear, getColumn, getColumnAt, getColumnCount, getLastRow, getRowCount, getTable, indexOf, indexOf, isRowValid, removeColumn, 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
 

Field Detail

PROPERTY_ROOT

public static final String PROPERTY_ROOT
Property name for the visible root field.

See Also:
Constant Field Values

SORTEDCHILDREN_COLUMN

public static final String SORTEDCHILDREN_COLUMN
Name of the column containing the sorted children of the tree.

See Also:
Constant Field Values

WEIGHT_COLUMN

public static final String WEIGHT_COLUMN
Name of the column where the additive weights are computed.

See Also:
Constant Field Values
Constructor Detail

TreeVisualization

public TreeVisualization(Tree tree)
Constructor for TreeVisualization.

Parameters:
tree - the Tree.

TreeVisualization

public TreeVisualization(Tree tree,
                         ItemRenderer ir)
Constructor for TreeVisualization.

Parameters:
tree - the tree
ir - the ItemRenderer root
Method Detail

getTree

public Tree getTree()
Returns the tree.

Returns:
Tree

paintItems

public void paintItems(Graphics2D graphics,
                       Rectangle2D bounds)
Method for filtering and painting the items.

Overrides:
paintItems in class DefaultVisualization
Parameters:
graphics - the graphics.
bounds - the bounding box of the visualization.

apply

public boolean apply(int node)

Specified by:
apply in interface IntProcedure

getVisibleRoot

public int getVisibleRoot()
Returns the visible root.

Returns:
int the visible root.

setVisibleRoot

public void setVisibleRoot(int root)
Sets the visible root.

Parameters:
root - The visible root to set

getWeightColumn

public NumberColumn getWeightColumn()
Returns an additive weighted column from the specified size column.

Returns:
an additive weighted column from the specified size

getTransformFunction

public DoubleFunction getTransformFunction()
Returns the transform function applied to weights or null.

Returns:
the transform function applied to weights or null.

setTransformFunction

public void setTransformFunction(DoubleFunction transformFunction)
Sets the transform function applied to weights or null.

Parameters:
transformFunction - the transform function.

setPermutation

public void setPermutation(Permutation permutation)
Sets the permutation.

Specified by:
setPermutation in interface Visualization
Overrides:
setPermutation in class DefaultVisualization
Parameters:
permutation - The permutation to set

childrenIterator

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

Specified by:
childrenIterator in interface Tree
Parameters:
node - the node
Returns:
the iterator over the children of the node

addNode

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

Specified by:
addNode in interface Tree
Parameters:
par - the parent of the node.
Returns:
the created node.

addRow

public int addRow()
Creates a new row and returns it.

Specified by:
addRow in interface DynamicTable
Returns:
the new created row.

removeRow

public void removeRow(int row)
Removes a specified row.

Specified by:
removeRow in interface DynamicTable
Parameters:
row - the row to remove.

removeNode

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

Specified by:
removeNode in interface Tree
Parameters:
node - the node to remove
Returns:
true if the node has been removed.

getChild

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

Specified by:
getChild in interface Tree
Parameters:
node - the node
index - the index if the requested child
Returns:
the requested child or NIL if node has not so many children.

getChildCount

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

Specified by:
getChildCount in interface Tree
Parameters:
node - the node.
Returns:
the number of children of a node.

getDepth

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

Specified by:
getDepth in interface Tree
Parameters:
node - the node.
Returns:
the depth of the node.

getFirstChild

public int getFirstChild(int node)
Returns the first child of a specified node or NIL.

Parameters:
node - the node
Returns:
the first child of a specified node or NIL.

getParent

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

Specified by:
getParent in interface Tree
Parameters:
node - the node
Returns:
the parent or the NIL value if node is the top node

isAncestor

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

Specified by:
isAncestor in interface Tree
Parameters:
node - the node.
par - the tested ancestor.
Returns:
true if the first node has the second node as ancestor.

isLeaf

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

Specified by:
isLeaf in interface Tree
Parameters:
node - the node
Returns:
true if the node is a leaf_node.

reparent

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

Specified by:
reparent in interface Tree
Parameters:
node - the node.
newparent - the new parent.

nextNode

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

Specified by:
nextNode in interface Tree
Returns:
the next node to be returned by addNode.

reverseIterator

public RowIterator reverseIterator()
Returns an iterator over the columns of this table in reverse order.

Specified by:
reverseIterator in interface Table
Specified by:
reverseIterator in interface Visualization
Overrides:
reverseIterator in class DefaultVisualization
Returns:
an iterator over the columns of this table in reverse order.

getNodeCount

public 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.

Specified by:
getNodeCount in interface Tree
Returns:
the number of proper nodes in the Tree.

addTreeModelListener

public void addTreeModelListener(TreeModelListener l)

Specified by:
addTreeModelListener in interface TreeModel

getChild

public Object getChild(Object parent,
                       int index)

Specified by:
getChild in interface TreeModel

getChildCount

public int getChildCount(Object parent)

Specified by:
getChildCount in interface TreeModel

getIndexOfChild

public int getIndexOfChild(Object parent,
                           Object child)

Specified by:
getIndexOfChild in interface TreeModel

getRoot

public Object getRoot()

Specified by:
getRoot in interface TreeModel

isLeaf

public boolean isLeaf(Object node)

Specified by:
isLeaf in interface TreeModel

removeTreeModelListener

public void removeTreeModelListener(TreeModelListener l)

Specified by:
removeTreeModelListener in interface TreeModel

valueForPathChanged

public void valueForPathChanged(TreePath path,
                                Object newValue)

Specified by:
valueForPathChanged in interface TreeModel


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