org.argouml.uml.diagram
Class UMLMutableGraphSupport

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

public abstract class UMLMutableGraphSupport
extends 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  DiDiagram diDiagram
           
private  Vector edges
          Constains all the edges in the graphmodel/diagram.
private  Object homeModel
          The "home" UML model of this diagram, not all ModelElements in this graph are in the home model, but if they are added and don't already have a model, they are placed in the "home model".
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 in the ArgoUML implmentation.
 Object connect(Object fromPort, Object toPort, Class edgeClass)
          The connect method specifying a connection type by class is unavailable in the ArgoUML implementation.
 Object connect(Object fromPort, Object toPort, Object edgeType)
          Construct and add a new edge of the given kind and connect the given ports.
 Object connect(Object fromPort, Object toPort, Object edgeType, Map styleAttributes)
          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.
 DiDiagram getDiDiagram()
          Get the object that represents this diagram in the DiagramInterchangeModel.
 List getEdges()
          Get all the edges from the graphmodel/diagram.
 Object getHomeModel()
          Get the homemodel.
 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.
 boolean isRemoveFromDiagramAllowed(Collection figs)
          Return true if the current targets may be removed from the diagram.
 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.
(package private)  void setDiDiagram(DiDiagram dd)
          Package scope.
 void setHomeModel(Object ns)
          Set the homemodel.
 
Methods inherited from class org.tigris.gef.graph.MutableGraphSupport
addEdge, addGraphEventListener, addNode, canChangeConnectedNode, canConnect, canConnect, canDragNode, changeConnectedNode, containsEdge, containsEdgePort, 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.GraphModel
getInEdges, getOutEdges, getPorts
 
Methods inherited from interface org.tigris.gef.graph.BaseGraphModel
getOwner
 

Field Detail

LOG

private static final Logger LOG
Logger.


diDiagram

private DiDiagram diDiagram

nodes

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


edges

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


homeModel

private Object homeModel
The "home" UML model of this diagram, not all ModelElements in this graph are in the home model, but if they are added and don't already have a model, they are placed in the "home model". Also, elements from other models will have their FigNodes add a line to say what their model is.

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 in the ArgoUML implmentation.

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

getHomeModel

public Object getHomeModel()
Get the homemodel.

Returns:
the homemodel

setHomeModel

public void setHomeModel(Object ns)
Set the homemodel.

Parameters:
ns - the namespace

connect

public Object connect(Object fromPort,
                      Object toPort,
                      Class edgeClass)
The connect method specifying a connection type by class is unavailable in the ArgoUML implementation. TODO: This should be unsupported. Use the 3 Object version

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

connect

public Object connect(Object fromPort,
                      Object toPort,
                      Object edgeType)
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
edgeType - The type of edge to create. This is one of the types returned by the methods of org.argouml.model.MetaTypes
Returns:
The type of edge created (the same as edgeClass if we succeeded, null otherwise)

connect

public Object connect(Object fromPort,
                      Object toPort,
                      Object edgeType,
                      Map styleAttributes)
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
edgeType - An indicator of the edge type to create.
styleAttributes - key/value pairs from which to style the edge.
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

setDiDiagram

void setDiDiagram(DiDiagram dd)
Package scope. Only the factory is supposed to set this.

Parameters:
dd -

getDiDiagram

public DiDiagram getDiDiagram()
Get the object that represents this diagram in the DiagramInterchangeModel.

Returns:
the Diagram Interchange Diagram.

isRemoveFromDiagramAllowed

public boolean isRemoveFromDiagramAllowed(Collection figs)
Return true if the current targets may be removed from the diagram.

Parameters:
figs - a collection with the selected figs
Returns:
true if the targets may be removed


ArgoUML © 1996-2005ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook