Package diva.graph.modular
Class MutableModularGraphModel
- java.lang.Object
-
- diva.graph.AbstractGraphModel
-
- diva.graph.modular.ModularGraphModel
-
- diva.graph.modular.MutableModularGraphModel
-
- All Implemented Interfaces:
GraphModel,MutableGraphModel
- Direct Known Subclasses:
BasicModularGraphModel
public abstract class MutableModularGraphModel extends ModularGraphModel implements MutableGraphModel
A modular implementation of the graph model, whereby users with heterogeneous graphs can implement the graph model interface by implementing the simple interfaces of Graph, Node, CompositeNode, and Edge.- Version:
- $Id$
- Author:
- Michael Shilman
- Pt.AcceptedRating:
- Red
-
-
Field Summary
-
Fields inherited from class diva.graph.AbstractGraphModel
_graphListeners
-
-
Constructor Summary
Constructors Constructor Description MutableModularGraphModel(java.lang.Object root)Construct an empty graph model whose root is the given semantic object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanacceptHead(java.lang.Object edge, java.lang.Object node)Return true if the head of the given edge can be attached to the given node.booleanacceptTail(java.lang.Object edge, java.lang.Object node)Return true if the tail of the given edge can be attached to the given node.voidaddNode(java.lang.Object eventSource, java.lang.Object node, java.lang.Object parent)Add a node to the given graph and notify listeners with a NODE_ADDED event.voidconnectEdge(java.lang.Object eventSource, java.lang.Object edge, java.lang.Object tailNode, java.lang.Object headNode)Connect the given edge to the given tail and head nodes, then dispatch events to the listeners.voiddisconnectEdge(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.MutableEdgeModelgetMutableEdgeModel(java.lang.Object edge)Return the model for the given edge object, cast as a MutableEdgeModel.MutableNodeModelgetMutableNodeModel(java.lang.Object node)Return the node model for the given object, cast as a MutableNodeModel.voidremoveNode(java.lang.Object eventSource, java.lang.Object node)Delete a node from its parent graph and notify graph listeners with a NODE_REMOVED event.voidsetEdgeHead(java.lang.Object eventSource, java.lang.Object edge, java.lang.Object head)Connect an edge to the given head node and notify listeners with an EDGE_HEAD_CHANGED event.voidsetEdgeTail(java.lang.Object eventSource, java.lang.Object edge, java.lang.Object tail)Connect an edge to the given tail node and notify listeners with an EDGE_TAIL_CHANGED event.-
Methods inherited from class diva.graph.modular.ModularGraphModel
containsNode, getCompositeModel, getEdgeModel, getHead, getNodeCount, getNodeModel, getParent, getProperty, getRoot, getSemanticObject, getTail, inEdges, isComposite, isDirected, isEdge, isNode, nodes, nodesAfterEdges, nodesBeforeEdges, outEdges, setProperty, setSemanticObject
-
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
-
Methods inherited from interface diva.graph.GraphModel
addGraphListener, containsNode, dispatchGraphEvent, getHead, getNodeCount, getParent, getProperty, getRoot, getSemanticObject, getTail, inEdges, isComposite, isDirected, isEdge, isNode, nodes, nodesAfterEdges, nodesBeforeEdges, outEdges, removeGraphListener, setDispatchEnabled, setProperty, setSemanticObject
-
-
-
-
Method Detail
-
acceptHead
public boolean acceptHead(java.lang.Object edge, java.lang.Object node)Return true if the head of the given edge can be attached to the given node.- Specified by:
acceptHeadin interfaceMutableGraphModel
-
acceptTail
public boolean acceptTail(java.lang.Object edge, java.lang.Object node)Return true if the tail of the given edge can be attached to the given node.- Specified by:
acceptTailin interfaceMutableGraphModel
-
addNode
public void addNode(java.lang.Object eventSource, java.lang.Object node, java.lang.Object parent)Add a node to the given graph and notify listeners with a NODE_ADDED event.- Specified by:
addNodein interfaceMutableGraphModel- Parameters:
eventSource- The source of the event that will be dispatched, e.g. the view that made this call.
-
connectEdge
public void connectEdge(java.lang.Object eventSource, java.lang.Object edge, java.lang.Object tailNode, java.lang.Object headNode)Connect the given edge to the given tail and head nodes, then dispatch events to the listeners.- Specified by:
connectEdgein interfaceMutableGraphModel- Parameters:
eventSource- The source of the event that will be dispatched, e.g. the view that made this call.
-
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.- Specified by:
disconnectEdgein interfaceMutableGraphModel- Parameters:
eventSource- The source of the event that will be dispatched, e.g. the view that made this call.
-
getMutableEdgeModel
public MutableEdgeModel getMutableEdgeModel(java.lang.Object edge)
Return the model for the given edge object, cast as a MutableEdgeModel. If the object is not an edge, then return null. This method assumes that the edge model for the given edge is mutable.
-
getMutableNodeModel
public MutableNodeModel getMutableNodeModel(java.lang.Object node)
Return the node model for the given object, cast as a MutableNodeModel. If the object is not a node, then return null. This method assumes that the edge model for the given edge is mutable.
-
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. This first removes all the edges that are connected to the given node, or some subnode of that node, and then sets the parent of the node to null.- Specified by:
removeNodein interfaceMutableGraphModel- Parameters:
eventSource- The source of the event that will be dispatched, e.g. the view that made this call.
-
setEdgeHead
public void setEdgeHead(java.lang.Object eventSource, java.lang.Object edge, java.lang.Object head)Connect an edge to the given head node and notify listeners with an EDGE_HEAD_CHANGED event.- Specified by:
setEdgeHeadin interfaceMutableGraphModel- Parameters:
eventSource- The source of the event that will be dispatched, e.g. the view that made this call.
-
setEdgeTail
public void setEdgeTail(java.lang.Object eventSource, java.lang.Object edge, java.lang.Object tail)Connect an edge to the given tail node and notify listeners with an EDGE_TAIL_CHANGED event.- Specified by:
setEdgeTailin interfaceMutableGraphModel- Parameters:
eventSource- The source of the event that will be dispatched, e.g. the view that made this call.
-
-