Package ptolemy.vergil.tree
Class CompositeTreeModel
- java.lang.Object
-
- ptolemy.vergil.tree.EntityTreeModel
-
- ptolemy.vergil.tree.CompositeTreeModel
-
- All Implemented Interfaces:
javax.swing.tree.TreeModel
public class CompositeTreeModel extends EntityTreeModel
A tree model for Ptolemy II models. Nodes in this tree contain only CompositeEntities.The indexes of the attributes are 0 to a-1, where a is the number of attributes. The indexes of the ports are a to a+p-1, where p is the number of ports, and so on. Subclasses may return a subset of the attributes, ports, and relations by overriding the protected methods that list these contained objects.
- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Christopher Brooks, based on FullTreeModel by Steve Neuendorffer and Edward A. Lee
- Pt.AcceptedRating:
- Red (johnr)
- Pt.ProposedRating:
- Red (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.vergil.tree.EntityTreeModel
EntityTreeModel.TreeUpdateListener
-
-
Field Summary
-
Fields inherited from class ptolemy.vergil.tree.EntityTreeModel
_root
-
-
Constructor Summary
Constructors Constructor Description CompositeTreeModel(CompositeEntity root)
Create a new tree model with the specified root.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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, which in this base class is the number of contained entities.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 ptolemy.vergil.tree.EntityTreeModel
addTreeModelListener, getRoot, removeTreeModelListener, setRoot, valueForPathChanged
-
-
-
-
Constructor Detail
-
CompositeTreeModel
public CompositeTreeModel(CompositeEntity root)
Create a new tree model with the specified root.- Parameters:
root
- The root of the tree.
-
-
Method Detail
-
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. In this base class, a child is a contained entity.- Specified by:
getChild
in interfacejavax.swing.tree.TreeModel
- Overrides:
getChild
in classEntityTreeModel
- 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, which in this base class is the number of contained entities.- Specified by:
getChildCount
in interfacejavax.swing.tree.TreeModel
- Overrides:
getChildCount
in classEntityTreeModel
- Parameters:
parent
- A parent node.- Returns:
- The number of contained entities.
-
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 or is not an instance of CompositeEntity return -1.- Specified by:
getIndexOfChild
in interfacejavax.swing.tree.TreeModel
- Overrides:
getIndexOfChild
in classEntityTreeModel
- Parameters:
parent
- The parent, which is usually a CompositeEntity.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. In this base class, an object is a leaf node if it is not an instance of CompositeEntity.- Specified by:
isLeaf
in interfacejavax.swing.tree.TreeModel
- Overrides:
isLeaf
in classEntityTreeModel
- Parameters:
object
- The object in question.- Returns:
- True if the node has no children.
-
-