Logo Search packages:      
Sourcecode: libjgoodies-forms-java version File versions  Download package

int [] com::jgoodies::forms::layout::FormLayout::compressedSizes ( List  formSpecs,
int  totalSize,
int  totalMinSize,
int  totalPrefSize,
int[]  minSizes,
int[]  prefSizes 
) [inline, private]

Computes and returns the compressed sizes. Compresses space for columns and rows iff the available space is less than the total preferred size but more than the total minimum size.

Only columns and row that are specified to be compressable will be affected. You can specify a column and row as compressable by giving it the component size default.

formSpecs the column or row specs to use
totalSize the total available size
totalMinSize the sum of all minimum sizes
totalPrefSize the sum of all preferred sizes
minSizes an int array of column/row minimum sizes
prefSizes an int array of column/row preferred sizes
an int array of compressed column/row sizes

Definition at line 1310 of file FormLayout.java.

References com::jgoodies::forms::layout::FormSpec::getSize().

Referenced by computeGridOrigins().

        // If we have less space than the total min size answer the min sizes.                            
        if (totalSize < totalMinSize)
            return minSizes;
        // If we have more space than the total pref size answer the pref sizes.                            
        if (totalSize >= totalPrefSize)
            return prefSizes;
        int count = formSpecs.size();
        int[] sizes = new int[count];

        double totalCompressionSpace = totalPrefSize - totalSize;
        double maxCompressionSpace   = totalPrefSize - totalMinSize;
        double compressionFactor     = totalCompressionSpace / maxCompressionSpace;

//      System.out.println("Total compression space=" + totalCompressionSpace);
//      System.out.println("Max compression space  =" + maxCompressionSpace);
//      System.out.println("Compression factor     =" + compressionFactor);
        for (int i=0; i < count; i++) {
            FormSpec formSpec = (FormSpec) formSpecs.get(i);
            sizes[i] = prefSizes[i];
            if (formSpec.getSize() == Sizes.DEFAULT) {
                sizes[i] -= (int) Math.round((prefSizes[i] - minSizes[i]) 
                                                 * compressionFactor); 
        return sizes;

Generated by  Doxygen 1.6.0   Back to index