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

Tom Morris <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2009-01-19 14:08:38-0800
New Revision: 16660

Modified:
   trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClass.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClassifierBoxWithAttributes.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigDataType.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigEnumeration.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigInterface.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigStereotypeDeclaration.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartmentBox.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEditableCompartment.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNameWithAbstract.java

Log:
Issue 5591: Compute initial sizes more accurately
http://argouml.tigris.org/issues/show_bug.cgi?id=5591

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClass.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClass.java?view=diff&pathrev=16660&r1=16659&r2=16660
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClass.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClass.java	2009-01-19 14:08:38-0800
@@ -60,10 +60,8 @@
      * outlines.<p>
      *
      * <em>Warning</em>. Much of the graphics positioning is hard
-     * coded. The overall figure is placed at location (10,10). The
-     * name compartment (in the parent
-     * {@link org.argouml.uml.diagram.ui.FigNodeModelElement} is
-     * 21 pixels high. The stereotype compartment is created 15 pixels
+     * coded. The overall figure is placed at location (10,10). 
+     * The stereotype compartment is created 15 pixels
      * high in the parent, but we change it to 19 pixels, 1 more than
      * ({@link #STEREOHEIGHT} here. The attribute and operations boxes
      * are created at 19 pixels, 2 more than {@link #ROWHEIGHT}.<p>
@@ -96,10 +94,8 @@
      * outlines.<p>
      *
      * <em>Warning</em>. Much of the graphics positioning is hard
-     * coded. The overall figure is placed at location (10,10). The
-     * name compartment (in the parent
-     * {@link org.argouml.uml.diagram.ui.FigNodeModelElement} is
-     * 21 pixels high. The stereotype compartment is created 15 pixels
+     * coded. The overall figure is placed at location (10,10). 
+     * The stereotype compartment is created 15 pixels
      * high in the parent, but we change it to 19 pixels, 1 more than
      * ({@link #STEREOHEIGHT} here. The attribute and operations boxes
      * are created at 19 pixels, 2 more than {@link #ROWHEIGHT}.<p>
@@ -139,10 +135,8 @@
      * outlines.<p>
      *
      * <em>Warning</em>. Much of the graphics positioning is hard
-     * coded. The overall figure is placed at location (10,10). The
-     * name compartment (in the parent
-     * {@link org.argouml.uml.diagram.ui.FigNodeModelElement} is
-     * 21 pixels high. The stereotype compartment is created 15 pixels
+     * coded. The overall figure is placed at location (10,10). 
+     * The stereotype compartment is created 15 pixels
      * high in the parent, but we change it to 19 pixels, 1 more than
      * ({@link #STEREOHEIGHT} here. The attribute and operations boxes
      * are created at 19 pixels, 2 more than {@link #ROWHEIGHT}.<p>
@@ -155,7 +149,8 @@
             DiagramSettings settings) {
         super(element, bounds, settings);
         constructFigs();
-        renderingChanged(); // fix for issue 5591
+        Rectangle r = getBounds();
+        setStandardBounds(r.x, r.y, r.width, r.height);
     }
 
     /*

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClassifierBoxWithAttributes.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClassifierBoxWithAttributes.java?view=diff&pathrev=16660&r1=16659&r2=16660
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClassifierBoxWithAttributes.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClassifierBoxWithAttributes.java	2009-01-19 14:08:38-0800
@@ -24,7 +24,6 @@
 
 package org.argouml.uml.diagram.static_structure.ui;
 
-import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Rectangle;
 import java.util.HashSet;
@@ -32,6 +31,7 @@
 
 import javax.swing.Action;
 
+import org.apache.log4j.Logger;
 import org.argouml.model.AddAssociationEvent;
 import org.argouml.model.AssociationChangeEvent;
 import org.argouml.model.AttributeChangeEvent;
@@ -52,6 +52,9 @@
 public class FigClassifierBoxWithAttributes extends FigClassifierBox 
     implements AttributesCompartmentContainer {
 
+    private static final Logger LOG = 
+        Logger.getLogger(FigClassifierBoxWithAttributes.class);
+    
     private FigAttributesCompartment attributesFigCompartment;
 
     /**
@@ -87,7 +90,7 @@
     }
 
     /**
-     * @return The vector of graphics for operations (if any).
+     * @return The vector of graphics for the uml attributes (if any).
      * First one is the rectangle for the entire operations box.
      */
     protected FigAttributesCompartment getAttributesFig() {
@@ -248,8 +251,8 @@
         // name compartment and build up.
 
         Dimension aSize = getNameFig().getMinimumSize();
-        aSize.height += 4; // +2 padding above and below name
-        aSize.height = Math.max(21, aSize.height);
+        aSize.height += NAME_V_PADDING * 2;
+        aSize.height = Math.max(NAME_FIG_HEIGHT, aSize.height);
 
         aSize = addChildDimensions(aSize, getStereotypeFig());
         aSize = addChildDimensions(aSize, getAttributesFig());
@@ -268,40 +271,35 @@
      * equally distributed among all figs (i.e. compartments), such that the
      * cumulated height of all visible figs equals the demanded height<p>.
      *
-     * Some of this has "magic numbers" hardcoded in. In particular there is
-     * a knowledge that the minimum height of a name compartment is 21
-     * pixels.<p>
+     * Some of this has "magic numbers" hardcoded in.<p>
      *
      * @param x  Desired X coordinate of upper left corner
      *
      * @param y  Desired Y coordinate of upper left corner
      *
-     * @param w  Desired width of the FigClass
+     * @param width  Desired width of the FigClass
      *
-     * @param h  Desired height of the FigClass
+     * @param height  Desired height of the FigClass
      * 
      * @see org.tigris.gef.presentation.Fig#setBoundsImpl(int, int, int, int)
      */
     @Override
-    protected void setStandardBounds(final int x, final int y, final int w,
-            final int h) {
+    protected void setStandardBounds(final int x, final int y, final int width,
+            final int height) {
 
         // Save our old boundaries so it can be used in property message later
         Rectangle oldBounds = getBounds();
 
+        // Make sure we don't try to set things smaller than the minimum
+        int w = Math.max(width, getMinimumSize().width);
+        int h = Math.max(height, getMinimumSize().height);
+        
         // set bounds of big box
         getBigPort().setBounds(x, y, w, h);
         if (borderFig != null) {
             borderFig.setBounds(x, y, w, h);
         }
         
-        // Save our old boundaries (needed later), and get minimum size
-        // info. "whitespace" will be used to maintain a running calculation
-        // of our size at various points.
-        final int whitespace = h - getMinimumSize().height;
-
-        getNameFig().setLineWidth(0);
-        getNameFig().setLineColor(Color.red);  // TODO: Debug color?
         int currentHeight = 0;
 
         if (getStereotypeFig().isVisible()) {
@@ -322,7 +320,8 @@
             int attributesHeight = 
                 attributesFigCompartment.getMinimumSize().height;
             if (isOperationsVisible()) {
-                attributesHeight += whitespace / 2;
+                attributesHeight = Math.max(attributesHeight, 
+                        (h - currentHeight) / 2);
             }
             attributesFigCompartment.setBounds(
                     x,
@@ -334,7 +333,7 @@
 
         if (isOperationsVisible()) {
             int operationsY = y + currentHeight;
-            int operationsHeight = (h + y) - operationsY - 1;
+            int operationsHeight = (h + y) - operationsY - LINE_WIDTH;
             if (operationsHeight < getOperationsFig().getMinimumSize().height) {
                 operationsHeight = getOperationsFig().getMinimumSize().height;
             }
@@ -351,6 +350,8 @@
 
         calcBounds();
         updateEdges();
+        LOG.debug("Bounds change : old - " + oldBounds + ", new - " 
+                + getBounds());
         firePropChange("bounds", oldBounds, getBounds());
     }
 

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigDataType.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigDataType.java?view=diff&pathrev=16660&r1=16659&r2=16660
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigDataType.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigDataType.java	2009-01-19 14:08:38-0800
@@ -24,7 +24,6 @@
 
 package org.argouml.uml.diagram.static_structure.ui;
 
-import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Rectangle;
 
@@ -53,6 +52,8 @@
 public class FigDataType extends FigClassifierBox {
 
     private static final Logger LOG = Logger.getLogger(FigDataType.class);
+    
+    private static final int MIN_WIDTH = 40;
 
     /**
      * Main constructor for a {@link FigDataType}.
@@ -67,9 +68,8 @@
      * appropriately. The main boxes are all filled and have outlines.<p>
      * 
      * <em>Warning</em>. Much of the graphics positioning is hard coded. The
-     * overall figure is placed at location (10,10). The name compartment (in
-     * the parent {@link org.argouml.uml.diagram.ui.FigNodeModelElement}
-     * is 21 pixels high. The stereotype compartment is created 15 pixels high
+     * overall figure is placed at location (10,10). 
+     * The stereotype compartment is created 15 pixels high
      * in the parent, but we change it to 19 pixels, 1 more than
      * ({@link #STEREOHEIGHT} here. The operations box is created at 19 pixels,
      * 2 more than {@link #ROWHEIGHT}.<p>
@@ -90,7 +90,6 @@
     private void constructFigs() {
         getStereotypeFig().setKeyword(getKeyword());
 
-
         setSuppressCalcBounds(true);
         addFig(getBigPort());
         addFig(getStereotypeFig());
@@ -100,9 +99,9 @@
 
         setSuppressCalcBounds(false);
 
-        // Set the bounds of the figure to the total of the above (hardcoded)
+        // Set the bounds of the figure to the total of the above 
         enableSizeChecking(true);
-        setBounds(X0, Y0, WIDTH, 21 + ROWHEIGHT);
+        super.setStandardBounds(X0, Y0, WIDTH, NAME_FIG_HEIGHT + ROWHEIGHT);
     }
 
     /**
@@ -136,9 +135,8 @@
      * appropriately. The main boxes are all filled and have outlines.<p>
      * 
      * <em>Warning</em>. Much of the graphics positioning is hard coded. The
-     * overall figure is placed at location (10,10). The name compartment (in
-     * the parent {@link org.argouml.uml.diagram.ui.FigNodeModelElement}
-     * is 21 pixels high. The stereotype compartment is created 15 pixels high
+     * overall figure is placed at location (10,10).
+     * The stereotype compartment is created 15 pixels high
      * in the parent, but we change it to 19 pixels, 1 more than
      * ({@link #STEREOHEIGHT} here. The operations box is created at 19 pixels,
      * 2 more than {@link #ROWHEIGHT}.
@@ -188,8 +186,7 @@
     /**
      * Gets the minimum size permitted for a datatype on the diagram.<p>
      *
-     * Parts of this are hardcoded, notably the fact that the name
-     * compartment has a minimum height of 21 pixels.<p>
+     * Parts of this are hardcoded with magic numbers.<p>
      *
      * @return  the size of the minimum bounding box.
      */
@@ -200,9 +197,8 @@
 
         Dimension aSize = getNameFig().getMinimumSize();
 
-        // +2 padding before and after name
-        aSize.height += 4;
-        aSize.height = Math.max(21, aSize.height);
+        aSize.height += NAME_V_PADDING * 2;
+        aSize.height = Math.max(NAME_FIG_HEIGHT, aSize.height);
 
         // If we have a stereotype displayed, then allow some space for that
         // (width and height)
@@ -210,7 +206,7 @@
         aSize = addChildDimensions(aSize, getOperationsFig());
 
         // we want to maintain a minimum width for datatypes
-        aSize.width = Math.max(40, aSize.width);
+        aSize.width = Math.max(MIN_WIDTH, aSize.width);
 
         return aSize;
     }
@@ -313,11 +309,7 @@
      *
      * If the required height is bigger, then the additional height is
      * equally distributed among all figs (i.e. compartments), such that the
-     * cumulated height of all visible figs equals the demanded height<p>.
-     *
-     * Some of this has "magic numbers" hardcoded in. In particular there is
-     * a knowledge that the minimum height of a name compartment is 21
-     * pixels.<p>
+     * accumulated height of all visible figs equals the demanded height<p>.
      *
      * @param x  Desired X coordinate of upper left corner
      *
@@ -332,22 +324,14 @@
     protected void setStandardBounds(final int x, final int y, final int w,
             final int h) {
 
+        // Save our old boundaries to use in our property message later
         Rectangle oldBounds = getBounds();
-        // Save our old boundaries (needed later), and get minimum size
-        // info. "aSize will be used to maintain a running calculation of our
-        // size at various points.
-
-        // "extra_each" is the extra height per displayed fig if requested
-        // height is greater than minimal. "height_correction" is the height
-        // correction due to rounded division result, will be added to the name
-        // compartment
+        // and get minimum size info.
 
         // set bounds of big box
         getBigPort().setBounds(x, y, w, h);
         borderFig.setBounds(x, y, w, h);
 
-        getNameFig().setLineWidth(0);
-        getNameFig().setLineColor(Color.red); // TODO: debug color?
         int currentHeight = 0;
 
         if (getStereotypeFig().isVisible()) {
@@ -366,7 +350,7 @@
 
         if (getOperationsFig().isVisible()) {
             int operationsY = y + currentHeight;
-            int operationsHeight = (h + y) - operationsY - 1;
+            int operationsHeight = (h + y) - operationsY - LINE_WIDTH;
             getOperationsFig().setBounds(
                     x,
                     operationsY,

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigEnumeration.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigEnumeration.java?view=diff&pathrev=16660&r1=16659&r2=16660
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigEnumeration.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigEnumeration.java	2009-01-19 14:08:38-0800
@@ -233,7 +233,9 @@
         // Start with the minimum for our parent
         Dimension aSize = super.getMinimumSize();
 
-        aSize = addChildDimensions(aSize, literalsCompartment);
+        if (literalsCompartment != null) {
+            aSize = addChildDimensions(aSize, literalsCompartment);
+        }
         
         return aSize;
     }
@@ -242,23 +244,19 @@
      * @see org.tigris.gef.presentation.Fig#setBoundsImpl(int, int, int, int)
      */
     @Override
-    protected void setStandardBounds(final int x, final int y, final int w,
-            final int h) {
+    protected void setStandardBounds(final int x, final int y, final int width,
+            final int height) {
 
         // Save our old boundaries so it can be used in property message later
         Rectangle oldBounds = getBounds();
 
+        int w = Math.max(width, getMinimumSize().width);
+        int h = Math.max(height, getMinimumSize().height);
+        
         // set bounds of big box
         getBigPort().setBounds(x, y, w, h);
         borderFig.setBounds(x, y, w, h);
-
-        getNameFig().setLineWidth(0);
         
-        // Vertical whitespace to be distributed
-        // TODO: This continually adds more whitespace.  Figure out the problem.
-        //final int whitespace = Math.max(0, h - getMinimumSize().height);
-        final int whitespace = 0;
-                
         int currentHeight = 0;
 
         if (getStereotypeFig().isVisible()) {
@@ -275,10 +273,13 @@
         getNameFig().setBounds(x, y + currentHeight, w, nameHeight);
         currentHeight += nameHeight;
 
+        int visibleCompartments = getOperationsFig().isVisible() ? 1 : 0;
         if (getLiteralsCompartment().isVisible()) {
+            visibleCompartments++;
             int literalsHeight = 
                 getLiteralsCompartment().getMinimumSize().height;
-            literalsHeight += whitespace / 2;
+            literalsHeight = Math.max(literalsHeight, 
+                    (h - currentHeight) / visibleCompartments);
             getLiteralsCompartment().setBounds(
                     x,
                     y + currentHeight,
@@ -289,7 +290,7 @@
         
         if (getOperationsFig().isVisible()) {
             int operationsHeight = getOperationsFig().getMinimumSize().height;
-            operationsHeight += whitespace / 2;
+            operationsHeight = Math.max(operationsHeight, h - currentHeight);
             getOperationsFig().setBounds(
                     x,
                     y + currentHeight,

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigInterface.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigInterface.java?view=diff&pathrev=16660&r1=16659&r2=16660
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigInterface.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigInterface.java	2009-01-19 14:08:38-0800
@@ -24,7 +24,6 @@
 
 package org.argouml.uml.diagram.static_structure.ui;
 
-import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Rectangle;
 
@@ -66,9 +65,8 @@
      * bottom line, and avoid three compartments showing.<p>
      *
      * <em>Warning</em>. Much of the graphics positioning is hard coded. The
-     * overall figure is placed at location (10,10). The name compartment (in
-     * the parent {@link org.argouml.uml.diagram.ui.FigNodeModelElement}
-     * is 21 pixels high. The stereotype compartment is created 15 pixels high
+     * overall figure is placed at location (10,10).
+     * The stereotype compartment is created 15 pixels high
      * in the parent, but we change it to 19 pixels, 1 more than
      * ({@link #STEREOHEIGHT} here. The operations box is created at 19 pixels,
      * 2 more than {@link #ROWHEIGHT}.<p>
@@ -98,17 +96,23 @@
         // we're all done for efficiency.
         enableSizeChecking(false);
         setSuppressCalcBounds(true);
+        
+        Dimension size = new Dimension(0, 0);
+        
         addFig(getBigPort());
         addFig(getStereotypeFig());
+        addChildDimensions(size, getStereotypeFig());
         addFig(getNameFig());
+        addChildDimensions(size, getNameFig());
         addFig(getOperationsFig());
+        addChildDimensions(size, getOperationsFig());
         addFig(borderFig);
 
         setSuppressCalcBounds(false);
 
-        // Set the bounds of the figure to the total of the above (hardcoded)
+        // Set the bounds of the figure to the total of the above 
         enableSizeChecking(true);
-        setBounds(X0, Y0, WIDTH, 21 + ROWHEIGHT);
+        setBounds(X0, Y0, size.width, size.height);
     }
 
     /**
@@ -151,47 +155,11 @@
         return new SelectionInterface(this);
     }
 
-    /*
-     * @see org.argouml.uml.diagram.ui.FigCompartmentBox#setOperationsVisible(boolean)
-     * 
-     * TODO: This differs only very slightly from the version in the superclass
-     *       It probably can be merged, but I don't have time to verify
-     *       right now. - tfm - 20070109
-     */
-    public void setOperationsVisible(boolean isVisible) {
-        Rectangle rect = getBounds();
-        int h =
-                isCheckSize() ? ((ROWHEIGHT
-                * Math.max(1, getOperationsFig().getFigs().size() - 1) + 2)
-                * rect.height / getMinimumSize().height) : 0;
-        if (isOperationsVisible()) {
-            // TODO: Can these two legs be collapsed?  They differ only in the
-            // order the damage() method is invoked in
-            if (!isVisible) {
-                damage();
-                for (Object f : getOperationsFig().getFigs()) {
-                    ((Fig) f).setVisible(isVisible);
-                }
-                getOperationsFig().setVisible(isVisible);
-                setBounds(rect.x, rect.y, rect.width, rect.height - h);
-            }
-        } else {
-            if (isVisible) {
-                for (Object f : getOperationsFig().getFigs()) {
-                    ((Fig) f).setVisible(isVisible);
-                }
-                getOperationsFig().setVisible(isVisible);
-                setBounds(rect.x, rect.y, rect.width, rect.height + h);
-                damage();
-            }
-        }
-    }
 
     /**
      * Gets the minimum size permitted for an interface on the diagram.<p>
      *
-     * Parts of this are hardcoded, notably the fact that the name
-     * compartment has a minimum height of 21 pixels.<p>
+     * Parts of this are hardcoded.<p>
      *
      * @return  the size of the minimum bounding box.
      */
@@ -202,9 +170,8 @@
 
         Dimension aSize = getNameFig().getMinimumSize();
 
-        // +2 padding before and after name
-        aSize.height += 4;
-        aSize.height = Math.max(21, aSize.height);
+        aSize.height += NAME_V_PADDING * 2;
+        aSize.height = Math.max(NAME_FIG_HEIGHT, aSize.height);
 
         // If we have a stereotype displayed, then allow some space for that
         // (width and height)
@@ -217,21 +184,6 @@
         return aSize;
     }
 
-    /*
-     * @see org.tigris.gef.presentation.Fig#setLineWidth(int)
-     */
-    @Override
-    public void setLineWidth(int w) {
-        borderFig.setLineWidth(w);
-    }
-
-    /*
-     * @see org.tigris.gef.presentation.Fig#getLineWidth()
-     */
-    @Override
-    public int getLineWidth() {
-        return borderFig.getLineWidth();
-    }
 
     /*
      * @see org.tigris.gef.presentation.Fig#translate(int, int)
@@ -323,9 +275,7 @@
      * equally distributed among all figs (i.e. compartments), such that the
      * cumulated height of all visible figs equals the demanded height<p>.
      *
-     * Some of this has "magic numbers" hardcoded in. In particular there is
-     * a knowledge that the minimum height of a name compartment is 21
-     * pixels.<p>
+     * Some of this has "magic numbers" hardcoded in.<p>
      *
      * @param x  Desired X coordinate of upper left corner
      *
@@ -339,22 +289,14 @@
     protected void setStandardBounds(final int x, final int y, final int w,
             final int h) {
 
-        Rectangle oldBounds = getBounds();
         // Save our old boundaries (needed later), and get minimum size
-        // info. "aSize will be used to maintain a running calculation of our
-        // size at various points.
-
-        // "extra_each" is the extra height per displayed fig if requested
-        // height is greater than minimal. "height_correction" is the height
-        // correction due to rounded division result, will be added to the name
-        // compartment
+        // info. 
+        Rectangle oldBounds = getBounds();
 
         // set bounds of big box
         getBigPort().setBounds(x, y, w, h);
         borderFig.setBounds(x, y, w, h);
 
-        getNameFig().setLineWidth(0);
-        getNameFig().setLineColor(Color.red); // TODO: DEBUG_COLOR?
         int currentHeight = 0;
 
         if (getStereotypeFig().isVisible()) {

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigStereotypeDeclaration.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigStereotypeDeclaration.java?view=diff&pathrev=16660&r1=16659&r2=16660
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigStereotypeDeclaration.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigStereotypeDeclaration.java	2009-01-19 14:08:38-0800
@@ -24,7 +24,6 @@
 
 package org.argouml.uml.diagram.static_structure.ui;
 
-import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Rectangle;
 import java.awt.event.MouseEvent;
@@ -57,9 +56,6 @@
  */
 public class FigStereotypeDeclaration extends FigCompartmentBox {
 
-    /**
-     * The UID.
-     */
     private static final long serialVersionUID = -2702539988691983863L;
     
     /**
@@ -92,7 +88,7 @@
 
         setSuppressCalcBounds(false);
         // Set the bounds of the figure to the total of the above (hardcoded)
-        setBounds(X0, Y0, WIDTH, 22 + 2 * ROWHEIGHT);
+        setBounds(X0, Y0, WIDTH, STEREOHEIGHT + NAME_FIG_HEIGHT);
     }
 
     /**
@@ -200,21 +196,13 @@
      * Sets the bounds, but the size will be at least the one returned by
      * {@link #getMinimumSize()}, unless checking of size is disabled.<p>
      *
-     * If the required height is bigger, then the additional height is
-     * equally distributed among all figs (i.e. compartments), such that the
-     * cumulated height of all visible figs equals the demanded height<p>.
-     *
-     * Some of this has "magic numbers" hardcoded in. In particular there is
-     * a knowledge that the minimum height of a name compartment is 21
-     * pixels.<p>
-     *
      * @param x  Desired X coordinate of upper left corner
      *
      * @param y  Desired Y coordinate of upper left corner
      *
-     * @param w  Desired width of the FigClass
+     * @param w  Desired width of the fig
      *
-     * @param h  Desired height of the FigClass
+     * @param h  Desired height of the fig
      *
      * @see org.tigris.gef.presentation.Fig#setBoundsImpl(int, int, int, int)
      */
@@ -227,14 +215,6 @@
         getBigPort().setBounds(x, y, w, h);
         getBorderFig().setBounds(x, y, w, h);
 
-        // Save our old boundaries (needed later), and get minimum size
-        // info. "whitespace" will be used to maintain a running calculation
-        // of our size at various points.
-
-        // final int whitespace = h - getMinimumSize().height;
-
-        getNameFig().setLineWidth(0);
-        getNameFig().setLineColor(Color.red); // TODO: DEBUG_COLOR?
         int currentHeight = 0;
 
         if (getStereotypeFig().isVisible()) {

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=16660&r1=16659&r2=16660
==============================================================================
--- 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-01-19 14:08:38-0800
@@ -54,7 +54,8 @@
      * Default bounds for a compartment.
      */
     protected static final Rectangle DEFAULT_COMPARTMENT_BOUNDS = new Rectangle(
-            X0, Y0 + 20, WIDTH, ROWHEIGHT + 2);
+            X0, Y0 + 20 /* 20 = height of name fig ?*/, 
+            WIDTH, ROWHEIGHT + 2 /* 2*LINE_WIDTH?  or extra padding? */ );
     
     /**
      * Text highlighted by mouse actions on the diagram.<p>
@@ -79,10 +80,12 @@
      * Initialization shared by all constructors.
      */
     private void initialize() {
-        // Set properties of the stereotype box. Make it 1 pixel higher than
+        // Set properties of the stereotype box. Make it LINE_WIDTH higher than
         // before, so it overlaps the name box, and the blanking takes out both
         // lines. Initially not set to be displayed, but this will be changed
         // when we try to render it, if we find we have a stereotype.
+        // TODO: Overlapping figs won't work with when the colors have alpha
+        // channels
         getStereotypeFig().setFilled(true);
         getStereotypeFig().setLineWidth(LINE_WIDTH);
         // +1 to have 1 pixel overlap with getNameFig()

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEditableCompartment.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEditableCompartment.java?view=diff&pathrev=16660&r1=16659&r2=16660
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEditableCompartment.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEditableCompartment.java	2009-01-19 14:08:38-0800
@@ -28,7 +28,6 @@
 import java.awt.Rectangle;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.log4j.Logger;
@@ -56,7 +55,7 @@
 
     private static final Logger LOG = Logger.getLogger(FigCompartment.class);
 
-    private static final int MIN_HEIGHT = 21;
+    private static final int MIN_HEIGHT = FigNodeModelElement.NAME_FIG_HEIGHT;
 
     private FigSeperator compartmentSeperator;
 
@@ -350,7 +349,7 @@
     /**
      * The minimum width is the minimum width of the widest child element.
      * The minimum height is the total minimum height of all child figs but no
-     * less than MINIMUM_HEIGHT (21) pixels.
+     * less than MINIMUM_HEIGHT pixels.
      * @return the minimum width
      */
     @Override
@@ -370,28 +369,27 @@
         int newW = w;
         int newH = h;
 
-        Iterator figs = iterator();
-        Fig fig;
         int fw;
         int yy = y;
-        while (figs.hasNext()) {
-            fig = (Fig) figs.next();
+        int lineWidth = getLineWidth();
+        for (Fig fig : (List<Fig>) getFigs()) {
             if (fig.isVisible() && fig != getBigPort()) {
                 if (fig instanceof FigSeperator) {
                     fw = w;
                 } else {
                     fw = fig.getMinimumSize().width;
                 }
-                // TODO: Some of these magic numbers probably assume a line
-                // width of 1.  Replace with appropriate constants/variables.
-                fig.setBounds(x + 1, yy + 1, fw, fig.getMinimumSize().height);
-                if (newW < fw + 2) {
-                    newW = fw + 2;
+
+                fig.setBounds(x + lineWidth, yy + lineWidth, fw, 
+                        fig.getMinimumSize().height);
+                if (newW < fw + 2 * lineWidth) {
+                    newW = fw + 2 * lineWidth;
                 }
                 yy += fig.getMinimumSize().height;
             }
         }
-        getBigPort().setBounds(x + 1, y + 1, newW - 3, newH - 1);
+        getBigPort().setBounds(x + lineWidth, y + lineWidth, 
+                newW - 2 * lineWidth, newH - 2 * lineWidth);
         calcBounds();
     }
 

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNameWithAbstract.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNameWithAbstract.java?view=diff&pathrev=16660&r1=16659&r2=16660
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNameWithAbstract.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNameWithAbstract.java	2009-01-19 14:08:38-0800
@@ -78,4 +78,8 @@
         }
         return super.getFigFontStyle() | style;
     }
+    
+    public void setLineWidth(int w) {
+        super.setLineWidth(w);
+    }
 }
\ No newline at end of file

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

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.