}
@SuppressWarnings("deprecation")
@Override
public void drawString(Graphics2D g, String str, float x, float y) {
AffineTransform at = g.getTransform();
Rectangle c = g.getClipBounds();
if (at != null){
int atType = at.getType();
if (atType == AffineTransform.TYPE_TRANSLATION) {
c.translate((int)Math.round(at.getTranslateX()), (int)Math.round(at.getTranslateY()));
}
}
WritableRaster wr = ((BufferedImageGraphics2D)g).getWritableRaster();
ColorModel cm = ((BufferedImageGraphics2D)g).getColorModel();
Rectangle rBounds = wr.getBounds();
Object color = cm.getDataElements(g.getColor().getRGB(), null);
drawClipString(wr, color, str, (FontPeerImpl) (g.getFont().getPeer()),
(int)Math.round(x + at.getTranslateX()), (int)Math.round(y + at.getTranslateY()),
Math.max(c.x,rBounds.x),
Math.max(c.y,rBounds.y),
Math.min((int)Math.round(c.getMaxX()), (int)Math.round(rBounds.getMaxX())),
Math.min((int)Math.round(c.getMaxY()), (int)Math.round(rBounds.getMaxY())));