ptolemy.vergil.tree
Class ClassAndEntityTreeModel
java.lang.Object
ptolemy.vergil.tree.EntityTreeModel
ptolemy.vergil.tree.ClassAndEntityTreeModel
- All Implemented Interfaces:
- javax.swing.tree.TreeModel
- Direct Known Subclasses:
- FullTreeModel, NavigationTreeModel
public class ClassAndEntityTreeModel
- extends EntityTreeModel
A tree model for Ptolemy II models that includes class definitions and
entities. The indexes of the class definitions are 0 to a-1, where a is the
number of class definitions. The indexes of the entities are a to a+p-1,
where p is the number of entities.
- Since:
- Ptolemy II 4.0
- Version:
- $Id: ClassAndEntityTreeModel.java 57040 2010-01-27 20:52:32Z cxh $
- Author:
- Edward A. Lee
- Accepted Rating:
- Proposed Rating:
Method Summary |
protected java.util.List |
_classes(java.lang.Object object)
Return the list of classes, or an empty list if there are none. |
java.lang.Object |
getChild(java.lang.Object parent,
int index)
Get the child of the given parent at the given index. |
int |
getChildCount(java.lang.Object parent)
Return the number of children of the given parent. |
int |
getIndexOfChild(java.lang.Object parent,
java.lang.Object child)
Return the index of the given child within the given parent. |
boolean |
isLeaf(java.lang.Object object)
Return true if the object is a leaf node. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ClassAndEntityTreeModel
public ClassAndEntityTreeModel(NamedObj root)
- Create a new tree model with the specified root.
- Parameters:
root
- The root of the tree.
getChild
public java.lang.Object getChild(java.lang.Object parent,
int index)
- Get the child of the given parent at the given index.
If the child does not exist, then return null.
- Specified by:
getChild
in interface javax.swing.tree.TreeModel
- Overrides:
getChild
in class EntityTreeModel
- Parameters:
parent
- A node in the tree.index
- The index of the desired child.
- Returns:
- A node, or null if there is no such child.
getChildCount
public int getChildCount(java.lang.Object parent)
- Return the number of children of the given parent.
This is the number classes and contained
entities, filtered by the filter specified by setFilter(),
if any has been specified.
- Specified by:
getChildCount
in interface javax.swing.tree.TreeModel
- Overrides:
getChildCount
in class EntityTreeModel
- Parameters:
parent
- A parent node.
- Returns:
- The number of children.
getIndexOfChild
public int getIndexOfChild(java.lang.Object parent,
java.lang.Object child)
- Return the index of the given child within the given parent.
If the parent is not contained in the child, return -1.
- Specified by:
getIndexOfChild
in interface javax.swing.tree.TreeModel
- Overrides:
getIndexOfChild
in class EntityTreeModel
- Parameters:
parent
- The parent.child
- The child.
- Returns:
- The index of the specified child.
isLeaf
public boolean isLeaf(java.lang.Object object)
- Return true if the object is a leaf node. An object is a leaf
node if it has no children that are instances of one of the classes
specified by setFilter(), if a filter has been specified.
- Specified by:
isLeaf
in interface javax.swing.tree.TreeModel
- Overrides:
isLeaf
in class EntityTreeModel
- Parameters:
object
- The object.
- Returns:
- True if the node has no children.
_classes
protected java.util.List _classes(java.lang.Object object)
- Return the list of classes, or an empty list if there are none.
Override this method if you wish to show only a subset of the
classes.
- Parameters:
object
- The object.
- Returns:
- A list of classes.