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:
org.tigris.gef.graph.BaseGraphModel, EventListener, org.tigris.gef.graph.GraphModel, org.tigris.gef.graph.MutableGraphModel, Serializable, VetoableChangeListener

public class UseCaseDiagramGraphModel
extends UMLMutableGraphSupport
implements 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
private static Logger LOG
          Logger.
private  Object 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".
(package private) static long serialVersionUID
           
 
Fields inherited from class org.argouml.uml.diagram.UMLMutableGraphSupport
 
Fields inherited from class org.tigris.gef.graph.MutableGraphSupport
 
Constructor Summary
UseCaseDiagramGraphModel()
           
 
Method Summary
 void addEdge(Object edge)
          Add the given edge to the graph, if valid.
 void addNode(Object node)
          Add the given node to the graph, if valid.
 void addNodeRelatedEdges(Object node)
          Add the various types of edge that may be connected with the given node.
 boolean canAddEdge(Object edge)
          Determine if the given edge can validly be placed on this graph.
 boolean canAddNode(Object node)
          Determine if the given node can validly be placed on this graph.
 boolean canConnect(Object fromP, Object toP)
          Determine if the two given ports can be connected by a kind of edge to be determined by the ports.
 List getInEdges(Object port)
          Return all edges going to given port.
 Object getNamespace()
          Accessor to get the namespace.
 List getOutEdges(Object port)
          Return all edges going from the given port.
 Object getOwner(Object port)
          Return the node or edge that owns the given port.
 List getPorts(Object nodeOrEdge)
          Return all ports on a node or edge supplied as argument.
 void setNamespace(Object namespace)
          Accessor to set the namespace.
 void vetoableChange(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
buildCommentConnection, buildConnection, connect, connect, constainsEdge, containsNode, getDestPort, getEdges, getNodes, getSourcePort, isConnectionValid, removeEdge, removeNode
 
Methods inherited from class org.tigris.gef.graph.MutableGraphSupport
addGraphEventListener, 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
 

Field Detail

LOG

private static final Logger LOG
Logger.


model

private Object 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.


serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

UseCaseDiagramGraphModel

public UseCaseDiagramGraphModel()
Method Detail

getNamespace

public Object getNamespace()
Accessor to get the namespace.

Specified by:
getNamespace in class UMLMutableGraphSupport
Returns:
The namespace associated with this graph model.

setNamespace

public void setNamespace(Object namespace)
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:
namespace - The namespace to use for this graph model

getPorts

public List getPorts(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 Object getOwner(Object port)
Return the node or edge that owns the given port.

In our implementation the only objects with ports, use themselves as the port, so are there own owner.

Specified by:
getOwner in interface org.tigris.gef.graph.BaseGraphModel
Parameters:
port - The port, whose owner is wanted.
Returns:
The owner of the port.

getInEdges

public List getInEdges(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 List getOutEdges(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.

canAddNode

public boolean canAddNode(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
Overrides:
canAddNode in class UMLMutableGraphSupport
Parameters:
node - The node to be considered
Returns:
true if the given object is a valid node in this graph, false otherwise.
See Also:
MutableGraphModel.canAddNode(java.lang.Object)

canAddEdge

public boolean canAddEdge(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
Overrides:
canAddEdge in class UMLMutableGraphSupport
Parameters:
edge - The edge to be considered
Returns:
true if the given object is a valid edge in this graph, false otherwise.
See Also:
MutableGraphModel.canAddEdge(java.lang.Object)

addNode

public void addNode(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(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(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
Overrides:
addNodeRelatedEdges in class UMLMutableGraphSupport
Parameters:
node - The node whose edges are to be added.
See Also:
MutableGraphModel.addNodeRelatedEdges(java.lang.Object)

canConnect

public boolean canConnect(Object fromP,
                          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.
See Also:
MutableGraphModel.canConnect( java.lang.Object, java.lang.Object)

vetoableChange

public void vetoableChange(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 VetoableChangeListener
Parameters:
pce - The event that triggered us, and from which we can extract the name of the property that triggered us.


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