commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commit-cp] classpath ChangeLog java/awt/GridBagConstraints...


From: Thomas Fitzsimmons
Subject: [commit-cp] classpath ChangeLog java/awt/GridBagConstraints...
Date: Sun, 18 Jun 2006 18:56:44 +0000

CVSROOT:        /sources/classpath
Module name:    classpath
Changes by:     Thomas Fitzsimmons <fitzsim>    06/06/18 18:56:44

Modified files:
        .              : ChangeLog 
        java/awt       : GridBagConstraints.java GridBagLayout.java 

Log message:
        2006-06-18  Thomas Fitzsimmons  <address@hidden>
        
                * java/awt/GridBagLayout.java (AdjustForGravity): Implement.
                * java/awt/GridBagConstraints.java: Indent.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.7870&r2=1.7871
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/GridBagConstraints.java?cvsroot=classpath&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/GridBagLayout.java?cvsroot=classpath&r1=1.29&r2=1.30

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/classpath/classpath/ChangeLog,v
retrieving revision 1.7870
retrieving revision 1.7871
diff -u -b -r1.7870 -r1.7871
--- ChangeLog   18 Jun 2006 18:53:42 -0000      1.7870
+++ ChangeLog   18 Jun 2006 18:56:44 -0000      1.7871
@@ -1,3 +1,8 @@
+2006-06-18  Thomas Fitzsimmons  <address@hidden>
+
+       * java/awt/GridBagLayout.java (AdjustForGravity): Implement.
+       * java/awt/GridBagConstraints.java: Indent.
+
 2006-06-18  Tom Tromey  <address@hidden>
 
        * native/jni/gconf-peer/.cvsignore: New file.

Index: java/awt/GridBagConstraints.java
===================================================================
RCS file: /sources/classpath/classpath/java/awt/GridBagConstraints.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- java/awt/GridBagConstraints.java    2 Jul 2005 20:32:25 -0000       1.7
+++ java/awt/GridBagConstraints.java    18 Jun 2006 18:56:44 -0000      1.8
@@ -48,62 +48,99 @@
 {
   static final long serialVersionUID = -1000070633030801713L;
 
-  /** Fill in both directions.  */
-  public static final int BOTH = 1;
-  /** Don't fill.  */
+  // Fill values.
+  /**
+   * Don't fill.
+   */
   public static final int NONE = 0;
-  /** Fill horizontally.  */
+
+  /**
+   * Fill in both directions.
+   */
+  public static final int BOTH = 1;
+
+  /**
+   * Fill horizontally.
+   */
   public static final int HORIZONTAL = 2;
-  /** Fill vertically.  */
+
+  /**
+   * Fill vertically.
+   */
   public static final int VERTICAL = 3;
 
-  /** Position in the center.  */
+  // Anchor values.
+  /**
+   * Position in the center.
+   */
   public static final int CENTER = 10;
-  /** Position to the east.  */
-  public static final int EAST = 13;
-  /** Position to the north.  */
+
+  /**
+   * Position to the north.
+   */
   public static final int NORTH = 11;
-  /** Position to the northeast.  */
+
+  /**
+   * Position to the northeast.
+   */
   public static final int NORTHEAST = 12;
-  /** Position to the northwest.  */
-  public static final int NORTHWEST = 18;
-  /** Position to the south.  */
-  public static final int SOUTH = 15;
-  /** Position to the southeast.  */
+
+  /**
+   * Position to the east.
+   */
+  public static final int EAST = 13;
+
+  /**
+   * Position to the southeast.
+   */
   public static final int SOUTHEAST = 14;
-  /** Position to the southwest.  */
+
+  /**
+   * Position to the south.
+   */
+  public static final int SOUTH = 15;
+
+  /**
+   * Position to the southwest.
+   */
   public static final int SOUTHWEST = 16;
-  /** Position to the west.  */
+
+  /**
+   * Position to the west.
+   */
   public static final int WEST = 17;
 
-  /** Occupy all remaining cells except last cell.  */
+  /**
+   * Position to the northwest.
+   */
+  public static final int NORTHWEST = 18;
+
+  // gridx and gridy values.
+  /**
+   * Occupy all remaining cells except last cell.
+   */
   public static final int RELATIVE = -1;
-  /** Occupy all remaining cells.  */
-  public static final int REMAINDER = 0;
 
   /**
-   * Position to where the first text line would end. Equals to NORTHEAST for
-   * horizontal left-to-right orientations.
+   * Occupy all remaining cells.
    */
-  public static final int FIRST_LINE_END = 24;
+  public static final int REMAINDER = 0;
 
   /**
-   * Position to where the first text line would start. Equals to NORTHWEST for
-   * horizontal left-to-right orientations.
+   * Position to where a page starts. Equals NORTH for horizontal orientations.
    */
-  public static final int FIRST_LINE_START = 23;
+  public static final int PAGE_START = 19;
 
   /**
-   * Position to where the last text line would end. Equals to SOUTHEAST for
-   * horizontal left-to-right orientations.
+   * Position to where a page ends. Equals SOUTH for horizontal orientations.
    */
-  public static final int LAST_LINE_END = 26;
+  public static final int PAGE_END = 20;
 
   /**
-   * Position to where the last text line would start. Equals to SOUTHWEST for
-   * horizontal left-to-right orientations.
+   * Position to where a text line would start. Equals to WEST for
+   * left-to-right orientations.
    */
-  public static final int LAST_LINE_START = 25;
+  public static final int LINE_START = 21;
 
   /**
    * Position to where a text line would end. Equals to EAST for
@@ -112,20 +149,28 @@
   public static final int LINE_END = 22;
 
   /**
-   * Position to where a text line would start. Equals to WEST for
-   * left-to-right orientations.
+   * Position to where the first text line would start. Equals to NORTHWEST for
+   * horizontal left-to-right orientations.
    */
-  public static final int LINE_START = 21;
+  public static final int FIRST_LINE_START = 23;
 
   /**
-   * Position to where a page ends. Equals SOUTH for horizontal orientations.
+   * Position to where the first text line would end. Equals to NORTHEAST for
+   * horizontal left-to-right orientations.
    */
-  public static final int PAGE_END = 20;
+  public static final int FIRST_LINE_END = 24;
 
   /**
-   * Position to where a page starts. Equals NORTH for horizontal orientations.
+   * Position to where the last text line would start. Equals to SOUTHWEST for
+   * horizontal left-to-right orientations.
    */
-  public static final int PAGE_START = 19;
+  public static final int LAST_LINE_START = 25;
+
+  /**
+   * Position to where the last text line would end. Equals to SOUTHEAST for
+   * horizontal left-to-right orientations.
+   */
+  public static final int LAST_LINE_END = 26;
 
   public int anchor;
   public int fill;
@@ -139,7 +184,9 @@
   public double weightx;
   public double weighty;
 
-  /** Create a copy of this object.  */
+  /**
+   * Create a copy of this object.
+   */
   public Object clone ()
   {
     try
@@ -155,8 +202,10 @@
       }
   }
 
-  /** Create a new GridBagConstraints object with the default
-   * parameters.  */
+  /**
+   * Create a new GridBagConstraints object with the default
+   * parameters.
+   */
   public GridBagConstraints ()
   {
     this.anchor = CENTER;
@@ -172,8 +221,10 @@
     this.weighty = 0;
   }
 
-  /** Create a new GridBagConstraints object with the indicated
-   * parameters.  */
+  /**
+   * Create a new GridBagConstraints object with the indicated
+   * parameters.
+   */
   public GridBagConstraints (int gridx, int gridy,
                             int gridwidth, int gridheight,
                             double weightx, double weighty,

Index: java/awt/GridBagLayout.java
===================================================================
RCS file: /sources/classpath/classpath/java/awt/GridBagLayout.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- java/awt/GridBagLayout.java 18 Jun 2006 02:22:17 -0000      1.29
+++ java/awt/GridBagLayout.java 18 Jun 2006 18:56:44 -0000      1.30
@@ -38,8 +38,6 @@
 
 package java.awt;
 
-import gnu.classpath.NotImplementedException;
-
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -322,19 +320,127 @@
     }
 
   /**
-   * Obsolete.
+     * Move and resize a rectangle according to a set of grid bag
+     * constraints.  The x, y, width and height fields of the
+     * rectangle argument are adjusted to the new values.
+     *
+     * @param constraints position and size constraints
+     * @param r rectangle to be moved and resized
    */
   protected void AdjustForGravity (GridBagConstraints constraints, 
-                                  Rectangle rect)
+                                     Rectangle r)
   {
-    Insets insets = constraints.insets;
-    if (insets != null)
+      Rectangle result = new Rectangle (0, 0, 0, 0);
+
+      // Calculate width and height.
+
+      // Adjust width and height for fill value.
+      switch (constraints.fill)
       {
-       rect.x += insets.left;
-       rect.y += insets.top;
-       rect.width -= insets.left + insets.right;
-       rect.height -= insets.top + insets.bottom;
+        case GridBagConstraints.NONE:
+          result.width = 0;
+          result.height = 0;
+          break;
+        case GridBagConstraints.BOTH:
+          result.width = r.width;
+          result.height = r.height;
+          break;
+        case GridBagConstraints.HORIZONTAL:
+          result.width = r.width;
+          result.height = 0;
+          break;
+        case GridBagConstraints.VERTICAL:
+          result.width = 0;
+          result.height = r.height;
+          break;
       }
+
+      // Adjust width and height for insets, and clamp to minimum
+      // values of ipadx and ipady.
+      result.width = Math.max(result.width
+                              - constraints.insets.left
+                              - constraints.insets.right,
+                              constraints.ipadx);
+      result.height = Math.max(result.height
+                               - constraints.insets.top
+                               - constraints.insets.bottom,
+                               constraints.ipady);
+
+      // Calculate x and y.
+
+      // Do not account for the internal padding when setting the
+      // result rectangle's x and y co-ordinates.
+      int rect_width = r.width - constraints.ipadx;
+      int rect_height = r.height - constraints.ipady;
+
+      int half_width = (rect_width + constraints.insets.left
+                        - constraints.insets.right) / 2;
+      int half_height = (rect_height + constraints.insets.top
+                         - constraints.insets.bottom) / 2;
+
+      // Adjust x and y for anchor value.
+      switch (constraints.anchor)
+        {
+        case GridBagConstraints.CENTER:
+          result.x = r.x + half_width;
+          result.y = r.y + half_height;
+          break;
+        case GridBagConstraints.NORTH:
+          result.x = r.x + half_width;
+          result.y = r.y + constraints.insets.top;
+          break;
+        case GridBagConstraints.NORTHEAST:
+          result.x = r.x + rect_width - constraints.insets.right;
+          result.y = r.y + constraints.insets.top;
+          break;
+        case GridBagConstraints.EAST:
+          result.x = r.x + rect_width - constraints.insets.right;
+          result.y = r.y + half_height;
+          break;
+        case GridBagConstraints.SOUTHEAST:
+          result.x = r.x + rect_width - constraints.insets.right;
+          result.y = r.y + rect_height - constraints.insets.bottom;
+          break;
+        case GridBagConstraints.SOUTH:
+          result.x = r.x + half_width;
+          result.y = r.y + rect_height - constraints.insets.bottom;
+          break;
+        case GridBagConstraints.SOUTHWEST:
+          result.x = r.x + constraints.insets.left;
+          result.y = r.y + rect_height - constraints.insets.bottom;
+          break;
+        case GridBagConstraints.WEST:
+          result.x = r.x + constraints.insets.left;
+          result.y = r.y + half_height;
+          break;
+        case GridBagConstraints.NORTHWEST:
+          result.x = r.x + constraints.insets.left;
+          result.y = r.y + constraints.insets.top;
+          break;
+        }
+
+       // Adjust x and y for fill, clamping values to the external
+       // padding boundaries where necessary.
+       switch (constraints.fill)
+         {
+         case GridBagConstraints.NONE:
+           break;
+         case GridBagConstraints.BOTH:
+           result.x = r.x + constraints.insets.left;
+           result.y = r.y + constraints.insets.top;
+           break;
+         case GridBagConstraints.HORIZONTAL:
+           result.x = r.x + constraints.insets.left;
+           break;
+         case GridBagConstraints.VERTICAL:
+           result.y = r.y + constraints.insets.top;
+           break;
+         }
+
+      r.x = result.x;
+      r.y = result.y;
+      r.width = result.width;
+      r.height = result.height;
   }
 
     /**
@@ -1081,10 +1187,18 @@
     }
 
     /**
+     * Move and resize a rectangle according to a set of grid bag
+     * constraints.  The x, y, width and height fields of the
+     * rectangle argument are adjusted to the new values.
+     *
+     * @param constraints position and size constraints
+     * @param r rectangle to be moved and resized
+     *
      * @since 1.4
      */
-    protected void adjustForGravity (GridBagConstraints gbc, Rectangle rect)
+    protected void adjustForGravity (GridBagConstraints constraints,
+                                     Rectangle r)
     {
-      AdjustForGravity (gbc, rect);
+      AdjustForGravity (constraints, r);
     }
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]