ptolemy.vergil.modal
Class FSMGraphModel

java.lang.Object
  extended by diva.graph.AbstractGraphModel
      extended by diva.graph.modular.ModularGraphModel
          extended by ptolemy.vergil.basic.AbstractBasicGraphModel
              extended by ptolemy.vergil.modal.FSMGraphModel
All Implemented Interfaces:
GraphModel, ChangeListener
Direct Known Subclasses:
GTFrameController.GTFSMGraphModel

public class FSMGraphModel
extends AbstractBasicGraphModel

A graph model for graphically manipulating ptolemy FSM models.

Since:
Ptolemy II 8.0
Version:
$Id: FSMGraphModel.java 57046 2010-01-27 23:35:53Z cxh $
Author:
Steve Neuendorffer
Accepted Rating:
Red (johnr)
Proposed Rating:
Yellow (neuendor)

Nested Class Summary
 class FSMGraphModel.ArcModel
          The model for arcs between states.
 class FSMGraphModel.PortModel
          The model for external ports.
 class FSMGraphModel.StateModel
          The model for an icon that represent states.
 
Field Summary
private  FSMGraphModel.ArcModel _arcModel
           
private  java.util.Set _linkSet
           
private  FSMGraphModel.PortModel _portModel
           
private  FSMGraphModel.StateModel _stateModel
           
 
Fields inherited from class diva.graph.AbstractGraphModel
_graphListeners
 
Constructor Summary
FSMGraphModel(CompositeEntity composite)
          Construct a new graph model whose root is the given composite entity.
 
Method Summary
protected  boolean _update()
          Update the graph model.
private  void _updateLinks(ComponentRelation relation)
           
 void disconnectEdge(java.lang.Object eventSource, java.lang.Object edge)
          Disconnect an edge from its two endpoints and notify graph listeners with an EDGE_HEAD_CHANGED and an EDGE_TAIL_CHANGED event whose source is the given source.
 FSMGraphModel.ArcModel getArcModel()
          Get the arc model.
 java.lang.String getDeleteEdgeMoML(java.lang.Object edge)
          Return a MoML String that will delete the given edge from the Ptolemy model.
 java.lang.String getDeleteNodeMoML(java.lang.Object node)
          Return a MoML String that will delete the given node from the Ptolemy model.
 EdgeModel getEdgeModel(java.lang.Object edge)
          Return the model for the given edge object.
 NodeModel getNodeModel(java.lang.Object node)
          Return the node model for the given object.
 FSMGraphModel.PortModel getPortModel()
          Get the port model.
 java.lang.Object getSemanticObject(java.lang.Object element)
          Return the semantic object corresponding to the given node, edge, or composite.
 FSMGraphModel.StateModel getStateModel()
          Get the state model.
 void removeNode(java.lang.Object eventSource, java.lang.Object node)
          Delete a node from its parent graph and notify graph listeners with a NODE_REMOVED event.
 
Methods inherited from class ptolemy.vergil.basic.AbstractBasicGraphModel
_getLocation, changeExecuted, changeFailed, getCompositeModel, getProperty, getPtolemyModel, isNode, removeListeners, setProperty, setSemanticObject
 
Methods inherited from class diva.graph.modular.ModularGraphModel
containsNode, getHead, getNodeCount, getParent, getRoot, getTail, inEdges, isComposite, isDirected, isEdge, nodes, nodesAfterEdges, nodesBeforeEdges, outEdges
 
Methods inherited from class diva.graph.AbstractGraphModel
addGraphListener, dispatchGraphEvent, removeGraphListener, setDispatchEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_linkSet

private java.util.Set _linkSet

_arcModel

private FSMGraphModel.ArcModel _arcModel

_portModel

private FSMGraphModel.PortModel _portModel

_stateModel

private FSMGraphModel.StateModel _stateModel
Constructor Detail

FSMGraphModel

public FSMGraphModel(CompositeEntity composite)
Construct a new graph model whose root is the given composite entity.

Parameters:
composite - The top-level composite entity for the model.
Method Detail

disconnectEdge

public void disconnectEdge(java.lang.Object eventSource,
                           java.lang.Object edge)
Disconnect an edge from its two endpoints and notify graph listeners with an EDGE_HEAD_CHANGED and an EDGE_TAIL_CHANGED event whose source is the given source.

Specified by:
disconnectEdge in class AbstractBasicGraphModel
Parameters:
eventSource - The source of the event that will be dispatched, e.g. the view that made this call.
edge - The edge.

getDeleteEdgeMoML

public java.lang.String getDeleteEdgeMoML(java.lang.Object edge)
Return a MoML String that will delete the given edge from the Ptolemy model.

Specified by:
getDeleteEdgeMoML in class AbstractBasicGraphModel
Parameters:
edge - The edge.
Returns:
A valid MoML string.

getDeleteNodeMoML

public java.lang.String getDeleteNodeMoML(java.lang.Object node)
Return a MoML String that will delete the given node from the Ptolemy model.

Specified by:
getDeleteNodeMoML in class AbstractBasicGraphModel
Parameters:
node - The node.
Returns:
A valid MoML string.

getEdgeModel

public EdgeModel getEdgeModel(java.lang.Object edge)
Return the model for the given edge object. If the object is not an edge, then return null.

Specified by:
getEdgeModel in class ModularGraphModel
Parameters:
edge - An object which is assumed to be in this graph model.
Returns:
An instance of ArcModel if the object is an Arc. Otherwise return null.

getNodeModel

public NodeModel getNodeModel(java.lang.Object node)
Return the node model for the given object. If the object is not a node, then return null.

Overrides:
getNodeModel in class AbstractBasicGraphModel
Parameters:
node - An object which is assumed to be in this graph model.
Returns:
The node model for the specified node, or null if there is none.

getSemanticObject

public java.lang.Object getSemanticObject(java.lang.Object element)
Return the semantic object corresponding to the given node, edge, or composite. A "semantic object" is an object associated with a node in the graph. In this case, if the node is icon, the semantic object is the entity containing the icon. If it is an arc, then the semantic object is the arc's relation.

Specified by:
getSemanticObject in interface GraphModel
Overrides:
getSemanticObject in class AbstractBasicGraphModel
Parameters:
element - A graph element.
Returns:
The semantic object associated with this element, or null if the object is not recognized.
See Also:
AbstractBasicGraphModel.setSemanticObject(Object, Object)

removeNode

public void removeNode(java.lang.Object eventSource,
                       java.lang.Object node)
Delete a node from its parent graph and notify graph listeners with a NODE_REMOVED event.

Specified by:
removeNode in class AbstractBasicGraphModel
Parameters:
eventSource - The source of the event that will be dispatched, e.g. the view that made this call.
node - The node to be removed.

getPortModel

public FSMGraphModel.PortModel getPortModel()
Get the port model.

Returns:
The port model.

getStateModel

public FSMGraphModel.StateModel getStateModel()
Get the state model.

Returns:
The state model.

getArcModel

public FSMGraphModel.ArcModel getArcModel()
Get the arc model.

Returns:
The acr model.

_update

protected boolean _update()
Update the graph model. This is called whenever a change request is executed. In this class the internal set of link objects is verified to be correct.

Overrides:
_update in class AbstractBasicGraphModel
Returns:
True if the graph model changes (always true in this base class).

_updateLinks

private void _updateLinks(ComponentRelation relation)