code: private static int[] distributedSizes(List formSpecs,
              int totalSize, int totalPrefSize,
              int[] inputSizes) {
          double totalFreeSpace = totalSize - totalPrefSize;
          // Do nothing if there's no free space.
          if (totalFreeSpace < 0) {
              return inputSizes;
          }
  
          // Compute the total weight.
          int count = formSpecs.size();
          double totalWeight = 0.0;
          for (int i = 0; i < count; i++) {
              FormSpec formSpec = (FormSpec) formSpecs.get(i);
              totalWeight += formSpec.getResizeWeight();
          }
  
          // Do nothing if there's no resizing column.
          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;
      }
docs: Distributes free space over columns and rows and returns the sizes after this distribution
  process.
  
  @param formSpecs the column/row specifications to work with
  @param totalSize the total available size
  @param totalPrefSize the sum of all preferred sizes
  @param inputSizes the input sizes
  @return the distributed sizes