}
return at;
}
public void paint(Graphics2D graphics){
Rectangle2D anchor = _shape.getLogicalAnchor2D();
TextElement[] elem = getTextElements((float)anchor.getWidth(), graphics.getFontRenderContext());
if(elem == null) return;
float textHeight = 0;
for (int i = 0; i < elem.length; i++) {
textHeight += elem[i].ascent + elem[i].descent;
}
int valign = _shape.getVerticalAlignment();
double y0 = anchor.getY();
switch (valign){
case TextShape.AnchorTopBaseline:
case TextShape.AnchorTop:
y0 += _shape.getMarginTop();
break;
case TextShape.AnchorBottom:
y0 += anchor.getHeight() - textHeight - _shape.getMarginBottom();
break;
default:
case TextShape.AnchorMiddle:
float delta = (float)anchor.getHeight() - textHeight - _shape.getMarginTop() - _shape.getMarginBottom();
y0 += _shape.getMarginTop() + delta/2;
break;
}
//finally draw the text fragments
for (int i = 0; i < elem.length; i++) {
y0 += elem[i].ascent;
Point2D.Double pen = new Point2D.Double();
pen.y = y0;
switch (elem[i]._align) {
default:
case TextShape.AlignLeft:
pen.x = anchor.getX() + _shape.getMarginLeft();
break;
case TextShape.AlignCenter:
pen.x = anchor.getX() + _shape.getMarginLeft() +
(anchor.getWidth() - elem[i].advance - _shape.getMarginLeft() - _shape.getMarginRight()) / 2;
break;
case TextShape.AlignRight:
pen.x = anchor.getX() + _shape.getMarginLeft() +
(anchor.getWidth() - elem[i].advance - _shape.getMarginLeft() - _shape.getMarginRight());
break;
}
if(elem[i]._bullet != null){
graphics.drawString(elem[i]._bullet.getIterator(), (float)(pen.x + elem[i]._bulletOffset), (float)pen.y);
}