/[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.18 by rabbit78, Tue Oct 4 14:50:31 2005 UTC revision 1.19 by rabbit78, Thu Oct 13 20:02:29 2005 UTC
# Line 424  public class SizeRequirements implements Line 424  public class SizeRequirements implements
424                                                 boolean forward)                                                 boolean forward)
425    {    {
426      // First we compute the position of the baseline.      // First we compute the position of the baseline.
427      float left = 0;      float baseline = allocated * total.alignment;
428      float right = 0;  
     for (int i = 0; i < children.length; i++)  
       {  
         float myLeft = children[i].preferred * children[i].alignment;  
         float myRight = children[i].preferred - myLeft;  
         left = Math.max(myLeft, left);  
         right = Math.max(myRight, right);  
       }  
     int baseline = (int) ((left / (left + right)) * allocated);  
429      // Now we can layout the components along the baseline.      // Now we can layout the components along the baseline.
430      for (int i = 0; i < children.length; i++)      for (int i = 0; i < children.length; i++)
431        {        {
# Line 457  public class SizeRequirements implements Line 449  public class SizeRequirements implements
449     * @param allocated     * @param allocated
450     * @param spanAndOffset     * @param spanAndOffset
451     */     */
452    private static void adjustFromRight(SizeRequirements reqs, int baseline,    private static void adjustFromRight(SizeRequirements reqs, float baseline,
453                                        int allocated, int[] spanAndOffset)                                        int allocated, int[] spanAndOffset)
454    {    {
455      float right = allocated - baseline;      float right = allocated - baseline;
# Line 470  public class SizeRequirements implements Line 462  public class SizeRequirements implements
462      if (right / (1.F - reqs.alignment) * reqs.alignment > allocated - baseline)      if (right / (1.F - reqs.alignment) * reqs.alignment > allocated - baseline)
463        right = ((float) (allocated - baseline))        right = ((float) (allocated - baseline))
464               / reqs.alignment * (1.F - reqs.alignment);               / reqs.alignment * (1.F - reqs.alignment);
     // If we are below the minimum, then adjust upwards.  
       float minRight = ((float) reqs.minimum) * (1.F - reqs.alignment);  
     if (right / (1.F - reqs.alignment) < reqs.minimum)  
       right = Math.max(minRight, maxRight);  
465    
466      spanAndOffset[0] = (int) (right / (1.F - reqs.alignment));      spanAndOffset[0] = (int) (right / (1.F - reqs.alignment));
467      spanAndOffset[1] = baseline -      spanAndOffset[1] = (int) (baseline - spanAndOffset[0] * reqs.alignment);
                        (int) (((float) spanAndOffset[0]) * reqs.alignment);  
468    }    }
469    
470    /**    /**
# Line 488  public class SizeRequirements implements Line 475  public class SizeRequirements implements
475     * @param allocated     * @param allocated
476     * @param spanAndOffset     * @param spanAndOffset
477     */     */
478    private static void adjustFromLeft(SizeRequirements reqs, int baseline,    private static void adjustFromLeft(SizeRequirements reqs, float baseline,
479                                       int allocated, int[] spanAndOffset)                                       int allocated, int[] spanAndOffset)
480    {    {
481      float left = baseline;      float left = baseline;
# Line 502  public class SizeRequirements implements Line 489  public class SizeRequirements implements
489        left = ((float) (allocated - baseline))        left = ((float) (allocated - baseline))
490               / (1.F - reqs.alignment) * reqs.alignment;               / (1.F - reqs.alignment) * reqs.alignment;
491    
     // If we are below the minimum, then adjust upwards.  
     float minLeft = ((float) reqs.minimum) * reqs.alignment;  
     if (left / reqs.alignment < reqs.minimum)  
       left = Math.max(minLeft, maxLeft);  
   
492      spanAndOffset[0] = (int) (left / reqs.alignment);      spanAndOffset[0] = (int) (left / reqs.alignment);
493      spanAndOffset[1] = baseline -      spanAndOffset[1] = (int) (baseline - spanAndOffset[0] * reqs.alignment);
                        (int) (((float) spanAndOffset[0]) * reqs.alignment);  
494    }    }
495    
496    /**    /**

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

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