question: private static int [ ] distributedSizes ( List formSpecs , int totalSize , int totalPrefSize , int [ ] inputSizes ) { double totalFreeSpace = totalSize - totalPrefSize ; if ( totalFreeSpace < 0 ) { return inputSizes ; } int count = formSpecs . size ( ) ; double totalWeight = 0.0 ; for ( int i = 0 ; i < count ; i ++ ) { FormSpec formSpec = ( FormSpec ) formSpecs . get ( i ) ; totalWeight += formSpec . getResizeWeight ( ) ; } if ( totalWeight == 0.0 ) { return inputSizes ; } int [ ] sizes = new int [ count ] ; double restSpace = totalFreeSpace ; int roundedRestSpace = ( int ) totalFreeSpace ; for ( int i = 0 ; i < count ; i ++ ) { FormSpec formSpec = ( FormSpec ) formSpecs . get ( i ) ; double weight = formSpec . getResizeWeight ( ) ; if ( weight == FormSpec . NO_GROW ) { sizes [ i ] = inputSizes [ i ] ; } else { double roundingCorrection = restSpace - roundedRestSpace ; double extraSpace = totalFreeSpace * weight / totalWeight ; double correctedExtraSpace = extraSpace - roundingCorrection ; int roundedExtraSpace = ( int ) Math . round ( correctedExtraSpace ) ; sizes [ i ] = inputSizes [ i ] + roundedExtraSpace ; restSpace -= extraSpace ; roundedRestSpace -= roundedExtraSpace ; } } return sizes ; }
target:  Distributes free space over columns and rows and returns the sizes after this distribution process.