Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

how to rotate a string 90 degree in the display  RSS feed

 
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
 
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
 
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
Boost this thread!