File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes graphics problem! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "graphics problem!" Watch "graphics problem!" New topic

graphics problem!

Mateen Dar
Ranch Hand

Joined: Jan 14, 2005
Posts: 55
hi , i am facing triouble with a small grpahics problem. my project draws liens between various nodes. then a string is printed on these edges. the problem is g.drawString() writes the string completly horizontally. i want the string to be printed neatly next to the edge. u understand what i mean. how can i do this. i know the graphics 2d library has affine transformation, but i dont know how i can do it. thanks for u'r help

the String
Michael Ernest
High Plains Drifter

Joined: Oct 25, 2000
Posts: 7292

Really need to see some code on that in order to help.

Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Mateen Dar
Ranch Hand

Joined: Jan 14, 2005
Posts: 55
Graphics2D g1= (Graphics2D)g;
AffineTransform transform=new AffineTransform();

this piece code does the trick .. but how do i undo the transform. cuase i have other strings to be printed at a different angle. thanks.
Ryan McGuire
Ranch Hand

Joined: Feb 18, 2005
Posts: 1044
Save the current transform before setting to the rotated one, and then set it back to the saved one.
I agree. Here's the link:
subject: graphics problem!
It's not a secret anymore!