int curParagraphLimit = Integer.MIN_VALUE; // dummy value
int damageStart = curGraphicStart;
ParagraphRenderer renderer = null;
LineBreakMeasurer measurer = null;
// try to use cached LineBreakMeasurer if possible
if (fCachedMeasurer != null &&
curParagraphStart == fCachedMeasurerStart) {
curParagraphLimit = fText.paragraphLimit(curParagraphStart);
try {
if (newCurTextLen - fLTCurTextLen == 1 && afLength == 1) {
if (curParagraphLimit == fCachedMeasurerLimit+1) {
MTextIterator iter = new MTextIterator(fText,
fFontResolver,
curParagraphStart,
curParagraphLimit);
fCachedMeasurer.insertChar(iter, afStart);
fCachedMeasurerLimit += 1;
measurer = fCachedMeasurer;
}
}
else if (fLTCurTextLen - newCurTextLen == 1 && afLength == 0) {
if (fCachedMeasurerLimit > fCachedMeasurerStart + 1 &&
curParagraphLimit == fCachedMeasurerLimit-1) {
MTextIterator iter = new MTextIterator(fText,
fFontResolver,
curParagraphStart,
curParagraphLimit);
fCachedMeasurer.deleteChar(iter, afStart);
fCachedMeasurerLimit -= 1;
measurer = fCachedMeasurer;
}
}
}
catch(ArrayIndexOutOfBoundsException e) {
fCachedMeasurer = null;
fgCacheMeasurers = false;
}
if (measurer != null) {
// need to set up renderer since the paragraph update in the
// formatting loop will not happen
AttributeMap style = fText.paragraphStyleAt(curParagraphStart);
renderer = getRendererFor(style);
measurer.setPosition(curLineStart);
}
}
if (measurer == null) {
// trigger paragraph update at start of formatting loop
curParagraphLimit = curParagraphStart;
curParagraphStart = 0;
}
fLTCurTextLen = newCurTextLen;
while (true) {
// System.out.println("line: " + fLTPosEnd + ", cls: " + curLineStart);
if (curLineStart >= curParagraphLimit) {
curParagraphStart = curParagraphLimit;
curParagraphLimit = fText.paragraphLimit(curParagraphStart);
AttributeMap style = fText.paragraphStyleAt(curParagraphStart);
renderer = getRendererFor(style);
if (curParagraphStart < curParagraphLimit) {
measurer = makeMeasurer(curParagraphStart, curParagraphLimit);
measurer.setPosition(curLineStart);
}
else {
measurer = null;
}
}