org.tigris.gef.graph.presentation
Class AdjacencyListGraphModel

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

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
           
 
Fields inherited from class org.tigris.gef.graph.MutableGraphSupport
_graphListeners
 
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.Vector getEdges()
          Return all nodes in the graph
 java.util.Vector getEdgesLabeled(java.lang.Object label)
           
 java.util.Vector getInEdges(java.lang.Object port)
          Return all edges going to given port
 java.util.Vector getNodes()
          Return all nodes in the graph
 java.util.Vector 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.Vector 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, canDragNode, changeConnectedNode, connect, containsEdge, containsEdgePort, containsNode, containsNodePort, containsPort, createNode, dragNode, fireEdgeAdded, fireEdgeRemoved, fireGraphChanged, fireNodeAdded, fireNodeRemoved, getGraphListeners, removeGraphEventListener
 
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
 

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.Vector getNodes()
Description copied from interface: GraphModel
Return all nodes in the graph

Specified by:
getNodes in interface GraphModel

getEdges

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

Specified by:
getEdges in interface GraphModel

getPorts

public abstract java.util.Vector 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.Vector 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.Vector 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 interface: MutableGraphModel
Add the given node to the graph, if valid. Sends a notification.

Specified by:
addNode in interface MutableGraphModel

addEdge

public void addEdge(java.lang.Object edge)
Description copied from interface: MutableGraphModel
Add the given edge to the graph, if valid. Sends a notification.

Specified by:
addEdge in interface MutableGraphModel

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

removeEdge

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

Specified by:
removeEdge in interface MutableGraphModel

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)