-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.0
-
x86
-
windows_nt
Name: boT120536 Date: 09/04/2001
java version "1.4.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta2-b77)
Java HotSpot(TM) Client VM (build 1.4.0-beta2-b77, mixed mode)
I was messing around with displaying text using the Java fonts and I noticed
that when I would set the rotation of the Graphics2D object and then draw the
text, the text would not display exactly where i wanted it to...close, but not
exact. But if the rotation was 0 degrees, it WOULD display exactly where i
expected it.
So I switched back to the 1.3.1 version of the JDK....and it works correctly!
The text draws exactly where i tell it to draw...not shifted based on rotation
angle.
For further evidence...I draw a rectangle at the XY coordinate that i tell the
text to draw. At 0 degrees, the rectantle and text show up at the same spot.
Rotated about a given point by 90 degrees, the rectangle and text no longer
exactly match...the rectangle is where i expect it to be...but the text is not.
HERE IS A PROGRAM THAT DEMONSTRATES THE PROBLEM...Note that it works correctly
in 1.3.1...incorrectly in 1.4 beta 2:
import javax.swing.JFrame;
import java.awt.Component;
import java.awt.Container;
import java.awt.Graphics2D;
import java.awt.Graphics;
import java.awt.geom.AffineTransform;
import java.awt.Color;
import javax.swing.JPanel;
import java.awt.BasicStroke;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.Font;
public class Test
{
private static boolean _bPass1=true;
public static void main(String args[])
{
JFrame jfrm = new JFrame("Rotate Text Problem");
Component jcmp = (Component) jfrm.getContentPane();
Container jcnt = (Container) jcmp;
jcnt.add( new JPanel()
{
public void paint(Graphics g)
{
Graphics2D drw = (Graphics2D) g;
Font f = new Font("Times",Font.PLAIN, 14);
drw.setFont(f);
drw.setColor(Color.black);
drw.drawString("Kelly Harmon",200,200);
drw.drawRect(197,197,6,6);
AffineTransform affTrans = new AffineTransform();
affTrans.setToIdentity();
affTrans.rotate(4.71,100,100);
drw.setTransform(affTrans);
drw.drawString("Kelly Harmon",110,110);
drw.drawRect(107,107,6,6);
// done!
}
});
jcnt.addMouseListener( new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
_bPass1=false;
Component comp = (Component) e.getSource();
comp.repaint();
}
});
jfrm.setBounds (0,0,800,600);
jfrm.setVisible(true);
}
}
(Review ID: 131276)
======================================================================
- duplicates
-
JDK-4491131 Rotated text is not rendered in correctly.
-
- Closed
-