/[classpath]/classpath/javax/swing/SizeRequirements.java
ViewVC logotype

Diff of /classpath/javax/swing/SizeRequirements.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by rabbit78, Tue Sep 13 10:23:50 2005 UTC revision 1.12 by rabbit78, Sun Sep 25 10:17:19 2005 UTC
# Line 166  public class SizeRequirements implements Line 166  public class SizeRequirements implements
166    public static SizeRequirements    public static SizeRequirements
167    getAlignedSizeRequirements(SizeRequirements[] children)    getAlignedSizeRequirements(SizeRequirements[] children)
168    {    {
169      return null; // TODO      float minLeft = 0;
170        float minRight = 0;
171        float prefLeft = 0;
172        float prefRight = 0;
173        float maxLeft = 0;
174        float maxRight = 0;
175        for (int i = 0; i < children.length; i++)
176          {
177            float myMinLeft = children[i].minimum * children[i].alignment;
178            float myMinRight = children[i].minimum - myMinLeft;
179            minLeft = Math.max(myMinLeft, minLeft);
180            minRight = Math.max(myMinRight, minRight);
181            float myPrefLeft = children[i].preferred * children[i].alignment;
182            float myPrefRight = children[i].preferred - myMinLeft;
183            prefLeft = Math.max(myPrefLeft, prefLeft);
184            prefRight = Math.max(myPrefRight, prefRight);
185            float myMaxLeft = children[i].maximum * children[i].alignment;
186            float myMaxRight = children[i].maximum - myMinLeft;
187            maxLeft = Math.max(myMaxLeft, maxLeft);
188            maxRight = Math.max(myMaxRight, maxRight);
189          }
190        int minSize = (int) (minLeft + minRight);
191        int prefSize = (int) (prefLeft + prefRight);
192        int maxSize = (int) (maxLeft + maxRight);
193        return new SizeRequirements(minSize, prefSize, maxSize, 0.5F);
194    }    }
195    
196    /**    /**
# Line 317  public class SizeRequirements implements Line 341  public class SizeRequirements implements
341                                                 int[] offset, int[] spans,                                                 int[] offset, int[] spans,
342                                                 boolean forward)                                                 boolean forward)
343    {    {
344      // TODO: Implement this correctly.      // First we compute the position of the baseline.
345      for (int i = 0; i < children.length; ++i)      float left = 0;
346        float right = 0;
347        for (int i = 0; i < children.length; i++)
348          {
349            float myLeft = children[i].preferred * children[i].alignment;
350            float myRight = children[i].preferred - myLeft;
351            left = Math.max(myLeft, left);
352            right = Math.max(myRight, right);
353          }
354        int baseline = (int) ((left / (left + right)) * allocated);
355        // Now we can layout the components along the baseline.
356        for (int i = 0; i < children.length; i++)
357        {        {
358          // This is only a hack to make things work a little.          // FIXME: Handle the case when span[i] results in exceeding
359          spans[i] = Math.min(allocated, children[i].maximum);          // the available space.
360            spans[i] = children[i].preferred;
361            offset[i] = baseline - (int) (children[i].alignment * ((float) spans[i]));
362        }        }
363    }    }
364    

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26