Package ptolemy.vergil.ontologies
Class OntologyGraphModel
- java.lang.Object
-
- diva.graph.AbstractGraphModel
-
- diva.graph.modular.ModularGraphModel
-
- ptolemy.vergil.basic.AbstractBasicGraphModel
-
- ptolemy.vergil.ontologies.OntologyGraphModel
-
- All Implemented Interfaces:
GraphModel
,ChangeListener
public class OntologyGraphModel extends AbstractBasicGraphModel
A graph model for graphically manipulating ontology models. Most of this code is duplicated fromFSMGraphModel
but many features of the Modal Model editors are not used, so it doesn't make sense to inherit directly from that class.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Charles Shelton, Edward A. Lee
- Pt.AcceptedRating:
- Red (cshelton)
- Pt.ProposedRating:
- Red (cshelton)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
OntologyGraphModel.ConceptModel
The model for an icon that represents concepts in the ontology model.class
OntologyGraphModel.RelationModel
The model for relations between concepts in the ontology.
-
Field Summary
-
Fields inherited from class diva.graph.AbstractGraphModel
_graphListeners
-
-
Constructor Summary
Constructors Constructor Description OntologyGraphModel(CompositeEntity composite)
Construct a new graph model whose root is the given composite entity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
_update()
Update the graph model.void
disconnectEdge(java.lang.Object eventSource, java.lang.Object edge)
Disconnect an edge (aLink
object which contains aConceptRelation
in the ontology model) 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.OntologyGraphModel.ConceptModel
getConceptModel()
Get the concept model which maps all nodes in the graph to theConcept
elements in the ontology 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.OntologyGraphModel.RelationModel
getRelationModel()
Get the relation model.java.lang.Object
getSemanticObject(java.lang.Object element)
Return the semantic object corresponding to the given node, edge, or composite.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
-
-
-
-
Constructor Detail
-
OntologyGraphModel
public OntologyGraphModel(CompositeEntity composite)
Construct a new graph model whose root is the given composite entity. This should always be anOntology
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 (aLink
object which contains aConceptRelation
in the ontology model) 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 classAbstractBasicGraphModel
- Parameters:
eventSource
- The source of the event that will be dispatched, e.g. the view that made this call.edge
- The edge to be disconnected.
-
getConceptModel
public OntologyGraphModel.ConceptModel getConceptModel()
Get the concept model which maps all nodes in the graph to theConcept
elements in the ontology model.- Returns:
- The concept model.
-
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 classAbstractBasicGraphModel
- 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 classAbstractBasicGraphModel
- 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 classModularGraphModel
- Parameters:
edge
- An object which is assumed to be in this graph model.- Returns:
- An instance of RelationModel if the object is a Link. 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. The nodes in an ontology model should be eitherConcepts
or Ptolemy annotationTextAttributes
.- Overrides:
getNodeModel
in classAbstractBasicGraphModel
- 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.
-
getRelationModel
public OntologyGraphModel.RelationModel getRelationModel()
Get the relation model. The only relations represented in the ontology should beConceptRelations
.- Returns:
- The relation model.
-
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. If the argument is an instance of Locatable, then return the container of the Locatable, which should be a Concept or Attribute in the ontology. If it is a Link, then the semantic object is the link's ConceptRelation.- Specified by:
getSemanticObject
in interfaceGraphModel
- Overrides:
getSemanticObject
in classAbstractBasicGraphModel
- 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 classAbstractBasicGraphModel
- 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.
-
_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 classAbstractBasicGraphModel
- Returns:
- True if the model was successfully updated, or false if further change requests were queued.
-
-