Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rotating the Text in an Applet

 
mars76
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am generating graphs dynamically in my application. And on the Y-axis i wants to display the Parameter Name along the y-axis. Inorder to do that i need to rotate the text by 90 degrees.
I tried with setTransform() method of Graphics2D object , but it's not rotating the Text..
Thanks in advance...
Sateesh
 
Amit Agarwal
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Satish,
you have to use the AffineTransform class of the java.awt.geom package. Usage:
public void paint(Graphics g)
{
...
Graphics2D g2=(Graphics2D)g;
AffineTransform at=AffineTransform.getRotateInstance(Math.PI/2, x, y);
g2.setTransform(at);
d2.drawString("Y Label",x,y);
g2.setTransform(new AffineTransform()); // reset

...
}

-----------
Amit
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic