Hello,
I've got a little question concering affine transformations such as
rotation.
There are (at least) two possibilities for performing an affine transformation on a text: 1) Creating a rotated font or 2) "rotate" the graphics.
The following code snippet illustrates both possiblities:
----------------8X--------------------8X-------------------
public void paint(Graphics io_Graphics) {
java.awt.Graphics2D g2d = (java.awt.Graphics2D) io_Graphics;
AffineTransform origAT = g2d.getTransform();
Font origFont = g2d.getFont();
g2d.setColor(Color.blue);
// 1) create rotated font
AffineTransform at = new AffineTransform();
at.rotate(Math.toRadians((double) 45d));
Font rotatedFont = origFont.deriveFont(at);
g2d.setFont(rotatedFont);
g2d.drawString("Hello World by font.rotate", 40, 60);
g2d.setFont(origFont);
// restore
g2d.setTransform(origAT);
g2d.setFont(origFont);
g2d.setColor(Color.red);
// 2) rotate graphics
g2d.rotate(Math.toRadians((double) 45d), 40, 60);
g2d.drawString("Hello World by graphics.rotate", 40, 60);
g2d.setTransform(origAT);
}
----------------8X--------------------8X-------------------
Using an AWT graphics object (java.awt.Graphics) both fragments produce the same rotation - the results are printed overlapped.
Using a SVGGraphics2D object, only the 2nd way performs the rotation, the 1st way does _not_ rotate the font! OK, I can use the 2nd variant in my code, but not if I use third party code...
This means, the AWT and SVG results differ! Is this a bug (or missing feature) of the Batik (1.0 and 1.1RC3) generator?
jens
____________________________________________________________
Jens von Pilgrim
4flow AG
Berlin, Germany
