org.tigris.gef.graph.presentation
Class DefaultGraphModel

java.lang.Object
  extended by org.tigris.gef.graph.MutableGraphSupport
      extended by org.tigris.gef.graph.presentation.DefaultGraphModel
All Implemented Interfaces:
java.io.Serializable, BaseGraphModel, GraphModel, MutableGraphModel

public class DefaultGraphModel
extends MutableGraphSupport
implements java.io.Serializable

This interface provides a facade to a net-level representation. Similiar in concept to the Swing class TreeModel. This implementation of GraphModel uses the GEF classes NetList, NetNode, NetPort, and NetEdge. If you implement your own GraphModel, you can use your own application-specific classes.

See Also:
NetList, NetNode, NetPort, NetEdge, AdjacencyListGraphModel, Serialized Form

Constructor Summary
DefaultGraphModel()
           
DefaultGraphModel(ConnectionConstrainer cc)
           
DefaultGraphModel(NetList nl)
           
 
Method Summary
 void addEdge(java.lang.Object edge)
          Add the given edge to the graph, if valid.
 void addNode(java.lang.Object node)
          Add the given node to the graph, if valid.
 void addNodeRelatedEdges(java.lang.Object node)
          Add existing edges that are related to the node.
 boolean canAddEdge(java.lang.Object edge)
          Return true if the given object is a valid edge in this graph
 boolean canAddNode(java.lang.Object node)
          Return true if the given object is a valid node in this graph
 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 srcPort, java.lang.Object destPort)
          Return true if the two given ports can be connected by a kind of edge to be determined by the ports.
 boolean canDragNode(java.lang.Object node)
          Return true if dragging the given object is a valid in this graph
 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 srcPort, java.lang.Object destPort)
          Contruct and add a new edge of a kind determined by the ports
 java.lang.Object connect(java.lang.Object srcPort, java.lang.Object destPort, java.lang.Class edgeClass)
          Contruct and add a new edge of the given kind
 java.lang.Object connect(java.lang.Object srcPort, java.lang.Object destPort, java.lang.Object edgeType)
          Contruct and add a new edge of the given kind The default is to assume the edge type is a Class.
protected  java.lang.Object connectInternal(NetPort s, NetPort d, NetEdge e)
          Asks the given edge to attempt to connect itself to the given ports.
 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.
 java.lang.Object getDestPort(java.lang.Object edge)
          Return the other end of an edge
 java.util.List getEdges()
          Return all edges in the graph
 java.util.Collection getEdges(java.util.Collection c)
          Return all nodes in the graph
 java.util.List getInEdges(java.lang.Object port)
          Return all edges going to given port
 java.util.List getNodes()
          Return all nodes in the graph
 java.util.Collection getNodes(java.util.Collection c)
          Return all nodes in the graph
 java.util.List getOutEdges(java.lang.Object port)
          Return all edges going from given port
 java.lang.Object getOwner(java.lang.Object port)
          Return the node or edge that owns the given port
 java.util.Collection getPorts(java.util.Collection c, java.lang.Object nodeOrEdge)
          Return all ports on node or edge
 java.util.List getPorts(java.lang.Object nodeOrEdge)
          Return all ports on node or edge
 java.lang.Object getSourcePort(java.lang.Object edge)
          Return one end of an edge
 void removeAll()
          Remove all nodes and edges to reset the graph.
 void removeAllEdges()
          Remove all the edges from the graph.
 void removeAllNodes()
          Remove all the nodes from the graph.
 void removeEdge(java.lang.Object edge)
          Remove the given edge from the graph.
 void removeNode(java.lang.Object node)
          Remove the given node from the graph.
 
Methods inherited from class org.tigris.gef.graph.MutableGraphSupport
addGraphEventListener, canConnect, canConnect, connect, containsEdge, containsEdgePort, containsNode, containsNodePort, containsPort, fireEdgeAdded, fireEdgeRemoved, fireGraphChanged, fireNodeAdded, fireNodeRemoved, getConnectionConstrainer, getGraphListeners, isEnclosable, removeFig, removeGraphEventListener, setConnectionConstrainer, setSaveAction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultGraphModel

public DefaultGraphModel()

DefaultGraphModel

public DefaultGraphModel(ConnectionConstrainer cc)

DefaultGraphModel

public DefaultGraphModel(NetList nl)
Method Detail

getNodes

public java.util.List getNodes()
Return all nodes in the graph

Specified by:
getNodes in interface GraphModel

getEdges

public java.util.List getEdges()
Return all edges in the graph

Specified by:
getEdges in interface GraphModel

getPorts

public java.util.List getPorts(java.lang.Object nodeOrEdge)
Return all ports on node or edge

Specified by:
getPorts in interface GraphModel

getNodes

public java.util.Collection getNodes(java.util.Collection c)
Return all nodes in the graph


getEdges

public java.util.Collection getEdges(java.util.Collection c)
Return all nodes in the graph


getPorts

public java.util.Collection getPorts(java.util.Collection c,
                                     java.lang.Object nodeOrEdge)
Return all ports on node or edge


getOwner

public java.lang.Object getOwner(java.lang.Object port)
Return the node or edge that owns the given port

Specified by:
getOwner in interface BaseGraphModel

getInEdges

public java.util.List getInEdges(java.lang.Object port)
Return all edges going to given port

Specified by:
getInEdges in interface GraphModel

getOutEdges

public java.util.List getOutEdges(java.lang.Object port)
Return all edges going from given port

Specified by:
getOutEdges in interface GraphModel

getSourcePort

public java.lang.Object getSourcePort(java.lang.Object edge)
Return one end of an edge

Specified by:
getSourcePort in interface BaseGraphModel

getDestPort

public java.lang.Object getDestPort(java.lang.Object edge)
Return the other end of an edge

Specified by:
getDestPort in interface BaseGraphModel

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
Overrides:
createNode in class MutableGraphSupport

canAddNode

public boolean canAddNode(java.lang.Object node)
Return true if the given object is a valid node in this graph

Specified by:
canAddNode in interface MutableGraphModel

canAddEdge

public boolean canAddEdge(java.lang.Object edge)
Return true if the given object is a valid edge in this graph

Specified by:
canAddEdge in interface MutableGraphModel

removeNode

public void removeNode(java.lang.Object node)
Remove the given node from the graph.

Specified by:
removeNode in interface MutableGraphModel
Overrides:
removeNode in class MutableGraphSupport

canDragNode

public boolean canDragNode(java.lang.Object node)
Return true if dragging the given object is a valid in this graph

Specified by:
canDragNode in interface MutableGraphModel
Overrides:
canDragNode in class MutableGraphSupport

addNode

public void addNode(java.lang.Object node)
Add the given node to the graph, if valid.

Specified by:
addNode in interface MutableGraphModel
Overrides:
addNode in class MutableGraphSupport

addEdge

public void addEdge(java.lang.Object edge)
Add the given edge to the graph, if valid.

Specified by:
addEdge in interface MutableGraphModel
Overrides:
addEdge in class MutableGraphSupport

addNodeRelatedEdges

public void addNodeRelatedEdges(java.lang.Object node)
Description copied from interface: MutableGraphModel
Add existing edges that are related to the node.

Specified by:
addNodeRelatedEdges in interface MutableGraphModel

removeEdge

public void removeEdge(java.lang.Object edge)
Remove the given edge from the graph.

Specified by:
removeEdge in interface MutableGraphModel
Overrides:
removeEdge in class MutableGraphSupport

removeAllNodes

public void removeAllNodes()
Remove all the nodes from the graph.

Overrides:
removeAllNodes in class MutableGraphSupport

removeAllEdges

public void removeAllEdges()
Remove all the edges from the graph.

Overrides:
removeAllEdges in class MutableGraphSupport

removeAll

public void removeAll()
Remove all nodes and edges to reset the graph.

Overrides:
removeAll in class MutableGraphSupport

dragNode

public void dragNode(java.lang.Object node)
Description copied from class: MutableGraphSupport
Create a new node based on the given one and add it to the graph.

Specified by:
dragNode in interface MutableGraphModel
Overrides:
dragNode in class MutableGraphSupport

canConnect

public boolean canConnect(java.lang.Object srcPort,
                          java.lang.Object destPort)
Return true if the two given ports can be connected by a kind of edge to be determined by the ports.

Specified by:
canConnect in interface MutableGraphModel

connect

public java.lang.Object connect(java.lang.Object srcPort,
                                java.lang.Object destPort)
Contruct and add a new edge of a kind determined by the ports

Specified by:
connect in interface MutableGraphModel

connect

public java.lang.Object connect(java.lang.Object srcPort,
                                java.lang.Object destPort,
                                java.lang.Object edgeType)
Contruct and add a new edge of the given kind The default is to assume the edge type is a Class.

Specified by:
connect in interface MutableGraphModel
Overrides:
connect in class MutableGraphSupport

connect

public java.lang.Object connect(java.lang.Object srcPort,
                                java.lang.Object destPort,
                                java.lang.Class edgeClass)
Contruct and add a new edge of the given kind

Specified by:
connect in interface MutableGraphModel

connectInternal

protected java.lang.Object connectInternal(NetPort s,
                                           NetPort d,
                                           NetEdge e)
Asks the given edge to attempt to connect itself to the given ports.

Parameters:
s - source port
d - destination port
e - edge
Returns:
the edge or null if the edge rejects the connection.

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
Overrides:
canChangeConnectedNode in class MutableGraphSupport

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
Overrides:
changeConnectedNode in class MutableGraphSupport