public int getRowCount() {
return rows.getLength();
}
public Bounds getCharacterBounds(int index) {
Bounds characterBounds = null;
CharSequence characters = paragraph.getCharacters();
int characterCount = characters.length();
int rowIndex, xLocal, widthLocal;
if (index == characterCount) {
// This is the terminator character
rowIndex = rows.getLength() - 1;
Row row = rows.get(rowIndex);
Rectangle2D glyphVectorBounds = row.glyphVector.getLogicalBounds();
xLocal = (int)Math.floor(glyphVectorBounds.getWidth());
widthLocal = PARAGRAPH_TERMINATOR_WIDTH;
} else {
// This is a visible character
rowIndex = getRowAt(index);
Row row = rows.get(rowIndex);
Shape glyphBounds = row.glyphVector.getGlyphLogicalBounds(index - row.offset);
Rectangle2D glyphBounds2D = glyphBounds.getBounds2D();
xLocal = (int)Math.floor(glyphBounds2D.getX());
widthLocal = (int)Math.ceil(glyphBounds2D.getWidth());
}
Font font = textAreaSkin.getFont();
FontRenderContext fontRenderContext = Platform.getFontRenderContext();
LineMetrics lm = font.getLineMetrics("", fontRenderContext);
float rowHeight = lm.getAscent() + lm.getDescent();
characterBounds = new Bounds(xLocal, (int)Math.floor(rowIndex * rowHeight), widthLocal,
(int)Math.ceil(rowHeight));
return characterBounds;
}