org.argouml.uml.diagram
Class UMLMutableGraphSupport

java.lang.Object
  extended byorg.tigris.gef.graph.MutableGraphSupport
      extended byorg.argouml.uml.diagram.UMLMutableGraphSupport
All Implemented Interfaces:
org.tigris.gef.graph.BaseGraphModel, org.tigris.gef.graph.GraphModel, org.tigris.gef.graph.MutableGraphModel, Serializable
Direct Known Subclasses:
ClassDiagramGraphModel, CollabDiagramGraphModel, DeploymentDiagramGraphModel, SequenceDiagramGraphModel, StateDiagramGraphModel, UseCaseDiagramGraphModel

public abstract class UMLMutableGraphSupport
extends org.tigris.gef.graph.MutableGraphSupport

UMLMutableGraphSupport is a helper class which extends MutableGraphSupport to provide additional helper and common methods for UML Diagrams.

Since:
November 14, 2002, 10:20 PM
See Also:
Serialized Form

Field Summary
private  Vector edges
          Constains all the edges in the graphmodel/diagram.
private static Logger LOG
          Logger.
private  Vector nodes
          Contains all the nodes in the graphmodel/diagram.
 
Fields inherited from class org.tigris.gef.graph.MutableGraphSupport
 
Constructor Summary
UMLMutableGraphSupport()
          Constructor.
 
Method Summary
 void addNodeRelatedEdges(Object node)
           
 CommentEdge buildCommentConnection(Object from, Object to)
          Builds the model behind a connection between a comment and the annotated modelelement.
protected  Object buildConnection(Object edgeType, Object fromElement, Object fromStyle, Object toElement, Object toStyle, Object unidirectional, Object namespace)
          Create an edge of the given type and connect it to the given nodes.
 boolean canAddEdge(Object edge)
           
 boolean canAddNode(Object node)
           
 boolean canConnect(Object fromP, Object toP)
          Assume that anything can be connected to anything unless overridden in a subclass.
 Object connect(Object fromPort, Object toPort)
          The connect method without specifying a connection type is unavailable by default.
 Object connect(Object fromPort, Object toPort, Class edgeClass)
          Construct and add a new edge of the given kind and connect the given ports.
 boolean constainsEdge(Object edge)
           
 boolean containsNode(Object node)
           
 Object getDestPort(Object edge)
          Return the destination end of an edge.
 List getEdges()
          Get all the edges from the graphmodel/diagram.
abstract  Object getNamespace()
           
 List getNodes()
          Get all the nodes from the graphmodel/diagram.
 Object getSourcePort(Object edge)
          Return the source end of an edge.
protected  boolean isConnectionValid(Object edgeType, Object fromElement, Object toElement)
          Checks if some type of edge is valid to connect two types of node.
 void removeEdge(Object edge)
          Remove an edge from the graphmodel and notify GEF.
 void removeNode(Object node)
          Remove a node from the diagram and notify GEF.
 
Methods inherited from class org.tigris.gef.graph.MutableGraphSupport
addEdge, addGraphEventListener, addNode, canChangeConnectedNode, canConnect, canDragNode, changeConnectedNode, containsEdge, containsEdgePort, containsNodePort, containsPort, createNode, dragNode, fireEdgeAdded, fireEdgeRemoved, fireGraphChanged, fireNodeAdded, fireNodeRemoved, getConnectionConstrainer, getGraphListeners, 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.GraphModel
getInEdges, getOutEdges, getPorts
 
Methods inherited from interface org.tigris.gef.graph.BaseGraphModel
getOwner
 

Field Detail

LOG

private static final Logger LOG
Logger.


nodes

private Vector nodes
Contains all the nodes in the graphmodel/diagram.


edges

private Vector edges
Constains all the edges in the graphmodel/diagram.

Constructor Detail

UMLMutableGraphSupport

public UMLMutableGraphSupport()
Constructor.

See Also:
MutableGraphSupport
Method Detail

getNodes

public List getNodes()
Get all the nodes from the graphmodel/diagram.

Returns:
Vector of nodes in the graphmodel/diagram
See Also:
GraphModel.getNodes()

getEdges

public List getEdges()
Get all the edges from the graphmodel/diagram.

Returns:
Vector of edges in the graphmodel/diagram

containsNode

public boolean containsNode(Object node)
See Also:
MutableGraphModel.containsNode(java.lang.Object)

constainsEdge

public boolean constainsEdge(Object edge)
Parameters:
edge - the candidate edge
Returns:
true if it is contained

removeNode

public void removeNode(Object node)
Remove a node from the diagram and notify GEF.

Parameters:
node - node to remove

removeEdge

public void removeEdge(Object edge)
Remove an edge from the graphmodel and notify GEF.

Parameters:
edge - edge to remove

canConnect

public boolean canConnect(Object fromP,
                          Object toP)
Assume that anything can be connected to anything unless overridden in a subclass.

See Also:
MutableGraphModel.canConnect( java.lang.Object, java.lang.Object)

connect

public Object connect(Object fromPort,
                      Object toPort)
The connect method without specifying a connection type is unavailable by default.

See Also:
MutableGraphModel.connect( java.lang.Object, java.lang.Object)

getNamespace

public abstract Object getNamespace()
Returns:
the namespace of the diagram

connect

public Object connect(Object fromPort,
                      Object toPort,
                      Class edgeClass)
Construct and add a new edge of the given kind and connect the given ports.

Parameters:
fromPort - The originating port to connect
toPort - The destination port to connect
edgeClass - The NSUML type of edge to create.
Returns:
The type of edge created (the same as edgeClass if we succeeded, null otherwise)

canAddNode

public boolean canAddNode(Object node)
See Also:
MutableGraphModel.canAddNode(java.lang.Object)

getSourcePort

public Object getSourcePort(Object edge)
Return the source end of an edge.

Parameters:
edge - The edge for which we want the source port.
Returns:
The source port for the edge, or null if the edge given is of the wrong type or has no source defined.

getDestPort

public Object getDestPort(Object edge)
Return the destination end of an edge.

Parameters:
edge - The edge for which we want the destination port.
Returns:
The destination port for the edge, or null if the edge given is otf the wrong type or has no destination defined.

canAddEdge

public boolean canAddEdge(Object edge)
See Also:
MutableGraphModel.canAddEdge(java.lang.Object)

addNodeRelatedEdges

public void addNodeRelatedEdges(Object node)
See Also:
MutableGraphModel.addNodeRelatedEdges(java.lang.Object)

buildConnection

protected Object buildConnection(Object edgeType,
                                 Object fromElement,
                                 Object fromStyle,
                                 Object toElement,
                                 Object toStyle,
                                 Object unidirectional,
                                 Object namespace)
Create an edge of the given type and connect it to the given nodes.

Parameters:
edgeType - the UML object type of the connection
fromElement - the UML object for the "from" element
fromStyle - the aggregationkind for the connection in case of an association
toElement - the UML object for the "to" element
toStyle - the aggregationkind for the connection in case of an association
unidirectional - for association and associationrole
namespace - the namespace to use if it can't be determined
Returns:
the newly build connection (UML object)

buildCommentConnection

public CommentEdge buildCommentConnection(Object from,
                                          Object to)
Builds the model behind a connection between a comment and the annotated modelelement.

Parameters:
from - The comment or annotated element.
to - The comment or annotated element.
Returns:
A commentEdge representing the model behind the connection between a comment and an annotated modelelement.

isConnectionValid

protected boolean isConnectionValid(Object edgeType,
                                    Object fromElement,
                                    Object toElement)
Checks if some type of edge is valid to connect two types of node.

Parameters:
edgeType - the UML object type of the connection
fromElement - the UML object type of the "from"
toElement - the UML object type of the "to"
Returns:
true if valid


ArgoUML © 1996-2004 (20050222)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook