svn commit: r15007 - trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SelectionClassifierRole.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bobtarling
Date: 2008-06-19 14:47:26-0700
New Revision: 15007

Modified:
   trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SelectionClassifierRole.java

Log:
Add another iteration as a single iteration only works if we happen to get all classifier-roles before the messages.

Some javadoc and style tidying.

Modified: trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SelectionClassifierRole.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SelectionClassifierRole.java?view=diff&rev=15007&p1=trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SelectionClassifierRole.java&p2=trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SelectionClassifierRole.java&r1=15006&r2=15007
==============================================================================
--- trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SelectionClassifierRole.java	(original)
+++ trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SelectionClassifierRole.java	2008-06-19 14:47:26-0700
@@ -74,7 +74,7 @@
             return;

         }

 

-        List<Fig> figs = getContent().getLayer().getContents();

+        final List<Fig> figs = getContent().getLayer().getContents();

 

         int minimumHeight = 0;

         for (Fig workOnFig : figs) {

@@ -85,33 +85,48 @@
         }

 

         int deltaY = mY - getContent().getY();

-        int newHeight;

         

         // vertical resizing

         switch (hand.index) {

         case Handle.NORTHWEST:

         case Handle.NORTH:

-        case Handle.NORTHEAST:         

-            newHeight = getContent().getHeight() - deltaY;

+        case Handle.NORTHEAST:

+            int newHeight = getContent().getHeight() - deltaY;

             if (newHeight < minimumHeight) {

                 newHeight = minimumHeight;

                 deltaY = getContent().getHeight() - newHeight;

             }

             

-            HashMap<Fig, Polygon> msgPoly = new HashMap<Fig, Polygon>();         

+            final HashMap<Fig, Polygon> polygonsByFig =

+            	new HashMap<Fig, Polygon>();

+            

+            // There is a bug in GEF where positioning nodes can affect

+            // edge positions. We need to do 3 iterations to protect

+            // against that.

+            

+            // 1. Remember current message paths

             for (Fig workOnFig : figs) {

                 if (workOnFig instanceof FigMessage) {

-                    msgPoly.put(workOnFig, ((FigMessage) workOnFig).getPolygon());

+                    polygonsByFig.put(

+                    		workOnFig,

+                    		((FigMessage) workOnFig).getPolygon());

                 }

             }

 

+            // 2. Reposition and resize nodes

             for (Fig workOnFig : figs) {

                 if (workOnFig instanceof FigClassifierRole) {

                     workOnFig.setHeight(newHeight);

                     workOnFig.translate(0, deltaY);

-                } else if (workOnFig instanceof FigMessage) {

-                    msgPoly.get(workOnFig).translate(0, deltaY);

-                    ((FigMessage) workOnFig).setPolygon(msgPoly.get(workOnFig));

+                }

+            }

+

+            // 3. Now reposition messages based on their original position

+            for (Fig workOnFig : figs) {

+                if (workOnFig instanceof FigMessage) {

+                    polygonsByFig.get(workOnFig).translate(0, deltaY);

+                    ((FigMessage) workOnFig).setPolygon(

+                    		polygonsByFig.get(workOnFig));

                 }

             }

             break;

@@ -130,7 +145,7 @@
         default:

         }

 

-        Fig workOnFig = getContent();

+        final Fig workOnFig = getContent();

         // horizontal resizing

         switch (hand.index) {

         case Handle.NORTHWEST:
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.