public static void calculateAlignedPositions(int allocated,SizeRequirements total,SizeRequirements[] children,int[] offsets,int[] spans,boolean normal){
  float totalAlignment=normal ? total.alignment : 1.0f - total.alignment;
  int totalAscent=(int)(allocated * totalAlignment);
  int totalDescent=allocated - totalAscent;
  for (int i=0; i < children.length; i++) {
    SizeRequirements req=children[i];
    float alignment=normal ? req.alignment : 1.0f - req.alignment;
    int maxAscent=(int)(req.maximum * alignment);
    int maxDescent=req.maximum - maxAscent;
    int ascent=Math.min(totalAscent,maxAscent);
    int descent=Math.min(totalDescent,maxDescent);
    offsets[i]=totalAscent - ascent;
    spans[i]=(int)Math.min((long)ascent + (long)descent,Integer.MAX_VALUE);
  }
}

public static void calculateAlignedPositions ( int allocated , SizeRequirements total , SizeRequirements [ ] children , int [ ] offsets , int [ ] spans , boolean normal ) { float totalAlignment = normal ? total . alignment : 1.0f - total . alignment ; int totalAscent = ( int ) ( allocated * totalAlignment ) ; int totalDescent = allocated - totalAscent ; for ( int i = 0 ; i < children . length ; i ++ ) { SizeRequirements req = children [ i ] ; float alignment = normal ? req . alignment : 1.0f - req . alignment ; int maxAscent = ( int ) ( req . maximum * alignment ) ; int maxDescent = req . maximum - maxAscent ; int ascent = Math . min ( totalAscent , maxAscent ) ; int descent = Math . min ( totalDescent , maxDescent ) ; offsets [ i ] = totalAscent - ascent ; spans [ i ] = ( int ) Math . min ( ( long ) ascent + ( long ) descent , Integer . MAX_VALUE ) ; } }
creates a set of offset / span pairs specifying how to lay out a set of components with the specified alignments . the resulting span allocations will overlap , with each one fitting as well as possible into the given total allocation . this method requires that you specify the total amount of space to be allocated , the size requirements for each component to be placed ( specified as an array of sizerequirements ) , and the total size requirements of the set of components ( only the alignment field of which is actually used ) you can get the total size requirement by invoking getalignedsizerequirements . this method also requires a flag indicating whether normal or reverse alignment should be performed . with normal alignment the value 0 . 0f represents the left / top edge of the component to be aligned . with reverse alignment , 0 . 0f represents the right / bottom edge .
