org.tigris.gef.graph
Class MutableGraphSupport

java.lang.Object
  extended byorg.tigris.gef.graph.MutableGraphSupport
All Implemented Interfaces:
BaseGraphModel, GraphModel, MutableGraphModel, java.io.Serializable
Direct Known Subclasses:
AdjacencyListGraphModel, DefaultGraphModel

public abstract class MutableGraphSupport
extends java.lang.Object
implements MutableGraphModel, java.io.Serializable

An abstract class that makes it easier to implement your own version of MutableGraphModel. This class basically includes the code for event notifications, so that you don't have to write that. It also provides a few utility methods.

See Also:
AdjacencyListGraphModel, Serialized Form

Field Summary
protected  java.util.Vector _graphListeners
          Deprecated. 0.11, visibility will change use getGraphListeners and setGraphListeners instead
 
Constructor Summary
MutableGraphSupport()
           
 
Method Summary
 void addGraphEventListener(GraphListener listener)
           
 boolean canChangeConnectedNode(java.lang.Object newNode, java.lang.Object oldNode, java.lang.Object edge)
          Return true if the connection to the old node can be rerouted to the new node.
 boolean canConnect(java.lang.Object fromPort, java.lang.Object toPort, java.lang.Class edgeClass)
          Return true if the two given ports can be connected by the given kind of edge.
 boolean canDragNode(java.lang.Object node)
          Return true if the type of the given node can be mapped to a type supported by this type of diagram
 void changeConnectedNode(java.lang.Object newNode, java.lang.Object oldNode, java.lang.Object edge, boolean isSource)
          Reroutes the connection to the old node to be connected to the new node.
 java.lang.Object connect(java.lang.Object fromPort, java.lang.Object toPort, java.lang.Class edgeClass)
          Contruct and add a new edge of the given kind.
 boolean containsEdge(java.lang.Object edge)
          Return true if the given object is present as a edge in the graph
 boolean containsEdgePort(java.lang.Object port)
           
 boolean containsNode(java.lang.Object node)
          Return true if the given object is present as a node in the graph
 boolean containsNodePort(java.lang.Object port)
           
 boolean containsPort(java.lang.Object port)
           
 java.lang.Object createNode(java.lang.String name, java.util.Hashtable args)
          Return a valid node in this graph
 void dragNode(java.lang.Object node)
          Create a new node based on the given one and add it to the graph.
 void fireEdgeAdded(java.lang.Object edge)
           
 void fireEdgeRemoved(java.lang.Object edge)
           
 void fireGraphChanged()
           
 void fireNodeAdded(java.lang.Object node)
           
 void fireNodeRemoved(java.lang.Object node)
           
 java.util.Vector getGraphListeners()
           
 void removeGraphEventListener(GraphListener listener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.tigris.gef.graph.MutableGraphModel
addEdge, addNode, addNodeRelatedEdges, canAddEdge, canAddNode, canConnect, connect, removeEdge, removeNode
 
Methods inherited from interface org.tigris.gef.graph.GraphModel
getEdges, getInEdges, getNodes, getOutEdges, getPorts
 
Methods inherited from interface org.tigris.gef.graph.BaseGraphModel
getDestPort, getOwner, getSourcePort
 

Field Detail

_graphListeners

protected java.util.Vector _graphListeners
Deprecated. 0.11, visibility will change use getGraphListeners and setGraphListeners instead

Constructor Detail

MutableGraphSupport

public MutableGraphSupport()
Method Detail

getGraphListeners

public java.util.Vector getGraphListeners()

createNode

public java.lang.Object createNode(java.lang.String name,
                                   java.util.Hashtable args)
Return a valid node in this graph

Specified by:
createNode in interface MutableGraphModel

canDragNode

public boolean canDragNode(java.lang.Object node)
Return true if the type of the given node can be mapped to a type supported by this type of diagram

Specified by:
canDragNode in interface MutableGraphModel

dragNode

public void dragNode(java.lang.Object node)
Create a new node based on the given one and add it to the graph.

Specified by:
dragNode in interface MutableGraphModel

canChangeConnectedNode

public boolean canChangeConnectedNode(java.lang.Object newNode,
                                      java.lang.Object oldNode,
                                      java.lang.Object edge)
Return true if the connection to the old node can be rerouted to the new node.

Specified by:
canChangeConnectedNode in interface MutableGraphModel

canConnect

public boolean canConnect(java.lang.Object fromPort,
                          java.lang.Object toPort,
                          java.lang.Class edgeClass)
Return true if the two given ports can be connected by the given kind of edge. By default ignore edgeClass and call canConnect(port,port).

Specified by:
canConnect in interface MutableGraphModel

changeConnectedNode

public void changeConnectedNode(java.lang.Object newNode,
                                java.lang.Object oldNode,
                                java.lang.Object edge,
                                boolean isSource)
Reroutes the connection to the old node to be connected to the new node.

Specified by:
changeConnectedNode in interface MutableGraphModel

connect

public java.lang.Object connect(java.lang.Object fromPort,
                                java.lang.Object toPort,
                                java.lang.Class edgeClass)
Contruct and add a new edge of the given kind. By default ignore edgeClass and call connect(port,port).

Specified by:
connect in interface MutableGraphModel

containsNode

public boolean containsNode(java.lang.Object node)
Description copied from interface: MutableGraphModel
Return true if the given object is present as a node in the graph

Specified by:
containsNode in interface MutableGraphModel

containsEdge

public boolean containsEdge(java.lang.Object edge)
Description copied from interface: MutableGraphModel
Return true if the given object is present as a edge in the graph

Specified by:
containsEdge in interface MutableGraphModel

containsNodePort

public boolean containsNodePort(java.lang.Object port)

containsEdgePort

public boolean containsEdgePort(java.lang.Object port)

containsPort

public boolean containsPort(java.lang.Object port)

addGraphEventListener

public void addGraphEventListener(GraphListener listener)
Specified by:
addGraphEventListener in interface BaseGraphModel

removeGraphEventListener

public void removeGraphEventListener(GraphListener listener)
Specified by:
removeGraphEventListener in interface BaseGraphModel

fireNodeAdded

public void fireNodeAdded(java.lang.Object node)

fireNodeRemoved

public void fireNodeRemoved(java.lang.Object node)

fireEdgeAdded

public void fireEdgeAdded(java.lang.Object edge)

fireEdgeRemoved

public void fireEdgeRemoved(java.lang.Object edge)

fireGraphChanged

public void fireGraphChanged()