Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
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
Devaka Cooray
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Jeanne Boyarsky
Tim Cooke
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Tim Moores
Mikalai Zaikin
Carey Brown
Bartenders:
Forum:
Swing / AWT / SWT
How to turn the text vertical in graphics?
Shashi Bhushan N
Greenhorn
Posts: 12
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I was just using
g.drawString("N.SHASHIBHUSHAN",50,50);
and thought of displaying my name vertically
N
.
S
H
A
S
H
I
B
H
U
S
H
A
N
!!!@#$%!!!
But how do i do it in the
applet
???
Thankyou and regards.
Shashi Bhushan N
Greenhorn
Posts: 12
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Is there any facility in FontMetrics or Font or Swing.text to turn my text vertical??
David Gilbert
Ranch Hand
Posts: 42
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Here's the method I use in JFreeChart to draw vertical labels for axes:
/** * A utility method for drawing rotated text. * <P> * A common rotation is -Math.PI/2 which draws text 'vertically' (with the top of the * characters on the left). * * @param text the text. * @param g2 the graphics device. * @param textX the x-coordinate for the text (before rotation). * @param textY the y-coordinate for the text (before rotation). * @param angle the angle of the (clockwise) rotation (in radians). * @param rotateX the point about which the text is rotated. * @param rotateY the point about which the text is rotated. */ public static void drawRotatedString(String text, Graphics2D g2, float textX, float textY, double angle, float rotateX, float rotateY) { if ((text == null) || (text.equals(""))) { return; } AffineTransform saved = g2.getTransform(); // apply the rotation... AffineTransform rotate = AffineTransform.getRotateInstance(angle, rotateX, rotateY); g2.transform(rotate); if (useDrawRotatedStringWorkaround) { // workaround for JDC bug ID 4312117 and others... TextLayout tl = new TextLayout(text, g2.getFont(), g2.getFontRenderContext()); tl.draw(g2, textX, textY); } else { // replaces this code... g2.drawString(text, textX, textY); } g2.setTransform(saved); }
Regards,
Dave Gilbert
JFreeChart Project Leader
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
associativity and precedence...prob..pls..help
Finding the index of a character in an array
I need to put a double into a vector
JSP behaving badly!
Reg. >>
More...