wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes how to rotate a string 90 degree in the display Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to rotate a string 90 degree in the display" Watch "how to rotate a string 90 degree in the display" New topic
Author

how to rotate a string 90 degree in the display

ruilin yang
Ranch Hand

Joined: Feb 25, 2001
Posts: 334
Please help
I would like to write a string vertically in the display, i.e. 90 degree rotation anti-clockwise for a label of Y-axis.
Please help me how to do it.
Thanks a lot.
Ruilin
ruilin yang
Ranch Hand

Joined: Feb 25, 2001
Posts: 334
I looked Graphics class. I do not find any method doing rotation.
Anybody know this matter please help me.
Thanks a lot.
Ruilin
Amit Agarwal
Ranch Hand

Joined: May 09, 2001
Posts: 92
Try AffineTransform class of Java2D.
use:
import java.awt.geom.*;
...
AffineTransform at= AffineTransform.getRotateInstance(Math.toRadians(90),x,y);
Graphics2D g2=(Graphics2D)g;
g2.transform(at);
g2.drawString("Y-label",x,y);
g2.transform(new AffineTransform()); // reset

--------------
Amit
[This message has been edited by Amit Agarwal (edited May 29, 2001).]
ruilin yang
Ranch Hand

Joined: Feb 25, 2001
Posts: 334
Amit,
Thanks
I will try it.
Ruilin
Paul Bailey
Ranch Hand

Joined: Oct 20, 2000
Posts: 91
This will work... for now. Someday Sun may decide to make some other class that implements Graphics and use it. At this time you will not necessarily be able to cast every graphics as a graphics2D.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to rotate a string 90 degree in the display