svn commit: r16345 - trunk/src/argouml-app/src/org/argouml/uml/diagram/ui

Michiel van der Wulp <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: mvw
Date: 2008-12-12 01:51:07-0800
New Revision: 16345

Modified:
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigUtil.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociation.java

Log:
Make the "pretty little markers" re-usable for other figs - such as the FigAssociationEnd, which I am working on.

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigUtil.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigUtil.java?view=diff&pathrev=16345&r1=16344&r2=16345
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigUtil.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigUtil.java	2008-12-12 01:51:07-0800
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 2007 The Regents of the University of California. All
+// Copyright (c) 2007-2008 The Regents of the University of California. All
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 // software and its documentation without fee, and without a written
 // agreement is hereby granted, provided that the above copyright notice
@@ -24,6 +24,8 @@
 
 package org.argouml.uml.diagram.ui;
 
+import java.awt.Color;
+
 import org.argouml.kernel.Project;
 import org.argouml.kernel.ProjectManager;
 import org.argouml.uml.diagram.UMLMutableGraphSupport;
@@ -33,6 +35,9 @@
 import org.tigris.gef.base.LayerPerspective;
 import org.tigris.gef.graph.GraphModel;
 import org.tigris.gef.presentation.Fig;
+import org.tigris.gef.presentation.FigCircle;
+import org.tigris.gef.presentation.FigEdge;
+import org.tigris.gef.presentation.FigRect;
 
 /**
  * Static utility methods for use with ArgoFigs.
@@ -85,4 +90,28 @@
     }
 
 
+    /**
+     * Add pretty little markers for debugging purposes. We use three markers so
+     * you can see the anchor, the computed target position, and how collision
+     * detection affects a largish box.
+     */
+    static void markPosition(FigEdge fe, 
+            int pct, int delta, int angle, int offset,
+            Color color) {
+        // set this to true on to enable debugging figs
+        if (false) {
+            Fig f;
+            f = new FigCircle(0, 0, 5, 5, color, Color.red);
+            // anchor position
+            fe.addPathItem(f, new PathItemPlacement(fe, f, pct, delta, angle, 
+                    0));
+            f = new FigRect(0, 0, 100, 20, color, Color.red);
+            f.setFilled(false);
+            fe.addPathItem(f, new PathItemPlacement(fe, f, pct, delta, angle,
+                    offset));
+            f = new FigCircle(0, 0, 5, 5, color, Color.blue);
+            fe.addPathItem(f, new PathItemPlacement(fe, f, pct, delta, angle,
+                    offset));
+        }
+    }
 }

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociation.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociation.java?view=diff&pathrev=16345&r1=16344&r2=16345
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociation.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociation.java	2008-12-12 01:51:07-0800
@@ -51,10 +51,7 @@
 import org.tigris.gef.presentation.ArrowHeadDiamond;
 import org.tigris.gef.presentation.ArrowHeadGreater;
 import org.tigris.gef.presentation.ArrowHeadNone;
-import org.tigris.gef.presentation.Fig;
-import org.tigris.gef.presentation.FigCircle;
 import org.tigris.gef.presentation.FigNode;
-import org.tigris.gef.presentation.FigRect;
 import org.tigris.gef.presentation.FigText;
 
 
@@ -114,13 +111,13 @@
         // Placed perpendicular to midpoint of edge
         addPathItem(middleGroup,
                 new PathItemPlacement(this, middleGroup, 50, 25));
-        markPosition(50, 0, 90, 25, Color.yellow);
+        ArgoFigUtil.markPosition(this, 50, 0, 90, 25, Color.yellow);
         
         srcMult = new FigMultiplicity();
         // Placed at a 45 degree angle close to the end
         addPathItem(srcMult, 
                 new PathItemPlacement(this, srcMult, 0, 5, 135, 5));
-        markPosition(0, 5, 135, 5, Color.green);
+        ArgoFigUtil.markPosition(this, 0, 5, 135, 5, Color.green);
         
         //////////////////////////////////////////////////////////////////
         // NOTE: If this needs to be updated during the deprecation period
@@ -130,12 +127,12 @@
         srcGroup = new FigAssociationEndAnnotation(this);
         addPathItem(srcGroup, 
                 new PathItemPlacement(this, srcGroup, 0, 5, -135, 5));
-        markPosition(0, 5, -135, 5, Color.blue);
+        ArgoFigUtil.markPosition(this, 0, 5, -135, 5, Color.blue);
 
         destMult = new FigMultiplicity();
         addPathItem(destMult,
                 new PathItemPlacement(this, destMult, 100, -5, 45, 5));
-        markPosition(100, -5, 45, 5, Color.red);
+        ArgoFigUtil.markPosition(this, 100, -5, 45, 5, Color.red);
         
         //////////////////////////////////////////////////////////////////
         // NOTE: If this needs to be updated during the deprecation period
@@ -145,7 +142,7 @@
         destGroup = new FigAssociationEndAnnotation(this);
         addPathItem(destGroup,
                 new PathItemPlacement(this, destGroup, 100, -5, -45, 5));
-        markPosition(100, -5, -45, 5, Color.orange);
+        ArgoFigUtil.markPosition(this, 100, -5, -45, 5, Color.orange);
                 
         setBetweenNearestPoints(true);
     }
@@ -169,61 +166,36 @@
         middleGroup.addFig(getStereotypeFig());
         addPathItem(middleGroup,
                 new PathItemPlacement(this, middleGroup, 50, 25));
-        markPosition(50, 0, 90, 25, Color.yellow);
+        ArgoFigUtil.markPosition(this, 50, 0, 90, 25, Color.yellow);
         
-        Object[] ends = 
+        Object[] ends = // UML objects of AssociationEnd type
             Model.getFacade().getConnections(owner).toArray();
         
         srcMult = new FigMultiplicity(ends[0], settings);
         addPathItem(srcMult, 
                 new PathItemPlacement(this, srcMult, 0, 5, 135, 5));
-        markPosition(0, 5, 135, 5, Color.green);
+        ArgoFigUtil.markPosition(this, 0, 5, 135, 5, Color.green);
         
         srcGroup = new FigAssociationEndAnnotation(this, ends[0], settings);
         addPathItem(srcGroup, 
                 new PathItemPlacement(this, srcGroup, 0, 5, -135, 5));
-        markPosition(0, 5, -135, 5, Color.blue);
+        ArgoFigUtil.markPosition(this, 0, 5, -135, 5, Color.blue);
 
         destMult = new FigMultiplicity(ends[1], settings);
         addPathItem(destMult,
                 new PathItemPlacement(this, destMult, 100, -5, 45, 5));
-        markPosition(100, -5, 45, 5, Color.red);
+        ArgoFigUtil.markPosition(this, 100, -5, 45, 5, Color.red);
         
         destGroup = new FigAssociationEndAnnotation(this, ends[1], settings);
         addPathItem(destGroup,
                 new PathItemPlacement(this, destGroup, 100, -5, -45, 5));
-        markPosition(100, -5, -45, 5, Color.orange);
+        ArgoFigUtil.markPosition(this, 100, -5, -45, 5, Color.orange);
 
         setBetweenNearestPoints(true);
         
         initializeNotationProvidersInternal(owner);
 
     }
-
-    /*
-     * Add pretty little markers for debugging purposes. We use three markers so
-     * you can see the anchor, the computed target position, and how collision
-     * detection affects a largish box.
-     */
-    private void markPosition(int pct, int delta, int angle, int offset,
-            Color color) {
-        // set this to true on to enable debugging figs
-        if (false) {
-            Fig f;
-            f = new FigCircle(0, 0, 5, 5, color, Color.red);
-            // anchor position
-            addPathItem(f, new PathItemPlacement(this, f, pct, delta, angle, 
-                    0));
-            f = new FigRect(0, 0, 100, 20, color, Color.red);
-            f.setFilled(false);
-            addPathItem(f, new PathItemPlacement(this, f, pct, delta, angle,
-                    offset));
-            f = new FigCircle(0, 0, 5, 5, color, Color.blue);
-            addPathItem(f, new PathItemPlacement(this, f, pct, delta, angle,
-                    offset));
-        }
-    }
-
     
     /**
      * Constructor that hooks the Fig to an existing UML element.
@@ -737,7 +709,10 @@
 /**
  * The arrowhead and the group of labels shown at the association end: 
  * the role name and the ordering property. 
- * This does not include the multiplicity.
+ * This does not include the multiplicity. <p>
+ * 
+ * This class does not yet support arrows for a FigAssociationEnd, 
+ * as is used for N-ary associations.
  */
 class FigAssociationEndAnnotation extends FigTextGroup {

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

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.