static SizeRequirements calculateTiledRequirements(LayoutIterator iter,SizeRequirements r){
  long minimum=0;
  long maximum=0;
  long preferred=0;
  int lastMargin=0;
  int totalSpacing=0;
  int n=iter.getCount();
  for (int i=0; i < n; i++) {
    iter.setIndex(i);
    int margin0=lastMargin;
    int margin1=(int)iter.getLeadingCollapseSpan();
    totalSpacing+=Math.max(margin0,margin1);
    preferred+=(int)iter.getPreferredSpan(0);
    minimum+=iter.getMinimumSpan(0);
    maximum+=iter.getMaximumSpan(0);
    lastMargin=(int)iter.getTrailingCollapseSpan();
  }
  totalSpacing+=lastMargin;
  totalSpacing+=2 * iter.getBorderWidth();
  minimum+=totalSpacing;
  preferred+=totalSpacing;
  maximum+=totalSpacing;
  if (r == null) {
    r=new SizeRequirements();
  }
  r.minimum=(minimum > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int)minimum;
  r.preferred=(preferred > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int)preferred;
  r.maximum=(maximum > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int)maximum;
  return r;
}

static SizeRequirements calculateTiledRequirements ( LayoutIterator iter , SizeRequirements r ) { long minimum = 0 ; long maximum = 0 ; long preferred = 0 ; int lastMargin = 0 ; int totalSpacing = 0 ; int n = iter . getCount ( ) ; for ( int i = 0 ; i < n ; i ++ ) { iter . setIndex ( i ) ; int margin0 = lastMargin ; int margin1 = ( int ) iter . getLeadingCollapseSpan ( ) ; totalSpacing += Math . max ( margin0 , margin1 ) ; preferred += ( int ) iter . getPreferredSpan ( 0 ) ; minimum += iter . getMinimumSpan ( 0 ) ; maximum += iter . getMaximumSpan ( 0 ) ; lastMargin = ( int ) iter . getTrailingCollapseSpan ( ) ; } totalSpacing += lastMargin ; totalSpacing += 2 * iter . getBorderWidth ( ) ; minimum += totalSpacing ; preferred += totalSpacing ; maximum += totalSpacing ; if ( r == null ) { r = new SizeRequirements ( ) ; } r . minimum = ( minimum > Integer . MAX_VALUE ) ? Integer . MAX_VALUE : ( int ) minimum ; r . preferred = ( preferred > Integer . MAX_VALUE ) ? Integer . MAX_VALUE : ( int ) preferred ; r . maximum = ( maximum > Integer . MAX_VALUE ) ? Integer . MAX_VALUE : ( int ) maximum ; return r ; }
calculate the requirements needed to tile the requirements given by the iterator that would be tiled . the calculation takes into consideration margin and border spacing .
