org.tigris.gef.graph.presentation
Class AdjacencyListGraphModel

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

public abstract class AdjacencyListGraphModel
extends MutableGraphSupport
implements java.io.Serializable

This class is an example of an alternative way to implement MutableGraphModel. Needs-more-work: this code has not been used or tested.

See Also:
DefaultGraphModel, Serialized Form

Field Summary
protected  java.util.Vector _edges
           
protected  java.util.Vector _nodes
           
static java.lang.String UNLABELED
           
 
Constructor Summary
AdjacencyListGraphModel()
           
 
Method Summary
 void addEdge(java.lang.Object edge)
          Add the given edge to the graph, if valid.
 java.lang.Object addLabeledEdge(java.lang.Object srcPort, java.lang.Object destPort, java.lang.Object label)
           
 void addNode(java.lang.Object node)
          Add the given node to the graph, if valid.
 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 canConnect(java.lang.Object srcNode, java.lang.Object destNode)
          Return true if the two given ports can be connected by a kind of edge to be determined by the ports.
 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 getDestPort(java.lang.Object edge)
          Return the other end of an edge
 java.lang.Object getEdgeLabel(java.lang.Object edge)
           
 java.util.List getEdges()
          Return all nodes in the graph
 java.util.Vector getEdgesLabeled(java.lang.Object label)
           
 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.List getOutEdges(java.lang.Object port)
          Return all edges going from given port
abstract  java.lang.Object getOwner(java.lang.Object port)
          Return the node or edge that owns the given port
abstract  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
 boolean OK()
           
 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, canChangeConnectedNode, canConnect, canConnect, canDragNode, changeConnectedNode, connect, connect, containsEdge, containsEdgePort, containsNode, containsNodePort, containsPort, createNode, dragNode, fireEdgeAdded, fireEdgeRemoved, fireGraphChanged, fireNodeAdded, fireNodeRemoved, getConnectionConstrainer, getGraphListeners, isEnclosable, removeAll, removeAllEdges, removeAllNodes, removeFig, removeGraphEventListener, setConnectionConstrainer, setSaveAction
 
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
addNodeRelatedEdges, connect
 

Field Detail

UNLABELED

public static java.lang.String UNLABELED

_nodes

protected java.util.Vector _nodes

_edges

protected java.util.Vector _edges
Constructor Detail

AdjacencyListGraphModel

public AdjacencyListGraphModel()
Method Detail

OK

public boolean OK()

getNodes

public java.util.List getNodes()
Description copied from interface: GraphModel
Return all nodes in the graph

Specified by:
getNodes in interface GraphModel

getEdges

public java.util.List getEdges()
Description copied from interface: GraphModel
Return all nodes in the graph

Specified by:
getEdges in interface GraphModel

getPorts

public abstract java.util.List getPorts(java.lang.Object nodeOrEdge)
Description copied from interface: GraphModel
Return all ports on node or edge

Specified by:
getPorts in interface GraphModel

getOwner

public abstract java.lang.Object getOwner(java.lang.Object port)
Description copied from interface: BaseGraphModel
Return the node or edge that owns the given port

Specified by:
getOwner in interface BaseGraphModel

getSourcePort

public java.lang.Object getSourcePort(java.lang.Object edge)
Description copied from interface: BaseGraphModel
Return one end of an edge

Specified by:
getSourcePort in interface BaseGraphModel

getDestPort

public java.lang.Object getDestPort(java.lang.Object edge)
Description copied from interface: BaseGraphModel
Return the other end of an edge

Specified by:
getDestPort in interface BaseGraphModel

getInEdges

public java.util.List getInEdges(java.lang.Object port)
Description copied from interface: GraphModel
Return all edges going to given port

Specified by:
getInEdges in interface GraphModel

getOutEdges

public java.util.List getOutEdges(java.lang.Object port)
Description copied from interface: GraphModel
Return all edges going from given port

Specified by:
getOutEdges in interface GraphModel

canAddNode

public boolean canAddNode(java.lang.Object node)
Description copied from interface: MutableGraphModel
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)
Description copied from interface: MutableGraphModel
Return true if the given object is a valid edge in this graph

Specified by:
canAddEdge in interface MutableGraphModel

addNode

public void addNode(java.lang.Object node)
Description copied from class: MutableGraphSupport
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)
Description copied from class: MutableGraphSupport
Add the given edge to the graph, if valid.

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

removeNode

public void removeNode(java.lang.Object node)
Description copied from interface: MutableGraphModel
Remove the given node from the graph. Sends a notification.

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

removeEdge

public void removeEdge(java.lang.Object edge)
Description copied from class: MutableGraphSupport
Remove the given edge from the graph.

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

canConnect

public boolean canConnect(java.lang.Object srcNode,
                          java.lang.Object destNode)
Description copied from interface: MutableGraphModel
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)
Description copied from interface: MutableGraphModel
Contruct and add a new edge of a kind determined by the ports. Sends a notification.

Specified by:
connect in interface MutableGraphModel

getEdgeLabel

public java.lang.Object getEdgeLabel(java.lang.Object edge)

addLabeledEdge

public java.lang.Object addLabeledEdge(java.lang.Object srcPort,
                                       java.lang.Object destPort,
                                       java.lang.Object label)

getEdgesLabeled

public java.util.Vector getEdgesLabeled(java.lang.Object label)