svn commit: r12670 - trunk/src_new/org/argouml/uml/diagram: activity/ui collaboration/ui deployment/ui state/ui static_structure/ui ui use_case/ui

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2007-05-26 14:06:27-0700
New Revision: 12670

Modified:
   trunk/src_new/org/argouml/uml/diagram/activity/ui/SelectionActionState.java
   trunk/src_new/org/argouml/uml/diagram/collaboration/ui/SelectionClassifierRole.java
   trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponentInstance.java
   trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNode.java
   trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNodeInstance.java
   trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionObject.java
   trunk/src_new/org/argouml/uml/diagram/state/ui/SelectionState.java
   trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionClass.java
   trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java
   trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionActor.java

Log:
Issue 4764 - Fix selection clarifiers. Swapped Left/Right actions & resize.

Modified: trunk/src_new/org/argouml/uml/diagram/activity/ui/SelectionActionState.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/activity/ui/SelectionActionState.java?view=diff&rev=12670&p1=trunk/src_new/org/argouml/uml/diagram/activity/ui/SelectionActionState.java&p2=trunk/src_new/org/argouml/uml/diagram/activity/ui/SelectionActionState.java&r1=12669&r2=12670
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/activity/ui/SelectionActionState.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/activity/ui/SelectionActionState.java	2007-05-26 14:06:27-0700
@@ -83,15 +83,15 @@
      */
     public void setOutgoingButtonEnabled(boolean b) {
         setOutgoingRightButtonEnabled(b);
-        setIncomingAboveButtonEnabled(b);
+        setOutgoingBelowButtonEnabled(b);
     }
 
     /**
      * @param b true if the button is enabled
      */
     public void setIncomingButtonEnabled(boolean b) {
+        setIncomingAboveButtonEnabled(b);
         setIncomingLeftButtonEnabled(b);
-        setOutgoingBelowButtonEnabled(b);
     }
 
     /**
@@ -148,7 +148,7 @@
         if (!showOutgoingRight) {
             workingIcons[RIGHT - BASE] = null;
         }
-        return icons;
+        return workingIcons;
     }
 
     @Override
@@ -163,7 +163,7 @@
 
     @Override
     protected boolean isReverseEdge(int index) {
-        if (index == TOP || index == RIGHT ) {
+        if (index == TOP || index == LEFT ) {
             return true;
         }
         return false;

Modified: trunk/src_new/org/argouml/uml/diagram/collaboration/ui/SelectionClassifierRole.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/collaboration/ui/SelectionClassifierRole.java?view=diff&rev=12670&p1=trunk/src_new/org/argouml/uml/diagram/collaboration/ui/SelectionClassifierRole.java&p2=trunk/src_new/org/argouml/uml/diagram/collaboration/ui/SelectionClassifierRole.java&r1=12669&r2=12670
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/collaboration/ui/SelectionClassifierRole.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/collaboration/ui/SelectionClassifierRole.java	2007-05-26 14:06:27-0700
@@ -95,14 +95,14 @@
         Icon workingIcons[] = new Icon[icons.length];
         System.arraycopy(icons, 0, workingIcons, 0, icons.length);
 
-        if (!showOutgoing) {
-            workingIcons[12] = null;
-        }
         if (!showIncoming) {
-            workingIcons[13] = null;
+            workingIcons[BASE - LEFT] = null;
+        }
+        if (!showOutgoing) {
+            workingIcons[BASE - RIGHT] = null;
         }
         if (!showOutgoing && !showIncoming) {
-            workingIcons[14] = null;
+            workingIcons[BASE - LOWER_LEFT] = null;
         }
         return workingIcons;
     }
@@ -129,7 +129,7 @@
 
     @Override
     protected boolean isReverseEdge(int index) {
-        if (index == RIGHT) {
+        if (index == LEFT) {
             return true;
         }
         return false;

Modified: trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponentInstance.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponentInstance.java?view=diff&rev=12670&p1=trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponentInstance.java&p2=trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponentInstance.java&r1=12669&r2=12670
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponentInstance.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionComponentInstance.java	2007-05-26 14:06:27-0700
@@ -95,7 +95,7 @@
 
     @Override
     protected boolean isReverseEdge(int index) {
-        if (index == BOTTOM || index == RIGHT) {
+        if (index == BOTTOM || index == LEFT) {
             return true;
         }
         return false;

Modified: trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNode.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNode.java?view=diff&rev=12670&p1=trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNode.java&p2=trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNode.java&r1=12669&r2=12670
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNode.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNode.java	2007-05-26 14:06:27-0700
@@ -93,7 +93,7 @@
 
     @Override
     protected boolean isReverseEdge(int index) {
-        if (index == BOTTOM || index == RIGHT) {
+        if (index == BOTTOM || index == LEFT) {
             return true;
         }
         return false;

Modified: trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNodeInstance.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNodeInstance.java?view=diff&rev=12670&p1=trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNodeInstance.java&p2=trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNodeInstance.java&r1=12669&r2=12670
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNodeInstance.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionNodeInstance.java	2007-05-26 14:06:27-0700
@@ -92,7 +92,7 @@
 
     @Override
     protected boolean isReverseEdge(int index) {
-        if (index == BOTTOM || index == RIGHT) {
+        if (index == BOTTOM || index == LEFT) {
             return true;
         }
         return false;

Modified: trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionObject.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionObject.java?view=diff&rev=12670&p1=trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionObject.java&p2=trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionObject.java&r1=12669&r2=12670
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionObject.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/deployment/ui/SelectionObject.java	2007-05-26 14:06:27-0700
@@ -95,7 +95,7 @@
 
     @Override
     protected boolean isReverseEdge(int index) {
-        if (index == BOTTOM || index == RIGHT) {
+        if (index == BOTTOM || index == LEFT) {
             return true;
         }
         return false;

Modified: trunk/src_new/org/argouml/uml/diagram/state/ui/SelectionState.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/state/ui/SelectionState.java?view=diff&rev=12670&p1=trunk/src_new/org/argouml/uml/diagram/state/ui/SelectionState.java&p2=trunk/src_new/org/argouml/uml/diagram/state/ui/SelectionState.java&r1=12669&r2=12670
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/state/ui/SelectionState.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/state/ui/SelectionState.java	2007-05-26 14:06:27-0700
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2006 The Regents of the University of California. All
+// Copyright (c) 1996-2007 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
@@ -89,10 +89,10 @@
         System.arraycopy(icons, 0, workingIcons, 0, icons.length);
 
         if (!showOutgoing) {
-            workingIcons[LEFT - BASE] = null;
+            workingIcons[RIGHT - BASE] = null;
         }
         if (!showIncoming) {
-            workingIcons[RIGHT - BASE] = null;
+            workingIcons[LEFT - BASE] = null;
         }
         
         return workingIcons;

Modified: trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionClass.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionClass.java?view=diff&rev=12670&p1=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionClass.java&p2=trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionClass.java&r1=12669&r2=12670
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionClass.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/static_structure/ui/SelectionClass.java	2007-05-26 14:06:27-0700
@@ -101,8 +101,8 @@
             workingIcons[BOTTOM - BASE] = null;
         }
         if (useComposite) {
-            workingIcons[LEFT - BASE] = compos;
-            workingIcons[LEFT - BASE] = compos;
+            workingIcons[RIGHT - BASE] = compos;
+            workingIcons[RIGHT - BASE] = compos;
         } 
         return workingIcons;
     }

Modified: trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java?view=diff&rev=12670&p1=trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java&r1=12669&r2=12670
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/SelectionNodeClarifiers2.java	2007-05-26 14:06:27-0700
@@ -111,20 +111,21 @@
         int ch = getContent().getHeight();
         
         if (icons[0] != null) {
-            paintButtonAbove(icons[0], g, cx + cw / 2, cy, TOP);
+            paintButtonAbove(icons[0], g, cx + cw / 2, cy - OFFSET, TOP);
         }
         if (icons[1] != null) {
             paintButtonBelow(icons[1], g, cx + cw / 2, cy + ch + OFFSET, 
                     BOTTOM);
         }
         if (icons[2] != null) {
-            paintButtonLeft(icons[2], g, cx + cw + OFFSET, cy + ch / 2, LEFT);
+            myPaintButtonLeft(icons[2], g, cx - OFFSET, cy + ch / 2, LEFT);
         }
         if (icons[3] != null) {
-            paintButtonRight(icons[3], g, cx, cy + ch / 2, RIGHT);
+            myPaintButtonRight(icons[3], g, cx + cw + OFFSET, cy + ch / 2,
+                    RIGHT);
         }
         if (icons[4] != null) {
-            paintButtonRight(icons[4], g, cx, cy + ch, LOWER_LEFT);
+            paintButtonRight(icons[4], g, cx - OFFSET, cy + ch, LOWER_LEFT);
         }
     }
 
@@ -135,11 +136,22 @@
         return null;
     }
     
-    /*
-     * @see org.tigris.gef.base.Selection#hitHandle(java.awt.Rectangle,
-     * org.tigris.gef.presentation.Handle)
+    /**
+     * Compute handle selection, if any, from cursor location.
+     * 
+     * @param cursor
+     *            cursor point represented by a 0-size rectangle
+     * @param h
+     *            handle in which to return selected Handle information (output
+     *            parameter). A handle index of -1 indicates that the cursor is
+     *            not over any handle.
+     * 
+     * If GEF had any API documentation you could see the following:
+     * @see org.tigris.gef.base.SelectionResize#hitHandle(java.awt.Rectangle,
+     *      org.tigris.gef.presentation.Handle)
      */
-    public void hitHandle(Rectangle r, Handle h) {
+    public void hitHandle(Rectangle cursor, Handle h) {
+        super.hitHandle(cursor, h);
         if (h.index != -1) {
             // super implementation found a hit
             return;
@@ -184,35 +196,100 @@
          */
         if (icons[0] != null && hitAbove(cx + cw / 2, cy, 
                 icons[0].getIconWidth(), icons[0].getIconHeight(), 
-                r)) {
+                cursor)) {
             h.index = TOP;
-            h.instructions = getInstructions(h.index);
         } else if (icons[1] != null && hitBelow(cx + cw / 2, cy + ch, 
                 icons[1].getIconWidth(), icons[1].getIconHeight(), 
-                r)) {
+                cursor)) {
             h.index = BOTTOM;
-            h.instructions = getInstructions(h.index);
-        } else if (icons[2] != null && hitLeft(cx + cw, cy + ch / 2, 
+        } else if (icons[2] != null && myHitLeft(cx, cy + ch / 2, 
                 icons[2].getIconWidth(), icons[2].getIconHeight(), 
-                r)) {
+                cursor)) {
             h.index = LEFT;
-            h.instructions = getInstructions(h.index);
-        } else if (icons[3] != null && hitRight(cx, cy + ch / 2, 
+        } else if (icons[3] != null && myHitRight(cx + cw, cy + ch / 2, 
                 icons[3].getIconWidth(), icons[3].getIconHeight(), 
-                r)) {
+                cursor)) {
             h.index = RIGHT;
-            h.instructions = getInstructions(h.index);
-        } else if (icons[4] != null && hitRight(cx, cy + ch, 
+        } else if (icons[4] != null && myHitLeft(cx, cy + ch, 
                 icons[4].getIconWidth(), icons[4].getIconHeight(), 
-                r)) {
+                cursor)) {
             h.index = LOWER_LEFT;
-            h.instructions = getInstructions(h.index);
         } else {
             h.index = -1;
+        }
+        if (h.index == -1) {
             h.instructions = getInstructions(15);
+        } else {
+            h.instructions = getInstructions(h.index);
         }
     }
 
+    private static final int MARGIN = 2;
+    
+    /**
+     * Test if cursor is contained in the bounds of the icon to the left of, and
+     * centered vertically on the point x,y.
+     * <p>
+     * The GEF implementations of right/left are swapped, so this provides our
+     * own private implementation of what SelectionButtons.hitLeft
+     * <em>should</em> be doing. Rather than just calling the swapped method
+     * in GEF, we use our own implementation in case they ever swap
+     * hitRight/hitLeft to have the correct behavior.
+     * 
+     * @param x
+     *            X coordinate of left hand edge of displayed figure (right hand
+     *            edge of icon)
+     * @param y
+     *            Y coordinate of vertical <em>center</em> of icon
+     * @param w
+     *            width of icon
+     * @param h
+     *            height of icon
+     * @param r
+     *            cursor location, expressed as a 0-sized Rectange
+     * @return true if the cursor is contained in the given icon bounds.
+     */
+    protected boolean myHitLeft(int x, int y, int w, int h, Rectangle r) {
+        // return super.hitRight(x, y, w, h, r);
+        return intersectsRect(r, x - w - MARGIN, y - h / 2, w + MARGIN, h);
+    }
+
+    /**
+     * Test left handle hit. See
+     * {@link #myHitLeft(int, int, int, int, Rectangle)} for a more complete
+     * description.
+     */
+    protected boolean myHitRight(int x, int y, int w, int h, Rectangle r) {
+        // return super.hitLeft(x, y, w, h, r);
+        return intersectsRect(r, x, y - h / 2, w + MARGIN, h);
+    }
+
+    /**
+     * Paint right button. See
+     * {@link #myHitLeft(int, int, int, int, Rectangle)} for a more complete
+     * description.
+     */
+    protected void myPaintButtonRight(Icon i, Graphics g, int x, int y, 
+            int hi) {
+        // super.paintButtonLeft(i, g, x, y, hi);
+        paintButton(i, g, x + MARGIN, y - i.getIconHeight() / 2, hi);
+    }
+
+    /**
+     * Paint left button. See
+     * {@link #myHitLeft(int, int, int, int, Rectangle)} for a more complete
+     * description.
+     */
+    public void myPaintButtonLeft(Icon i, Graphics g, int x, int y, int hi) {
+        // super.paintButtonRight(i, g, x, y, hi);
+        paintButton(
+                    i,
+                    g,
+                    x - i.getIconWidth() - MARGIN,
+                    y - i.getIconHeight() / 2,
+                    hi);
+    }
+    
     /*
      * @see org.tigris.gef.base.Selection#dragHandle(int, int, int, int,
      * org.tigris.gef.presentation.Handle)
@@ -246,15 +323,15 @@
             break;
         case LEFT:
             by = cy + ch / 2;
-            bx = cx + cw;
+            bx = cx;
             break;
         case RIGHT:
             by = cy + ch / 2;
-            bx = cx;
+            bx = cx + cw;
             break;
         case LOWER_LEFT:
             by = cy + ch;
-            bx = cx + cw;
+            bx = cx;
             break;
         default:
             LOG.warn("invalid handle number");

Modified: trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionActor.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionActor.java?view=diff&rev=12670&p1=trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionActor.java&p2=trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionActor.java&r1=12669&r2=12670
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionActor.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/use_case/ui/SelectionActor.java	2007-05-26 14:06:27-0700
@@ -118,7 +118,7 @@
 
     @Override
     protected boolean isReverseEdge(int index) {
-        if (index == BOTTOM || index == RIGHT) {
+        if (index == BOTTOM || index == LEFT) {
             return true;
         }
         return false;
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.