harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r496469 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/org/apache/harmony/x/swing/ test/api/java/common/javax/swing/text/ test/api/java/common/org/apache/harmony/x/swing/
Date Mon, 15 Jan 2007 20:38:59 GMT
Author: hindessm
Date: Mon Jan 15 12:38:58 2007
New Revision: 496469

URL: http://svn.apache.org/viewvc?view=rev&rev=496469
Log:
Applying patches from "[#HARMONY-2915] [classlib][swing] j.s.text.BoxView
incorrectly layouts where its child views are resizable".

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/SizeRequirementsHelper.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/BoxView_WithChildrenTest.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/org/apache/harmony/x/swing/SizeRequirementsHelperRTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/SizeRequirementsHelper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/SizeRequirementsHelper.java?view=diff&rev=496469&r1=496468&r2=496469
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/SizeRequirementsHelper.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/SizeRequirementsHelper.java
Mon Jan 15 12:38:58 2007
@@ -168,25 +168,45 @@
                               final int[] offsets,
                               final int[] spans) {
 
-        calculateTiledSpans(allocated, total, children, spans);
-
-        final int aligningAxis = (int)((allocated - total.preferred) / 2
-                + total.alignment * total.preferred);
+        int baseLineOffset = (int)(allocated * total.alignment);
+        int childMinRequirement;
 
         for (int iChild = 0; iChild < children.length; iChild++) {
-            offsets[iChild] = (int)(aligningAxis - children[iChild].alignment * spans[iChild]);
-            if (offsets[iChild] < 0) {
-                if (spans[iChild] + offsets[iChild] > children[iChild].minimum) {
-                    spans[iChild] = spans[iChild] + offsets[iChild];
-                    offsets[iChild] = 0;
+            childMinRequirement = children[iChild].minimum;
+
+            if (children[iChild].alignment == 0) {
+                offsets[iChild] = baseLineOffset;
+                if (allocated - baseLineOffset > childMinRequirement) {
+                    spans[iChild] = Math.min(children[iChild].maximum,
+                                             allocated - baseLineOffset);
+                } else {
+                    spans[iChild] = childMinRequirement;
+                }
+                continue;
+            }
+
+            if (children[iChild].alignment == 1) {
+                if (baseLineOffset < childMinRequirement) {
+                    spans[iChild] = childMinRequirement;
                 } else {
-                    offsets[iChild] += spans[iChild] - children[iChild].minimum;
-                    spans[iChild] = children[iChild].minimum;
+                    spans[iChild] = Math.min(children[iChild].maximum,
+                                             baseLineOffset);
                 }
+                offsets[iChild] = baseLineOffset - spans[iChild];
+                continue;
             }
-            if (offsets[iChild] + spans[iChild] > allocated) {
-                spans[iChild] = Math.max(children[iChild].minimum, allocated - offsets[iChild]);
+
+            int upperSpan = (int)(baseLineOffset / children[iChild].alignment);
+            int bottomSpan = (int)((allocated - baseLineOffset) / (1 - children[iChild].alignment));
+
+            spans[iChild] = childMinRequirement;
+            if (childMinRequirement <= upperSpan
+                && childMinRequirement <= bottomSpan) {
+                spans[iChild] = Math.min(children[iChild].maximum, Math
+                    .min(upperSpan, bottomSpan));
             }
+            offsets[iChild] = baseLineOffset
+                              - (int)(spans[iChild] * children[iChild].alignment);
         }
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/BoxView_WithChildrenTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/BoxView_WithChildrenTest.java?view=diff&rev=496469&r1=496468&r2=496469
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/BoxView_WithChildrenTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/BoxView_WithChildrenTest.java
Mon Jan 15 12:38:58 2007
@@ -444,7 +444,7 @@
             View child = view.getView(i);
             float span = child.getPreferredSpan(axis);
             float offset = leftInset - span * child.getAlignment(axis);
-            if (i == 1 && !isHarmony()) {
+            if (i == 1) {
                 // The cause is rounding errors
                 offset += 1;
             }

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/org/apache/harmony/x/swing/SizeRequirementsHelperRTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/org/apache/harmony/x/swing/SizeRequirementsHelperRTest.java?view=diff&rev=496469&r1=496468&r2=496469
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/org/apache/harmony/x/swing/SizeRequirementsHelperRTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/org/apache/harmony/x/swing/SizeRequirementsHelperRTest.java
Mon Jan 15 12:38:58 2007
@@ -41,7 +41,7 @@
         int[] offsets = new int[children.length];
         int[] spans = new int[children.length];
         SizeRequirementsHelper.calculateAlignedPositions(100, total, children, offsets, spans);
-        assertEquals(37, offsets[0]);
+        assertEquals(38, offsets[0]);
         assertEquals(25, offsets[1]);
         assertEquals(25, spans[0]);
         assertEquals(50, spans[1]);
@@ -51,9 +51,9 @@
         offsets = new int[children.length];
         spans = new int[children.length];
         SizeRequirementsHelper.calculateAlignedPositions(200, total, children, offsets, spans);
-        assertEquals(75, offsets[0]);
-        assertEquals(50, offsets[1]);
-        assertEquals(50, spans[0]);
-        assertEquals(100, spans[1]);
+        assertEquals(0, offsets[0]);
+        assertEquals(0, offsets[1]);
+        assertEquals(200, spans[0]);
+        assertEquals(200, spans[1]);
     }
 }



Mime
View raw message