jdepend.swingui

Class DependTreeModel

public class DependTreeModel extends Object implements TreeModel

The DependTreeModel class defines the data model being observed by a DependTree instance.

Author: Mike Clark (mike@clarkware.com) Clarkware Consulting, Inc.

Constructor Summary
DependTreeModel(PackageNode root)
Constructs a DependTreeModel with the specified root package node.
Method Summary
voidaddTreeModelListener(TreeModelListener l)
Adds a listener for the TreeModelEvent posted after the tree changes.
ObjectgetChild(Object parent, int index)
Returns the child of the specified parent at the specified index in the parent's child collection.
intgetChildCount(Object parent)
Returns the number of children for the specified parent.
intgetIndexOfChild(Object parent, Object child)
Returns the index of the specified child within the specified parent.
ObjectgetRoot()
Returns the root of the tree.
booleanisLeaf(Object o)
Determines whether the specified tree node is a leaf node.
voidremoveTreeModelListener(TreeModelListener l)
Removes a listener for TreeModelEvents.
voidvalueForPathChanged(TreePath path, Object newValue)
Callback method triggered when the value for the item specified by path has changed to newValue.

Constructor Detail

DependTreeModel

public DependTreeModel(PackageNode root)
Constructs a DependTreeModel with the specified root package node.

Parameters: root Root package node.

Method Detail

addTreeModelListener

public void addTreeModelListener(TreeModelListener l)
Adds a listener for the TreeModelEvent posted after the tree changes.

Parameters: l The listener to add.

getChild

public Object getChild(Object parent, int index)
Returns the child of the specified parent at the specified index in the parent's child collection.

The specified parent must be a node previously obtained from this data source.

Parameters: parent A node in the tree, obtained from this data source. index Index of child in the parent's child collection.

Returns: Child.

getChildCount

public int getChildCount(Object parent)
Returns the number of children for the specified parent.

The specified parent must be a node previously obtained from this data source.

Parameters: parent A node in the tree, obtained from this data source.

Returns: The number of children of the specified parent, or 0 if the parent is a leaf node or if it has no children.

getIndexOfChild

public int getIndexOfChild(Object parent, Object child)
Returns the index of the specified child within the specified parent.

Parameters: parent Parent node. child Child node.

Returns: Index of child within parent.

getRoot

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

Returns: The root of the tree, or null if the tree has no nodes.

isLeaf

public boolean isLeaf(Object o)
Determines whether the specified tree node is a leaf node.

Parameters: o A node in the tree, obtained from this data source.

Returns: true if the node is a leaf; false otherwise.

removeTreeModelListener

public void removeTreeModelListener(TreeModelListener l)
Removes a listener for TreeModelEvents.

Parameters: l The listener to remove.

valueForPathChanged

public void valueForPathChanged(TreePath path, Object newValue)
Callback method triggered when the value for the item specified by path has changed to newValue.

Parameters: path Path to the node that has changed. newValue The new value of the node.

Copyright B) 1999-2003 Clarkware Consulting, Inc.