AreaInfo ai = null;
int iWScount = 0;
int iLScount = 0;
int firstAreaInfoIndex = -1;
int lastAreaInfoIndex = 0;
MinOptMax realWidth = new MinOptMax(0);
/* On first area created, add any leading space.
* Calculate word-space stretch value.
*/
while (posIter.hasNext()) {
LeafPosition tbpNext = (LeafPosition) posIter.next();
if (tbpNext == null) {
continue; //Ignore elements without Positions
}
if (tbpNext.getLeafPos() != -1) {
ai = (AreaInfo) vecAreaInfo.get(tbpNext.getLeafPos());
if (firstAreaInfoIndex == -1) {
firstAreaInfoIndex = tbpNext.getLeafPos();
}
iWScount += ai.iWScount;
iLScount += ai.iLScount;
realWidth.add(ai.ipdArea);
lastAreaInfoIndex = tbpNext.getLeafPos();
}
}
if (ai == null) {
return;
}
int textLength = ai.iBreakIndex - ai.iStartIndex;
if (ai.iLScount == textLength && !ai.bHyphenated
&& context.isLastArea()) {
// the line ends at a character like "/" or "-";
// remove the letter space after the last character
realWidth.add(MinOptMax.multiply(letterSpaceIPD, -1));
iLScount--;
}
for (int i = ai.iStartIndex; i < ai.iBreakIndex; i++) {
MinOptMax ladj = letterAdjustArray[i + 1];
if (ladj != null && ladj.isElastic()) {
iLScount++;
}
}
// add hyphenation character if the last word is hyphenated
if (context.isLastArea() && ai.bHyphenated) {
realWidth.add(new MinOptMax(hyphIPD));
}
// Calculate adjustments
int iDifference = 0;
int iTotalAdjust = 0;