ptolemy.vergil.kernel
Class CompositePtolemyModel

java.lang.Object
  extended by ptolemy.vergil.kernel.CompositePtolemyModel
All Implemented Interfaces:
CompositeModel

public class CompositePtolemyModel
extends java.lang.Object
implements CompositeModel

A diva node model for a Ptolemy II composite entity. Each element of the graph model is represented by an instance of Locatable, which is an attribute contained by a Ptolemy II object. If a Ptolemy II object is found that does not contain a Locatable, then one is created if needed. The graph model consists of locations for various elements in the composite. In particular, one location will be included for each contained entity, port, director, and visible attribute. In each case except visible attributes, if there is no location, then a default location is created. Visible attributes are included in the graph only if they already contain a location. In addition, for any relation that links more than two ports and does not contain a Vertex, this class will create a Vertex.

Since:
Ptolemy II 4.0
Version:
$Id: CompositePtolemyModel.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Steve Neuendorffer and Edward A. Lee
See Also:
Location
Accepted Rating:
Red (johnr)
Proposed Rating:
Yellow (neuendor)

Field Summary
private  java.lang.Object _composite
           
private  java.lang.Object _compositeAfter
           
private  java.lang.Object _compositeBefore
           
private  java.util.List _nodeList
           
private  java.util.List _nodeListAfter
           
private  java.util.List _nodeListBefore
           
private  long _version
           
private  long _versionAfter
           
private  long _versionBefore
           
 
Constructor Summary
CompositePtolemyModel()
           
 
Method Summary
protected  Locatable _getLocation(NamedObj object)
          Return the location attribute contained in the given object, or a new location contained in the given object if there was no location.
private  java.util.List _nodeList(NamedObj composite, boolean before, boolean after)
          Return a list of all the nodes in the graph corresponding to the specified Ptolemy II model.
 int getNodeCount(java.lang.Object composite)
          Return the number of nodes contained in the graph for the specified composite.
 java.util.Iterator nodes(java.lang.Object composite)
          Return an iterator over all the nodes contained in the graph for the specified composite.
 java.util.Iterator nodesAfterEdges(java.lang.Object composite)
          Return an iterator over the nodes that should be rendered after to the edges.
 java.util.Iterator nodesBeforeEdges(java.lang.Object composite)
          Return an iterator over the nodes that should be rendered prior to the edges.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_composite

private java.lang.Object _composite

_compositeBefore

private java.lang.Object _compositeBefore

_compositeAfter

private java.lang.Object _compositeAfter

_nodeList

private java.util.List _nodeList

_nodeListBefore

private java.util.List _nodeListBefore

_nodeListAfter

private java.util.List _nodeListAfter

_version

private long _version

_versionBefore

private long _versionBefore

_versionAfter

private long _versionAfter
Constructor Detail

CompositePtolemyModel

public CompositePtolemyModel()
Method Detail

getNodeCount

public int getNodeCount(java.lang.Object composite)
Return the number of nodes contained in the graph for the specified composite. If the argument is not an instance of CompositeEntity, then return 0.

Specified by:
getNodeCount in interface CompositeModel
Parameters:
composite - A composite entity.
Returns:
The number of nodes in the graph representing the specified composite entity.

nodes

public java.util.Iterator nodes(java.lang.Object composite)
Return an iterator over all the nodes contained in the graph for the specified composite. If the argument is not an instance of CompositeEntity, then return an empty iterator.

Specified by:
nodes in interface CompositeModel
Parameters:
composite - A composite entity.
Returns:
An iterator over nodes in the graph representing the specified composite entity.

nodesBeforeEdges

public java.util.Iterator nodesBeforeEdges(java.lang.Object composite)
Return an iterator over the nodes that should be rendered prior to the edges. This iterator does not necessarily support removal operations.

Specified by:
nodesBeforeEdges in interface CompositeModel
Parameters:
composite - The composite.
Returns:
An iterator over the nodes to be rendered prior to the edges.

nodesAfterEdges

public java.util.Iterator nodesAfterEdges(java.lang.Object composite)
Return an iterator over the nodes that should be rendered after to the edges. This iterator does not necessarily support removal operations.

Specified by:
nodesAfterEdges in interface CompositeModel
Parameters:
composite - The composite.
Returns:
An iterator over the nodes to be rendered after to the edges.

_getLocation

protected Locatable _getLocation(NamedObj object)
Return the location attribute contained in the given object, or a new location contained in the given object if there was no location.

Parameters:
object - The object for which a location is needed.
Returns:
The location of the object, or a new location if none.

_nodeList

private java.util.List _nodeList(NamedObj composite,
                                 boolean before,
                                 boolean after)
Return a list of all the nodes in the graph corresponding to the specified Ptolemy II model. If the before and after arguments are both true, then all nodes are returned. If only before is true, then all nodes except attributes that contain an attribute named "_renderLast" are returned. If only after is true, then only attributes that contain an attribute named "_renderLast" are returned. The model can be any NamedObj, and the returned list will include attributes that contain an attribute named "_renderFirst", followed by entities, ports, vertexes, followed by attributes that contain neither "_renderFirst" nor "_renderLast", in that order. Note that this method creates a new list, and should therefore only be called if the object has changed.

Parameters:
composite - The composite entity.
before - True to include nodes to be rendered before edges.
after - True to include nodes to be rendered after edges.
Returns:
A list of the nodes in the graph.