Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to rotate a string 90 degree in the display

 
ruilin yang
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amit,
Thanks
I will try it.
Ruilin
 
Paul Bailey
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic