Here come some more fixlets for the Swing API.

2006-01-27  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/SwingUtilities.java
        (calculateInsetArea): Removed unneeded method. The method
        calculateInnerArea has the same purpose and is actually specified.
        (calculateInnerArea): Rewritten to not use calculateInsetArea.
        * javax/swing/plaf/basic/BasicMenuItemUI.java
        (paintMenuItem): Use SwingUtilities.calculateInnerArea() instead
        of SwingUtilities.calculateInsetArea().

/Roman
Index: javax/swing/SwingUtilities.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/SwingUtilities.java,v
retrieving revision 1.42
diff -u -r1.42 SwingUtilities.java
--- javax/swing/SwingUtilities.java	19 Jan 2006 22:27:27 -0000	1.42
+++ javax/swing/SwingUtilities.java	27 Jan 2006 10:17:31 -0000
@@ -83,31 +83,6 @@
   {
     // Do nothing.
   }
-  
-  /**
-   * Calculates the portion of the base rectangle which is inside the
-   * insets.
-   *
-   * @param base The rectangle to apply the insets to
-   * @param insets The insets to apply to the base rectangle
-   * @param ret A rectangle to use for storing the return value, or
-   * <code>null</code>
-   *
-   * @return The calculated area inside the base rectangle and its insets,
-   * either stored in ret or a new Rectangle if ret is <code>null</code>
-   *
-   * @see #calculateInnerArea
-   */
-  public static Rectangle calculateInsetArea(Rectangle base, Insets insets,
-                                             Rectangle ret)
-  {
-    if (ret == null)
-      ret = new Rectangle();
-    ret.setBounds(base.x + insets.left, base.y + insets.top,
-                  base.width - (insets.left + insets.right),
-                  base.height - (insets.top + insets.bottom));
-    return ret;
-  }
 
   /**
    * Calculates the portion of the component's bounds which is inside the
@@ -122,13 +97,18 @@
    *
    * @return The calculated area inside the component and its border
    * insets
-   *
-   * @see #calculateInsetArea
    */
   public static Rectangle calculateInnerArea(JComponent c, Rectangle r)
   {
     Rectangle b = getLocalBounds(c);
-    return calculateInsetArea(b, c.getInsets(), r);
+    if (r == null)
+      r = new Rectangle();
+    Insets i = c.getInsets();
+    r.x = b.x + i.left;
+    r.width = b.width - i.left - i.right;
+    r.y = b.y + i.top;
+    r.height = b.height - i.top - i.bottom;
+    return r;
   }
 
   /**
Index: javax/swing/plaf/basic/BasicMenuItemUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java,v
retrieving revision 1.42
diff -u -r1.42 BasicMenuItemUI.java
--- javax/swing/plaf/basic/BasicMenuItemUI.java	4 Jan 2006 16:06:17 -0000	1.42
+++ javax/swing/plaf/basic/BasicMenuItemUI.java	27 Jan 2006 10:17:31 -0000
@@ -610,8 +610,7 @@
     Font f = m.getFont();
     g.setFont(f);
     FontMetrics fm = g.getFontMetrics(f);
-    SwingUtilities.calculateInnerArea(m, br);
-    SwingUtilities.calculateInsetArea(br, m.getInsets(), vr);
+    SwingUtilities.calculateInnerArea(m, vr);
     paintBackground(g, m, background);
 
     /*

Reply via email to