svn commit: r16450 - trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigTransition.java

Tom Morris <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2008-12-28 15:29:32-0800
New Revision: 16450

Modified:
   trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigTransition.java

Log:
Refactor some duplicate code

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigTransition.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigTransition.java?view=diff&pathrev=16450&r1=16449&r2=16450
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigTransition.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigTransition.java	2008-12-28 15:29:32-0800
@@ -99,14 +99,7 @@
     public FigTransition(Object edge, Layer lay) {
         this();
         if (Model.getFacade().isATransition(edge)) {
-            Object sourceSV = Model.getFacade().getSource(edge);
-            Object destSV = Model.getFacade().getTarget(edge);
-            FigNode sourceFN = (FigNode) lay.presentationFor(sourceSV);
-            FigNode destFN = (FigNode) lay.presentationFor(destSV);
-            setSourcePortFig(sourceFN);
-            setSourceFigNode(sourceFN);
-            setDestPortFig(destFN);
-            setDestFigNode(destFN);
+            initPorts(lay, edge);
         }
         setLayer(lay);
         setOwner(edge);
@@ -140,7 +133,7 @@
 
         /* This presumes that the layer is set after the owner: */
         if (getLayer() != null && getOwner() != null) {
-            initPorts();
+            initPorts(lay, getOwner());
         }
     }
 
@@ -152,18 +145,24 @@
 
         /* This presumes that the owner is set after the layer: */
         if (getLayer() != null && getOwner() != null) {
-            initPorts();
+            initPorts(getLayer(), owner);
         }
     }
 
     /**
+     * Set the owners of the associated FigNodes to be the StateVertexes which
+     * are at either end of the Transition.
+     * <p>
      * TODO: This needs documentation! Is this really needed? Why?
+     * 
+     * @param lay diagram layer containing this fig
+     * @param owner owning UML element
      */
-    private void initPorts() {
-        Object sourceSV = Model.getFacade().getSource(getOwner());
-        Object destSV = Model.getFacade().getTarget(getOwner());
-        FigNode sourceFN = (FigNode) getLayer().presentationFor(sourceSV);
-        FigNode destFN = (FigNode) getLayer().presentationFor(destSV);
+    private void initPorts(Layer lay, Object owner) {
+        Object sourceSV = Model.getFacade().getSource(owner);
+        Object destSV = Model.getFacade().getTarget(owner);
+        FigNode sourceFN = (FigNode) lay.presentationFor(sourceSV);
+        FigNode destFN = (FigNode) lay.presentationFor(destSV);
         setSourcePortFig(sourceFN);
         setSourceFigNode(sourceFN);
         setDestPortFig(destFN);
@@ -209,6 +208,7 @@
         }
     }
 
+    @Override
     public Vector getPopUpActions(MouseEvent me) {
         Vector popUpActions = super.getPopUpActions(me);
         /* Check if multiple items are selected: */
@@ -278,6 +278,7 @@
     /*
      * @see org.tigris.gef.presentation.FigEdge#setFig(org.tigris.gef.presentation.Fig)
      */
+    @Override
     public void setFig(Fig f) {
         super.setFig(f);
         getFig().setDashed(dashed);
@@ -286,6 +287,7 @@
     /*
      * @see org.argouml.uml.diagram.ui.FigEdgeModelElement#getDestination()
      */
+    @Override
     protected Object getDestination() {
         if (getOwner() != null) {
             return Model.getStateMachinesHelper().getDestination(getOwner());
@@ -296,6 +298,7 @@
     /*
      * @see org.argouml.uml.diagram.ui.FigEdgeModelElement#getSource()
      */
+    @Override
     protected Object getSource() {
         if (getOwner() != null) {
             return Model.getStateMachinesHelper().getSource(getOwner());
@@ -306,6 +309,7 @@
     /*
      * @see org.tigris.gef.presentation.Fig#paint(java.awt.Graphics)
      */
+    @Override
     public void paint(Graphics g) {
         endArrow.setLineColor(getLineColor());
         super.paint(g);
@@ -314,9 +318,10 @@
     /*
      * @see org.argouml.uml.diagram.ui.FigEdgeModelElement#paintClarifiers(java.awt.Graphics)
      */
+    @Override
     public void paintClarifiers(Graphics g) {
         indicateBounds(getNameFig(), g);
         super.paintClarifiers(g);
     }
 
-} /* end class FigTransition */
+}

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=994661

To unsubscribe from this discussion, e-mail: [[email protected]].
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.