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

Michiel van der Wulp <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: mvw
Date: 2009-10-05 11:37:12-0700
New Revision: 17371

Modified:
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigUtil.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartmentBox.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/use_case/ui/FigActor.java

Log:
Overhaul of the FigActor.
Make line color changes work.
Consistency with other Figs.

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=17371&r1=17370&r2=17371
==============================================================================
--- 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	2009-10-05 11:37:12-0700
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 2007-2008 The Regents of the University of California. All
+// Copyright (c) 2007-2009 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
@@ -25,6 +25,7 @@
 package org.argouml.uml.diagram.ui;
 
 import java.awt.Color;
+import java.awt.Dimension;
 
 import org.argouml.kernel.Project;
 import org.argouml.kernel.ProjectManager;
@@ -114,4 +115,41 @@
                     offset));
         }
     }
+
+    /**
+     * This utility adds the size of a child component to an overall size. The
+     * width is maximized with child's width and the child's height is added to
+     * the overall height. If the child figure is not visible or not yet
+     * created, it's size is not added.
+     * 
+     * @param size current dimensions - modified with the result
+     * @param child child figure
+     * @return new Dimension with child size added
+     */
+    public static Dimension addChildDimensions(Dimension size, Fig child) {
+        if (child != null && child.isVisible()) {
+            Dimension childSize = child.getMinimumSize();
+            size.width = Math.max(size.width, childSize.width);
+            size.height += childSize.height;
+        }
+        return size;
+    }
+
+
+    /**
+     * This utility adds the width of a child component to an overall size. The
+     * width is maximized with child's width and the child's height is ignored.
+     * If the child figure is not visible, it's size is not added.
+     * 
+     * @param size current dimensions - modified with the result
+     * @param child child figure
+     * @return new Dimension with child width added
+     */
+    public static Dimension addChildWidth(Dimension size, Fig child) {
+        if (child.isVisible()) {
+            Dimension childSize = child.getMinimumSize();
+            size.width = Math.max(size.width, childSize.width);
+        }
+        return size;
+    }
 }

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartmentBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartmentBox.java?view=diff&pathrev=17371&r1=17370&r2=17371
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartmentBox.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartmentBox.java	2009-10-05 11:37:12-0700
@@ -185,12 +185,12 @@
          * Only take into account the stereotype width, not the height, since
          * the height is included in the name fig:
          */
-        aSize = addChildWidth(aSize, getStereotypeFig());
+        aSize = ArgoFigUtil.addChildWidth(aSize, getStereotypeFig());
 
         /* Add the height of all the compartments (if there are any),
          * and check their minimum width: */
         for (FigCompartment c : compartments) {
-            aSize = addChildDimensions(aSize, c);
+            aSize = ArgoFigUtil.addChildDimensions(aSize, c);
         }
 
         /* We want to maintain a minimum width for the fig. Also, add the border
@@ -518,44 +518,6 @@
     }
 
     /**
-     * This utility adds the size of a child component to an overall size. The
-     * width is maximized with child's width and the child's height is added to
-     * the overall height. If the child figure is not visible or not yet
-     * created, it's size is not added.
-     * 
-     * @param size current dimensions - modified with the result
-     * @param child child figure
-     * @return new Dimension with child size added
-     */
-    protected static Dimension addChildDimensions(Dimension size, 
-            Fig child) {
-        if (child != null && child.isVisible()) {
-            Dimension childSize = child.getMinimumSize();
-            size.width = Math.max(size.width, childSize.width);
-            size.height += childSize.height;
-        }
-        return size;
-    }
-
-    /**
-     * This utility adds the width of a child component to an overall size. The
-     * width is maximized with child's width and the child's height is ignored.
-     * If the child figure is not visible, it's size is not added.
-     * 
-     * @param size current dimensions - modified with the result
-     * @param child child figure
-     * @return new Dimension with child width added
-     */
-    protected static Dimension addChildWidth(Dimension size, 
-            Fig child) {
-        if (child.isVisible()) {
-            Dimension childSize = child.getMinimumSize();
-            size.width = Math.max(size.width, childSize.width);
-        }
-        return size;
-    }
-
-    /**
      * @param compartment the compartment to be changed
      * @param isVisible true if the attribute compartment is visible
      *

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java?view=diff&pathrev=17371&r1=17370&r2=17371
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java	2009-10-05 11:37:12-0700
@@ -1000,7 +1000,10 @@
      * This algorithm makes the box grow 
      * (if the calculated minimum size grows), 
      * but then it can never shrink again 
-     * (not even if the calculated minimum size is smaller).
+     * (not even if the calculated minimum size is smaller).<p>
+     * 
+     * If the user can not resize the fig, e.g. like the FigActor, 
+     * then we return the minimum size.
      */
     protected void updateBounds() {
         if (!checkSize) {
@@ -1008,9 +1011,13 @@
         }
         Rectangle bbox = getBounds();
         Dimension minSize = getMinimumSize();
-        bbox.width = Math.max(bbox.width, minSize.width);
-        bbox.height = Math.max(bbox.height, minSize.height);
-        setBounds(bbox.x, bbox.y, bbox.width, bbox.height);
+        if (isResizable()) {
+            bbox.width = Math.max(bbox.width, minSize.width);
+            bbox.height = Math.max(bbox.height, minSize.height);
+            setBounds(bbox.x, bbox.y, bbox.width, bbox.height);
+        } else {
+            setBounds(bbox.x, bbox.y, minSize.width, minSize.height);
+        }
     }
 
     /*
@@ -1927,8 +1934,8 @@
     /**
      * @param bp the bigPort, which is the port where edges 
      *          connect to this node
-     * @deprecated by MVW since V0.28.1. Use makeBigPortFig instead, 
-     *          to guarantee correct initialization.
+     * @deprecated by MVW since V0.28.1. Use {@link #createBigPortFig} 
+     *          instead, to guarantee correct initialization.
      */
     protected void setBigPort(Fig bp) {
         this.bigPort = bp;

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/use_case/ui/FigActor.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/use_case/ui/FigActor.java?view=diff&pathrev=17371&r1=17370&r2=17371
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/use_case/ui/FigActor.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/use_case/ui/FigActor.java	2009-10-05 11:37:12-0700
@@ -37,6 +37,7 @@
 
 import org.argouml.model.Model;
 import org.argouml.uml.diagram.DiagramSettings;
+import org.argouml.uml.diagram.ui.ArgoFigUtil;
 import org.argouml.uml.diagram.ui.FigNodeModelElement;
 import org.tigris.gef.base.Selection;
 import org.tigris.gef.presentation.Fig;
@@ -45,16 +46,20 @@
 import org.tigris.gef.presentation.FigRect;
 
 /**
- * Class to display graphics for an Actor in a diagram.
+ * Class to display graphics for an Actor in a diagram. <p>
+ * 
+ * The dimensions of the stick-man figure are fixed at 40 wide by 55 high.
+ * It does not support different line-widths.<p>
+ * 
+ * Stereotypes and the name are shown below the stick-man.<p>
+ * 
+ *  This seems to be the only ArgoUML element where the stereotypes 
+ *  are shown below the name. The UML 1.4.2 standard does not forbid nor 
+ *  prescribe this layout detail.
  */
 public class FigActor extends FigNodeModelElement {
 
     /**
-     * The serialization version - Eclipse generated for rev. 1.40
-     */
-    private static final long serialVersionUID = 7265843766314395713L;
-
-    /**
      * The padding between the actor body and name and the top of the
      * stereotype.
      */
@@ -71,21 +76,13 @@
     private static final int RIGHT_LEG_POSN = 6;
 
     private void constructFigs(Rectangle bounds) {
-        Color fg = getLineColor();
-        Color fill = getFillColor();
-        
-        // Put this rectangle behind the rest, so it goes first
-        FigRect bigPort = new ActorPortFigRect(X0, Y0, 0, 0, this);
+
         FigCircle head =
-            new FigCircle(X0 + 2, Y0, 16, 15, fg, fill);
-        FigLine body = new FigLine(X0 + 10, Y0 + 15, 20, 40, fg);
-        FigLine arms = new FigLine(X0, Y0 + 20, 30, 30, fg);
-        FigLine leftLeg = new FigLine(X0 + 10, Y0 + 30, 15, 55, fg);
-        FigLine rightLeg = new FigLine(X0 + 10, Y0 + 30, 25, 55, fg);
-        body.setLineWidth(LINE_WIDTH);
-        arms.setLineWidth(LINE_WIDTH);
-        leftLeg.setLineWidth(LINE_WIDTH);
-        rightLeg.setLineWidth(LINE_WIDTH);
+            new FigCircle(X0 + 2, Y0, 16, 15);
+        FigLine body = new FigLine(X0 + 10, Y0 + 15, 20, 40);
+        FigLine arms = new FigLine(X0, Y0 + 20, 30, 30);
+        FigLine leftLeg = new FigLine(X0 + 10, Y0 + 30, 15, 55);
+        FigLine rightLeg = new FigLine(X0 + 10, Y0 + 30, 25, 55);
         
         getNameFig().setBounds(X0, Y0 + 45, 20, 20);
 
@@ -98,7 +95,8 @@
                                      0, 0);
         setSuppressCalcBounds(true);
         // add Figs to the FigNode in back-to-front order
-        addFig(bigPort);
+        // Put this rectangle behind the rest, so it goes first
+        addFig(getBigPort());
         addFig(getNameFig());
         addFig(head);
         addFig(body);
@@ -106,8 +104,16 @@
         addFig(leftLeg);
         addFig(rightLeg);
         addFig(getStereotypeFig());
-        setBigPort(bigPort);
-
+        
+        bindPort(getOwner(), getBigPort());
+        setResizable(false);
+        
+        setFilled(true);
+        setFillColor(FILL_COLOR);
+        setLineColor(LINE_COLOR);
+        setLineWidth(LINE_WIDTH);
+        setTextColor(TEXT_COLOR);
+        
         /* Set the drop location in the case of D&D: */
         if (bounds != null) {
             setLocation(bounds.x, bounds.y);
@@ -117,6 +123,11 @@
         setBounds(getBounds());
     }
     
+    @Override
+    protected Fig createBigPortFig() {
+        return new ActorPortFigRect(X0, Y0, 0, 0, this);
+    }
+
     /**
      * Construct a new Actor with the given owner, bounds, and settings.  This
      * constructor is used by the PGML parser.
@@ -125,52 +136,40 @@
      * @param bounds position and size
      * @param settings rendering settings
      */
-    public FigActor(Object owner, Rectangle bounds, DiagramSettings settings) {
+    public FigActor(Object owner, Rectangle bounds, 
+            DiagramSettings settings) {
         super(owner, bounds, settings);
         constructFigs(bounds);
     }
 
-    /*
-     * @see org.tigris.gef.presentation.Fig#setLineWidth(int)
-     */
     @Override
     public void setLineWidth(int width) {
-        // Miss out the text fix, this should have no line
-        for (int i = HEAD_POSN; i < RIGHT_LEG_POSN; i++) {
-            Fig f = getFigAt(i);
-            if (f != null) {
-                f.setLineWidth(width);
-            }
-        }
-        getFigAt(HEAD_POSN).setLineWidth(width);
-        getFigAt(BODY_POSN).setLineWidth(width);
-        getFigAt(ARMS_POSN).setLineWidth(width);
-        getFigAt(LEFT_LEG_POSN).setLineWidth(width);
-        getFigAt(RIGHT_LEG_POSN).setLineWidth(width);
+        /* This sets the lineWidth of all in the group: */
+        super.setLineWidth(width);
+        /* NameFig and StereotypeFig are handled by parent. */
+    }
+    
+    @Override
+    public void setFillColor(Color col) {
+        super.setFillColor(col);
+        getStereotypeFig().setFillColor(null);
+        getNameFig().setFillColor(null);
     }
 
-    /*
-     * @see org.tigris.gef.presentation.Fig#setFilled(boolean)
-     */
     @Override
     public void setFilled(boolean filled) {
+        super.setFilled(filled);
+        getBigPort().setFilled(false);
+        getNameFig().setFilled(false);
+        getStereotypeFig().setFilled(false);
         // Only the head should be filled (not the text)
-        getFigAt(HEAD_POSN).setFilled(filled);
     }
 
-
-    /*
-     * @see org.tigris.gef.presentation.Fig#makeSelection()
-     */
     @Override
     public Selection makeSelection() {
         return new SelectionActor(this);
     }
 
-    /*
-     * @see org.tigris.gef.ui.PopupGenerator#getPopUpActions(
-     *         java.awt.event.MouseEvent)
-     */
     @Override
     public Vector getPopUpActions(MouseEvent me) {
         Vector popUpActions = super.getPopUpActions(me);
@@ -181,40 +180,31 @@
         return popUpActions;
     }
 
-    /*
-     * @see org.tigris.gef.presentation.Fig#isResizable()
-     */
     @Override
     public boolean isResizable() {
         return false;
     }
 
-    /*
-     * @see org.tigris.gef.presentation.Fig#getMinimumSize()
-     */
     @Override
     public Dimension getMinimumSize() {
-        Dimension nameDim = getNameFig().getMinimumSize();
-        int w = Math.max(nameDim.width, 40);
-        int h = nameDim.height + 55;
-        if (getStereotypeFig().isVisible()) {
-            Dimension stereoDim = getStereotypeFig().getMinimumSize();
-            w = Math.max(stereoDim.width, w);
-            h = h + stereoDim.height;
-        }
-        return new Dimension(w, h);
+        Dimension aSize = new Dimension(40, 55);
+        aSize = ArgoFigUtil.addChildDimensions(aSize, getNameFig());
+        aSize = ArgoFigUtil.addChildDimensions(aSize, getStereotypeFig());
+        return aSize;
     }
 
-    /*
-     * @see org.tigris.gef.presentation.Fig#setBoundsImpl(int, int, int, int)
-     */
     @Override
-    protected void setBoundsImpl(final int x, final int y, 
+    protected void setStandardBounds(final int x, final int y, 
             final int w, final int h) {
-        int middle = x + w / 2;
 
         Rectangle oldBounds = getBounds();
-        getBigPort().setBounds(x, y, w, h);
+        
+        // Make sure we don't try to set things smaller than the minimum
+        Dimension minimumSize = getMinimumSize();
+        int newW = Math.max(w, minimumSize.width);
+        int newH = Math.max(h, minimumSize.height);
+
+        int middle = x + newW / 2;
 
         getFigAt(HEAD_POSN).setLocation(
                 middle - getFigAt(HEAD_POSN).getWidth() / 2, y + 10);
@@ -233,35 +223,20 @@
 
         if (getStereotypeFig().isVisible()) {
             Dimension minStereoSize = getStereotypeFig().getMinimumSize();
-            assert minStereoSize.width <= w;
+            assert minStereoSize.width <= newW;
             getStereotypeFig().setBounds(middle - minStereoSize.width / 2,
                     y + 55 + getNameFig().getHeight(),
                     minStereoSize.width, 
                     minStereoSize.height);
         }
+
+        getBigPort().setBounds(x, y, newW, newH);
+
         calcBounds(); //Accumulate a bounding box for all the Figs in the group.
         firePropChange("bounds", oldBounds, getBounds());
         updateEdges();
     }
 
-    /**
-     * Overruled the parent implementation, to always use the minimum size.
-     * 
-     * @see org.argouml.uml.diagram.ui.FigNodeModelElement#updateBounds()
-     */
-    @Override
-    protected void updateBounds() {
-        if (!isCheckSize()) {
-            return;
-        }
-        Rectangle bbox = getBounds();
-        Dimension minSize = getMinimumSize();
-        setBounds(bbox.x, bbox.y, minSize.width, minSize.height);
-    }
-
-    /*
-     * @see org.tigris.gef.presentation.FigNode#deepHitPort(int, int)
-     */
     @Override
     public Object deepHitPort(int x, int y) {
         Object o = super.deepHitPort(x, y);
@@ -305,9 +280,6 @@
         return ret;
     }
 
-    /*
-     * @see org.argouml.uml.diagram.ui.FigNodeModelElement#modelChanged(java.beans.PropertyChangeEvent)
-     */
     @Override
     protected void modelChanged(PropertyChangeEvent mee) {
         //      name updating
@@ -338,10 +310,10 @@
     }
 
     /**
-     * The bigport needs to overrule the getGravityPoints,
+     * The bigPort needs to overrule the getGravityPoints,
      * because it is the port of this FigNode.
      *
-     * @author [email protected]
+     * @author mvw
      */
     static class ActorPortFigRect extends FigRect {
         /**
@@ -372,10 +344,16 @@
             return parent.getGravityPoints();
         }
 
-        /**
-         * The serial version - Eclipse generated for Rev. 1.40
-         */
-        private static final long serialVersionUID = 5973857118854162659L;
+        @Override
+        public void setFilled(boolean f) {
+            super.setFilled(false);
+        }
+
+        @Override
+        public void setLineWidth(int w) {
+            super.setLineWidth(0);
+        }
+
     }
 
 }

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

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.