svn commit: r13446 - trunk/src_new/org/argouml/uml/diagram/use_case/ui/FigUseCase.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: mvw
Date: 2007-08-25 01:58:42-0700
New Revision: 13446

Modified:
   trunk/src_new/org/argouml/uml/diagram/use_case/ui/FigUseCase.java

Log:
ExtensionPoints did not show for larger fonts - fixed.
Still a lot of potential improvements here!

Modified: trunk/src_new/org/argouml/uml/diagram/use_case/ui/FigUseCase.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/use_case/ui/FigUseCase.java?view=diff&rev=13446&p1=trunk/src_new/org/argouml/uml/diagram/use_case/ui/FigUseCase.java&p2=trunk/src_new/org/argouml/uml/diagram/use_case/ui/FigUseCase.java&r1=13445&r2=13446
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/use_case/ui/FigUseCase.java	(original)
+++ trunk/src_new/org/argouml/uml/diagram/use_case/ui/FigUseCase.java	2007-08-25 01:58:42-0700
@@ -542,8 +542,9 @@
                 minSize.width = Math.max(minSize.width, elemWidth);
             }
 
-            // Height allows one row for each extension point 
-            minSize.height += ROWHEIGHT * Math.max(1, figs.size());
+            // Height allows one row for each extension point
+            int rowHeight = Math.max(ROWHEIGHT, minSize.height);
+            minSize.height += rowHeight * Math.max(1, figs.size());
         }
 
         return minSize;
@@ -653,16 +654,14 @@
             // the separator
             currY += 1 + SPACER;
 
-            // Use the utility routine getUpdatedSize to move the extension
-            // point figures. We can discard the result of this routine. For
+            // Move the extension point figures. For
             // now we assume that extension points are the width of the overall
             // text rectangle (true unless the name is wider than any EP).
-            updateFigGroupSize(epVec,
-                    	   x + ((newW - textSize.width) / 2),
-                    	   currY,
-                    	   textSize.width,
-                    	   (textSize.height - nameSize.height
-                    	    - SPACER * 2 - 1));
+            updateFigGroupSize(
+               	   x + ((newW - textSize.width) / 2),
+               	   currY,
+               	   textSize.width,
+               	   (textSize.height - nameSize.height - SPACER * 2 - 1));
         }
 
         // Set the bounds of the bigPort and cover
@@ -683,16 +682,14 @@
     }
 
     /**
-     * Returns the new size of the FigGroup (either attributes or operations)
+     * Calculates the new size of the FigGroup (based on its extensionpoints)
      * after calculation new bounds for all sub-figs, considering their minimal
      * sizes; FigGroup need not be displayed; no update event is fired.
-     * TODO: This is a duplicate method from FigEditableCompartment
-     * it should just be in one place.<p>
-     *
-     * This method has side effects that are sometimes used.
+     * This used to be a duplicate method from FigEditableCompartment. <p>
+     * 
+     * TODO: Follow the improvements done to 
+     * the similar code in FigEditableCompartment. 
      *
-     * @param fg
-     *            the FigGroup to be updated
      * @param x
      *            x
      * @param y
@@ -701,41 +698,37 @@
      *            w
      * @param h
      *            h
-     * @return the new dimension
      */
-    protected Dimension updateFigGroupSize(FigGroup fg, int x, int y, int w,
+    protected void updateFigGroupSize(int x, int y, int w,
             int h) {
         int newW = w;
-        int n = fg.getFigs().size() - 1;
+        int n = epVec.getFigs().size() - 1;
         int newH =
             isCheckSize() ? Math.max(h, ROWHEIGHT * Math.max(1, n) + 2)
                 : h;
-        int step = (n > 0) ? (newH - 1) / n : 0;
-        // width step between FigText objects int maxA =
-        // Toolkit.getDefaultToolkit().getFontMetrics(LABEL_FONT)
-        // .getMaxAscent();
 
         // set new bounds for all included figs
-        Iterator figs = fg.iterator();
-        Fig myBigPort = (Fig) figs.next();
+        Iterator figs = epVec.iterator();
+        figs.next(); // skip epBigPort
         Fig fi;
-        int fw, yy = y;
+        int fw, fh;
+        int yy = y;
         while (figs.hasNext()) {
             fi = (Fig) figs.next();
             fw = fi.getMinimumSize().width;
+            fh = fi.getMinimumSize().height;
             if (!isCheckSize() && fw > newW - 2) {
                 fw = newW - 2;
             }
-            fi.setBounds(x + 1, yy + 1, fw, Math.min(ROWHEIGHT, step) - 2);
+            fi.setBounds(x + 1, yy + 1, fw, fh/* - 2*/);
             if (isCheckSize() && newW < fw + 2) {
                 newW = fw + 2;
             }
-            yy += step;
+            yy += fh;
         }
-        myBigPort.setBounds(x, y, newW, newH);
-        // rectangle containing all following FigText objects
-        fg.calcBounds();
-        return new Dimension(newW, newH);
+        epBigPort.setBounds(x, y, newW, newH);
+        // calculate the rectangle containing all FigText objects:
+        epVec.calcBounds();
     }
 
     /**
@@ -1215,7 +1208,8 @@
                     
                     epFig.setFilled(false);
                     epFig.setLineWidth(0);
-                    epFig.setFont(getProject().getProjectSettings().getFontPlain());
+                    epFig.setFont(
+                            getProject().getProjectSettings().getFontPlain());
                     epFig.setTextColor(Color.black);
                     epFig.setJustification(FigText.JUSTIFY_LEFT);
                     epFig.setReturnAction(FigText.END_EDITING);
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.