• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 471
  • Last Modified:

Draw Text from Right

Hi Gurus,
   In my Project i have to generate an Image. For this iam using com.sun.image.codec.jpeg.*; In the image Iam drawing the text (request from a Jsp to a servlet.

   I want to align the text from right to Left. Can any one explain How to draw the text from right to left in Java.

Thanks in advance
VasanS
0
vasan_sr
Asked:
vasan_sr
1 Solution
 
objectsCommented:
Do you just want to right align your text, or do you actually want to draw the text from right to left (ie. first word appears on the right).

If you just want to right align, then you need to use FontMetrics to calculate the width of your text and draw it such that the last char appears on the right edge.

If you actually want to draw your text from right to left, then simply reverse your string and right align as above.
0
 
vasan_srAuthor Commented:
HI,
  Iam drawing an Arabic Text , so it has to align from right to left. I found the width of the text, also it is not alifning proper.

  One more solution is there..ie by using TextLayout. Can u explain how to use text layout in drawing text from right to left

VasanS
0
 
objectsCommented:
Sorry haven't ever used TextLayout.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
OviCommented:
Since you draw on a Image, I assume that you have a Graphics object. All you have to do is to draw from right to left, starting with "image.width" coordinate, decreasing the drawing point with the last drawed character width, down to 0.

Or you can remap the coordinates from {x = 0, y = 0}={top left corner} to {top right corner}
0
 
jose_tijoCommented:
0
 
vasan_srAuthor Commented:
Dear Ovi,
   can u be more clear.How to drawString from right to left. Only we can give the x & Y co-ordinates and it will paint from that co-ordinalte..

   I want to paint from the right to left. Can u explain more. If u explain with example i will be more happy.

VasanS
   
0
 
Venci75Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
PAQ'd and pts refunded
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venci75
EE Cleanup Volunteer
0
 
SpideyModCommented:
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now