Post
by David Gilbert » Tue Mar 04, 2003 11:06 am
Hi Chris,
Thanks for the report. This has been reported by one or two others, and seems to be specific to MacOS X.
The code that draws the rotated strings is in the RefineryUtilities class in the JCommon class library:
/**
* A utility method for drawing rotated text.
* <P>
* A common rotation is -Math.PI/2 which draws text 'vertically' (with the top of the
* characters on the left).
*
* @param text the text.
* @param g2 the graphics device.
* @param x the x-coordinate.
* @param y the y-coordinate.
* @param rotation the clockwise rotation (in radians).
*/
public static void drawRotatedString(String text, Graphics2D g2,
float x, float y, double rotation) {
if ((text == null) || (text.equals(""))) {
return;
}
AffineTransform saved = g2.getTransform();
// apply the rotation...
AffineTransform rotate = AffineTransform.getRotateInstance(rotation, x, y);
g2.transform(rotate);
// workaround for JDC bug ID 4312117 and others...
TextLayout tl = new TextLayout(text, g2.getFont(), g2.getFontRenderContext());
tl.draw(g2, x, y);
// replaces this code...
//g2.drawString(text, x, y);
g2.setTransform(saved);
}
Perhaps you could try it out without the TextLayout workaround to see if that makes a difference.
Regards,
Dave Gilbert