int (String text, int start, int end, FontMetrics metrics, int maxWidth, boolean replaceSeparators, boolean appendEllipsis, char returnSymbol) { if (metrics.charWidth('m') * (end - start) <= maxWidth) return end - start; int abbrWidth = appendEllipsis ? metrics.charWidth(ABBREVIATION_SUFFIX) : 0; int abbrLength = 0; CharSequenceSubSequence subSeq = new CharSequenceSubSequence(text, start, end); for (LineTokenizer lt = new LineTokenizer(subSeq); !lt.atEnd(); lt.advance()) { for (int i = 0; i < lt.getLength(); i++, abbrLength++) { abbrWidth += metrics.charWidth(subSeq.charAt(lt.getOffset() + i)); if (abbrWidth >= maxWidth) return abbrLength; } if (replaceSeparators && lt.getLineSeparatorLength() != 0) { abbrWidth += metrics.charWidth(returnSymbol); if (abbrWidth >= maxWidth) return abbrLength; abbrLength += lt.getLineSeparatorLength(); } } return abbrLength; }