public RenderedTextData getData() {
return data;
}
public Vector2 findCaretTranslation(final int caretPosition, final Vector2 store) {
Vector2 rVal = store;
if (rVal == null) {
rVal = new Vector2(0, 0);
}
if (data._lineHeights == null) {
return rVal;
}
int lineHeight = data._lineHeights.get(0);
int cursorY = 0;
for (int j = 1; j < data._lineEnds.size(); j++) {
if (data._lineEnds.get(j) < caretPosition) {
cursorY += lineHeight;
lineHeight = data._lineHeights.get(j);
} else {
break;
}
}
if (caretPosition < data._xStarts.size()) {
rVal.setX(data._xStarts.get(caretPosition));
} else {
final CharacterDescriptor charDesc = data._characters.get(caretPosition - 1);
rVal.setX(data._xStarts.get(caretPosition - 1)
+ (int) Math.round(charDesc.getScale() * charDesc.getXAdvance()));
}
rVal.setY(cursorY);
return rVal;
}