public abstract class AbstractBasicGraphModel extends ModularGraphModel implements ChangeListener
This class uses a change listener to detect changes to the Ptolemy model that do not originate from this class. These changes are propagated as structure changed graph events to all graphListeners registered with this model. This mechanism allows a graph visualization of a ptolemy model to remain synchronized with the state of a mutating model.
Red (johnr) |
Yellow (neuendor) |
_graphListeners
Constructor and Description |
---|
AbstractBasicGraphModel(NamedObj composite)
Create a graph model for the specified Ptolemy II model.
|
Modifier and Type | Method and Description |
---|---|
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.
|
protected boolean |
_update()
Update the graph model.
|
void |
changeExecuted(ChangeRequest change)
Notify the listener that a change has been successfully executed.
|
void |
changeFailed(ChangeRequest change,
java.lang.Exception exception)
Notify the listener that the change has failed with the
specified exception.
|
abstract 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.
|
CompositeModel |
getCompositeModel(java.lang.Object composite)
Return the model for the given composite object.
|
abstract java.lang.String |
getDeleteEdgeMoML(java.lang.Object edge)
Return a MoML String that will delete the given edge from the
Ptolemy model.
|
abstract java.lang.String |
getDeleteNodeMoML(java.lang.Object node)
Return a MoML String that will delete the given node from the
Ptolemy model.
|
NodeModel |
getNodeModel(java.lang.Object node)
Return the node model for the given object.
|
java.lang.Object |
getProperty(java.lang.Object object,
java.lang.String propertyName)
Return the property of the object associated with
the given property name.
|
NamedObj |
getPtolemyModel()
Return the Ptolemy II model associated with this graph model.
|
java.lang.Object |
getSemanticObject(java.lang.Object element)
Return the semantic object corresponding to the given node, edge,
or composite.
|
boolean |
isNode(java.lang.Object object)
Return true if the given object is a
node in this model, which in this case means
that it is an instance of Locatable.
|
void |
removeListeners()
Remove any listeners we have created.
|
abstract 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.
|
void |
setProperty(java.lang.Object object,
java.lang.String propertyName,
java.lang.Object value)
Set the property of the given graph object associated with
the given property name to the given value.
|
void |
setSemanticObject(java.lang.Object object,
java.lang.Object semantic)
Set the semantic object corresponding to the given node, edge,
or composite.
|
containsNode, getEdgeModel, getHead, getNodeCount, getParent, getRoot, getTail, inEdges, isComposite, isDirected, isEdge, nodes, nodesAfterEdges, nodesBeforeEdges, outEdges
addGraphListener, dispatchGraphEvent, removeGraphListener, setDispatchEnabled
public AbstractBasicGraphModel(NamedObj composite)
composite
- The Ptolemy II model.public void changeExecuted(ChangeRequest change)
changeExecuted
in interface ChangeListener
change
- The change that has been executed.public void changeFailed(ChangeRequest change, java.lang.Exception exception)
changeFailed
in interface ChangeListener
change
- The change that has failed.exception
- The exception that was thrown.public abstract void disconnectEdge(java.lang.Object eventSource, java.lang.Object edge)
eventSource
- The source of the event that will be dispatched,
e.g. the view that made this call.edge
- The edge that is to be disconnected.public abstract java.lang.String getDeleteEdgeMoML(java.lang.Object edge)
edge
- The edge that is to be disconnected.public abstract java.lang.String getDeleteNodeMoML(java.lang.Object node)
node
- The edge that is to be disconnected.public CompositeModel getCompositeModel(java.lang.Object composite)
getCompositeModel
in class ModularGraphModel
composite
- A composite object.public NodeModel getNodeModel(java.lang.Object node)
getNodeModel
in class ModularGraphModel
node
- An object which is assumed to be in this graph model.public java.lang.Object getProperty(java.lang.Object object, java.lang.String propertyName)
getProperty
in interface GraphModel
getProperty
in class ModularGraphModel
object
- The graph object, which is assumed to be an instance of
NamedObj.propertyName
- The name of the new property.setProperty(Object, String, Object)
public NamedObj getPtolemyModel()
public java.lang.Object getSemanticObject(java.lang.Object element)
getSemanticObject
in interface GraphModel
getSemanticObject
in class ModularGraphModel
element
- A graph element.setSemanticObject(Object, Object)
public boolean isNode(java.lang.Object object)
isNode
in interface GraphModel
isNode
in class ModularGraphModel
object
- The object to test for being a node
(vs. an edge).public abstract void removeNode(java.lang.Object eventSource, java.lang.Object node)
eventSource
- The source of the event that will be dispatched,
e.g. the view that made this call.node
- The node to be removed.public void setProperty(java.lang.Object object, java.lang.String propertyName, java.lang.Object value)
setProperty
in interface GraphModel
setProperty
in class ModularGraphModel
object
- The graph object.propertyName
- The property name.value
- The new value of the property.getProperty(Object, String)
public void setSemanticObject(java.lang.Object object, java.lang.Object semantic)
setSemanticObject
in interface GraphModel
setSemanticObject
in class ModularGraphModel
object
- The graph object that represents a node or an edge.semantic
- The semantic object to associate with the given
graph object.getSemanticObject(Object)
public void removeListeners()
protected Locatable _getLocation(NamedObj object)
object
- The object for which a location is needed.protected boolean _update()