// Returns visual bounds of this segment
@Override
Rectangle2D getVisualBounds() {
if (visualBounds == null) {
Rectangle2D bounds = ga.getBounds();
// First and last chars can be out of logical bounds, so we calculate
// (bounds.getWidth() - ga.getAdvance()) which is exactly the difference
bounds.setRect(
bounds.getMinX() + x,
bounds.getMinY() + y,
bounds.getWidth() - ga.getAdvance() + getAdvance(),
bounds.getHeight()
);
visualBounds = TextDecorator.extendVisualBounds(this, bounds, decoration);
}
return (Rectangle2D) visualBounds.clone();