org.argouml.uml.diagram.use_case
Class UseCaseDiagramGraphModel

java.lang.Object
  extended byorg.tigris.gef.graph.MutableGraphSupport
      extended byorg.argouml.uml.diagram.UMLMutableGraphSupport
          extended byorg.argouml.uml.diagram.use_case.UseCaseDiagramGraphModel
All Implemented Interfaces:
java.util.EventListener, org.tigris.gef.graph.GraphModel, org.tigris.gef.graph.MutableGraphModel, java.io.Serializable, java.beans.VetoableChangeListener

public class UseCaseDiagramGraphModel
extends UMLMutableGraphSupport
implements java.beans.VetoableChangeListener

This class defines a bridge between the UML meta-model representation of the design and the GraphModel interface used by GEF.

This class handles only UML Use Case Diagrams.

See Also:
Serialized Form

Field Summary
protected  ru.novosoft.uml.foundation.core.MNamespace _model
          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".
protected static org.apache.log4j.Category cat
           
 
Fields inherited from class org.argouml.uml.diagram.UMLMutableGraphSupport
_edges, _nodes
 
Fields inherited from class org.tigris.gef.graph.MutableGraphSupport
_graphListeners
 
Constructor Summary
UseCaseDiagramGraphModel()
           
 
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 the various types of edge that may be connected with the given node.
 boolean canAddEdge(java.lang.Object edge)
          Determine if the given edge can validly be placed on this graph.
 boolean canAddNode(java.lang.Object node)
          Determine if the given node can validly be placed on this graph.
 boolean canConnect(java.lang.Object fromP, java.lang.Object toP)
          Determine if the two given ports can be connected by a kind of edge to be determined by the ports.
 java.lang.Object getDestPort(java.lang.Object edge)
          Return the destination end of an edge.
 java.util.Vector getInEdges(java.lang.Object port)
          Return all edges going to given port.
 ru.novosoft.uml.foundation.core.MNamespace getNamespace()
          Accessor to get the namespace.
 java.util.Vector getOutEdges(java.lang.Object port)
          Return all edges going from the given port.
 java.lang.Object getOwner(java.lang.Object port)
           
 java.util.Vector getPorts(java.lang.Object nodeOrEdge)
          Return all ports on a node or edge supplied as argument.
 java.lang.Object getSourcePort(java.lang.Object edge)
          Return the source end of an edge.
 void setNamespace(ru.novosoft.uml.foundation.core.MNamespace m)
          Accessor to set the namespace.
 void vetoableChange(java.beans.PropertyChangeEvent pce)
          Called when a property of interest has been changed - in this case the owned elements of the model.
 
Methods inherited from class org.argouml.uml.diagram.UMLMutableGraphSupport
connect, connect, constainsEdge, containsNode, getEdges, getNodes, removeEdge, removeNode
 
Methods inherited from class org.tigris.gef.graph.MutableGraphSupport
addGraphEventListener, canChangeConnectedNode, canConnect, canDragNode, changeConnectedNode, containsEdge, containsEdgePort, containsNodePort, containsPort, 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
 

Field Detail

cat

protected static org.apache.log4j.Category cat

_model

protected ru.novosoft.uml.foundation.core.MNamespace _model

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

UseCaseDiagramGraphModel

public UseCaseDiagramGraphModel()
Method Detail

getNamespace

public ru.novosoft.uml.foundation.core.MNamespace getNamespace()

Accessor to get the namespace.

Returns:
The namespace associated with this graph model.

setNamespace

public void setNamespace(ru.novosoft.uml.foundation.core.MNamespace m)

Accessor to set the namespace.

Clears the current listener if we have a namespace at present. Sets a new listener if we set a new namespace (i.e. m is non-null).

Parameters:
m - The namespace to use for this graph model

getPorts

public java.util.Vector getPorts(java.lang.Object nodeOrEdge)

Return all ports on a node or edge supplied as argument.

The only objects on our diagram that have any ports are use cases and actors, and they each have one - themself.

Specified by:
getPorts in interface org.tigris.gef.graph.GraphModel
Parameters:
nodeOrEdge - A model element, for whom the list of ports is wanted.
Returns:
A vector of the ports found.

getOwner

public java.lang.Object getOwner(java.lang.Object port)
Specified by:
getOwner in interface org.tigris.gef.graph.GraphModel

getInEdges

public java.util.Vector getInEdges(java.lang.Object port)

Return all edges going to given port.

The only objects with ports on the use case diagram are actors and use cases. In each case we find the attached association ends, and build a list of them as the incoming ports.

Specified by:
getInEdges in interface org.tigris.gef.graph.GraphModel
Parameters:
port - The port for which we want to know the incoming edges.
Returns:
A vector of objects which are the incoming edges.

getOutEdges

public java.util.Vector getOutEdges(java.lang.Object port)

Return all edges going from the given port.

Needs more work. This would seem superficially to be identical to getInEdges(java.lang.Object), but in our implementation we return an empty vector.

Specified by:
getOutEdges in interface org.tigris.gef.graph.GraphModel
Parameters:
port - The port for which we want to know the outgoing edges.
Returns:
A vector of objects which are the outgoing edges. Currently return the empty vector.

getSourcePort

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

Return the source end of an edge.

Needs more work. In the current implementation we only know how to handle associations, returning the first of its connections—which, if set, will be a use case or an actor.

Specified by:
getSourcePort in interface org.tigris.gef.graph.GraphModel
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 not an association or has no source defined.

getDestPort

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

Return the destination end of an edge.

Needs more work. In the current implementation we only know how to handle associations, returning the second of its connections—which, if set, will be a use case or an actor.

Specified by:
getDestPort in interface org.tigris.gef.graph.GraphModel
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 not an association or has no destination defined.

canAddNode

public boolean canAddNode(java.lang.Object node)

Determine if the given node can validly be placed on this graph.

This is simply a matter of determining if the node is an actor or use case.

Note. This is inconsistent with addNode(java.lang.Object), which will not allow a node to be added to the graph if it is already there.

Specified by:
canAddNode in interface org.tigris.gef.graph.MutableGraphModel
Parameters:
node - The node to be considered
Returns:
true if the given object is a valid node in this graph, false otherwise.

canAddEdge

public boolean canAddEdge(java.lang.Object edge)

Determine if the given edge can validly be placed on this graph.

We cannot do so if the edge is already on the graph (unlike nodes they may not appear more than once).

Otherwise, for all valid types of edge (binary association, generalization, extend, include, dependency) we get the two ends. If they are both nodes already on the graph we are OK, otherwise we cannot place the edge on the graph.

Specified by:
canAddEdge in interface org.tigris.gef.graph.MutableGraphModel
Parameters:
edge - The edge to be considered
Returns:
true if the given object is a valid edge in this graph, false otherwise.

addNode

public void addNode(java.lang.Object node)

Add the given node to the graph, if valid.

We add the node if it is not already on the graph, and (assuming it to be an actor or use case) add it to the owned elements for the model.

Needs more work. In adding the node to the owned elements of the model namespace, we are implicitly making it public visibility (it could be private to this namespace).

Note. This method is inconsistent with canAddNode(java.lang.Object), which will allow a node to be added to the graph if it is already there.

Specified by:
addNode in interface org.tigris.gef.graph.MutableGraphModel
Parameters:
node - The node to be added to the graph.

addEdge

public void addEdge(java.lang.Object edge)

Add the given edge to the graph, if valid.

We add the edge if it is not already on the graph, and (assuming it to be an association, generalization, extend, include or dependency) add it to the owned elements for the model.

Needs more work. In adding the edge to the owned elements of the model namespace, we are implicitly making it public visibility (it could be private to this namespace).

Specified by:
addEdge in interface org.tigris.gef.graph.MutableGraphModel
Parameters:
edge - The edge to be added to the graph.

addNodeRelatedEdges

public void addNodeRelatedEdges(java.lang.Object node)

Add the various types of edge that may be connected with the given node.

For use cases we may find extend and include relationships. For classifiers (effectively actors and use cases) we may find associations. For generalizable elements (effectively actors and use cases again) we may find generalizations and specializations. For ModelElements (effectively actors and use cases again) we may find dependencies.

Specified by:
addNodeRelatedEdges in interface org.tigris.gef.graph.MutableGraphModel
Parameters:
node - The node whose edges are to be added.

canConnect

public boolean canConnect(java.lang.Object fromP,
                          java.lang.Object toP)

Determine if the two given ports can be connected by a kind of edge to be determined by the ports.

Note. There appears to be a problem with the implementation, since it suggests actors cannot connect. In fact generalization is permitted, and this works, suggesting this method is not actually invoked in the current implementation of ArgoUML.

Specified by:
canConnect in interface org.tigris.gef.graph.MutableGraphModel
Overrides:
canConnect in class UMLMutableGraphSupport
Parameters:
fromP - The source port of the connection
toP - The destination port of the connection.
Returns:
true if the two given ports can be connected by a kind of edge to be determined by the ports. false otherwise.

vetoableChange

public void vetoableChange(java.beans.PropertyChangeEvent pce)

Called when a property of interest has been changed - in this case the owned elements of the model. Provided to implement the VetoableChangeListener interface.

We could throw a PropertyVetoException if we wished to allow the change to be rolled back, but we don't.

Specified by:
vetoableChange in interface java.beans.VetoableChangeListener
Parameters:
pce - The event that triggered us, and from which we can extract the name of the property that triggered us.


ArgoUML © 1996-2003 (20040125)ArgoUML Project HomeArgoUML Cookbook