File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "graphics problem!" Watch "graphics problem!" New topic
Author

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
Sheriff

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();
g1.drawLine(10,10,130,130);
transform.rotate(Math.toRadians(45),77,77);
g1.setTransform(transform);
g1.drawString("Hello",75,75);

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: 1007
    
    3
Save the current transform before setting to the rotated one, and then set it back to the saved one.
 
Consider Paul's rocket mass heater.
 
subject: graphics problem!