• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to rotate a string 90 degree in the display

 
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Amit,
Thanks
I will try it.
Ruilin
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic