org.argouml.uml.diagram.static_structure
Class ClassDiagramGraphModel

java.lang.Object
  extended byorg.tigris.gef.graph.MutableGraphSupport
      extended byorg.argouml.uml.diagram.UMLMutableGraphSupport
          extended byorg.argouml.uml.diagram.static_structure.ClassDiagramGraphModel
All Implemented Interfaces:
org.tigris.gef.graph.BaseGraphModel, EventListener, org.tigris.gef.graph.GraphModel, org.tigris.gef.graph.MutableGraphModel, Serializable, VetoableChangeListener

public class ClassDiagramGraphModel
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 Class digrams.

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
ClassDiagramGraphModel()
           
 
Method Summary
 void addEdge(Object edge)
          Add the given edge to the graph, if of the correct type.
 void addNode(Object node)
           
 void addNodeRelatedEdges(Object node)
          Adds the edges from the given node.
 boolean canAddEdge(Object edge)
           
 boolean canAddNode(Object node)
           
 boolean canChangeConnectedNode(Object newNode, Object oldNode, Object edge)
          When rerouting an edge, this is the first method to be called by SelectionRerouteEdge, in order to determine whether the graphmodel will allow the change.
 void changeConnectedNode(Object newNode, Object oldNode, Object edge, boolean isSource)
          Reroutes the connection to the old node to be connected to the new node.
 List getInEdges(Object port)
           
 Object getNamespace()
           
 List getOutEdges(Object port)
           
 Object getOwner(Object port)
           
 List getPorts(Object nodeOrEdge)
           
private  void rerouteAssociation(Object newNode, Object oldNode, Object edge, boolean isSource)
          helper method for changeConnectedNode
private  void rerouteDependency(Object newNode, Object oldNode, Object edge, boolean isSource)
          helper method for changeConnectedNode
private  void rerouteGeneralization(Object newNode, Object oldNode, Object edge, boolean isSource)
          helper method for changeConnectedNode
private  void rerouteLink(Object newNode, Object oldNode, Object edge, boolean isSource)
          helper method for changeConnectedNode
 void setNamespace(Object namespace)
           
 void vetoableChange(PropertyChangeEvent pce)
           
 
Methods inherited from class org.argouml.uml.diagram.UMLMutableGraphSupport
buildCommentConnection, buildConnection, canConnect, connect, connect, constainsEdge, containsNode, getDestPort, getEdges, getNodes, getSourcePort, isConnectionValid, removeEdge, removeNode
 
Methods inherited from class org.tigris.gef.graph.MutableGraphSupport
addGraphEventListener, canConnect, canDragNode, 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

ClassDiagramGraphModel

public ClassDiagramGraphModel()
Method Detail

getNamespace

public Object getNamespace()
Specified by:
getNamespace in class UMLMutableGraphSupport
Returns:
the namespace of the diagram
See Also:
UMLMutableGraphSupport.getNamespace()

setNamespace

public void setNamespace(Object namespace)
Parameters:
namespace - the namespace to be set for this diagram

getPorts

public List getPorts(Object nodeOrEdge)
Specified by:
getPorts in interface org.tigris.gef.graph.GraphModel
See Also:
Return all ports on node or edge.

getOwner

public Object getOwner(Object port)
Specified by:
getOwner in interface org.tigris.gef.graph.BaseGraphModel
See Also:
Return the node or edge that owns the given port.

getInEdges

public List getInEdges(Object port)
Specified by:
getInEdges in interface org.tigris.gef.graph.GraphModel
See Also:
Return all edges going to given port (read Model Element). Instances can't currently be added to a class diagram.

getOutEdges

public List getOutEdges(Object port)
Specified by:
getOutEdges in interface org.tigris.gef.graph.GraphModel
See Also:
Return all edges going from given port (model element).

canAddNode

public boolean canAddNode(Object node)
Specified by:
canAddNode in interface org.tigris.gef.graph.MutableGraphModel
Overrides:
canAddNode in class UMLMutableGraphSupport
See Also:
Return true if the given object is a valid node in this graph.

canAddEdge

public boolean canAddEdge(Object edge)
Specified by:
canAddEdge in interface org.tigris.gef.graph.MutableGraphModel
Overrides:
canAddEdge in class UMLMutableGraphSupport
See Also:
Return true if the given object is a valid edge in this graph.

addNode

public void addNode(Object node)
Specified by:
addNode in interface org.tigris.gef.graph.MutableGraphModel
See Also:
Add the given node to the graph, if valid.

addEdge

public void addEdge(Object edge)
Add the given edge to the graph, if of the correct type. Throws IllegalArgumentException if edge is null or either of its ends are null.

Specified by:
addEdge in interface org.tigris.gef.graph.MutableGraphModel
See Also:
MutableGraphModel.addEdge(java.lang.Object)

addNodeRelatedEdges

public void addNodeRelatedEdges(Object node)
Adds the edges from the given node. For example, this method lets you add an allready existing massociation between two figclassifiers.

Specified by:
addNodeRelatedEdges in interface org.tigris.gef.graph.MutableGraphModel
Overrides:
addNodeRelatedEdges in class UMLMutableGraphSupport
See Also:
MutableGraphModel.addNodeRelatedEdges(Object)

vetoableChange

public void vetoableChange(PropertyChangeEvent pce)
Specified by:
vetoableChange in interface VetoableChangeListener
See Also:
VetoableChangeListener.vetoableChange(java.beans.PropertyChangeEvent)

canChangeConnectedNode

public boolean canChangeConnectedNode(Object newNode,
                                      Object oldNode,
                                      Object edge)
When rerouting an edge, this is the first method to be called by SelectionRerouteEdge, in order to determine whether the graphmodel will allow the change.

restricted to class<->association changes for now.

Specified by:
canChangeConnectedNode in interface org.tigris.gef.graph.MutableGraphModel
Parameters:
newNode - this is the new node that one of the ends is dragged to.
oldNode - this is the existing node that is already connected.
edge - this is the edge that is being dragged/rerouted
Returns:
whether or not the rerouting is allowed

changeConnectedNode

public void changeConnectedNode(Object newNode,
                                Object oldNode,
                                Object edge,
                                boolean isSource)
Reroutes the connection to the old node to be connected to the new node. delegates to rerouteXXX(,,,) for each of the 4 possible edges in a class diagram: Association, Dependency, Generalization, Link.

Specified by:
changeConnectedNode in interface org.tigris.gef.graph.MutableGraphModel
Parameters:
newNode - this is the new node that one of the ends is dragged to.
oldNode - this is the existing node that is already connected.
edge - this is the edge that is being dragged/rerouted
isSource - tells us which end is being rerouted.

rerouteAssociation

private void rerouteAssociation(Object newNode,
                                Object oldNode,
                                Object edge,
                                boolean isSource)
helper method for changeConnectedNode


rerouteGeneralization

private void rerouteGeneralization(Object newNode,
                                   Object oldNode,
                                   Object edge,
                                   boolean isSource)
helper method for changeConnectedNode

empty at the moment


rerouteDependency

private void rerouteDependency(Object newNode,
                               Object oldNode,
                               Object edge,
                               boolean isSource)
helper method for changeConnectedNode

empty at the moment


rerouteLink

private void rerouteLink(Object newNode,
                         Object oldNode,
                         Object edge,
                         boolean isSource)
helper method for changeConnectedNode

empty at the moment



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