calcWidth[i] = -1;
}
// first assign fixed width
for ( int i = 0; i < nEffCols; i++ ) {
Length l = (Length)_widths.get(i);
if ( l.isFixed() ) {
calcWidth[i] = l.value();
available -= l.value();
}
}
// assign percent width
if ( available > 0 ) {
int totalPercent = 0;
for ( int i = 0; i < nEffCols; i++ ) {
Length l = (Length)_widths.get(i);
if ( l.isPercent() ) {
totalPercent += l.value();
}
}
// calculate how much to distribute to percent cells.
int base = tableWidth * totalPercent / 100;
if (base > available) {
base = available;
}
for ( int i = 0; available > 0 && i < nEffCols; i++ ) {
Length l = (Length)_widths.get(i);
if ( l.isPercent() ) {
long w = base * l.value() / totalPercent;
available -= w;
calcWidth[i] = w;
}
}
}
// assign variable width
if ( available > 0 ) {
int totalVariable = 0;
for ( int i = 0; i < nEffCols; i++ ) {
Length l = (Length)_widths.get(i);
if ( l.isVariable() ) {
totalVariable++;
}
}
for ( int i = 0; available > 0 && i < nEffCols; i++ ) {
Length l = (Length)_widths.get(i);
if ( l.isVariable() ) {
int w = available / totalVariable;
available -= w;
calcWidth[i] = w;
totalVariable--;
}