Solved

Draw Text from Right

Posted on 2002-04-08
8
462 Views
Last Modified: 2009-12-16
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
Comment
Question by:vasan_sr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 92

Expert Comment

by:objects
ID: 6926962
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
 
LVL 2

Author Comment

by:vasan_sr
ID: 6927173
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
 
LVL 92

Expert Comment

by:objects
ID: 6927261
Sorry haven't ever used TextLayout.
0
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 
LVL 9

Expert Comment

by:Ovi
ID: 6927293
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
 
LVL 1

Expert Comment

by:jose_tijo
ID: 6927462
0
 
LVL 2

Author Comment

by:vasan_sr
ID: 6928197
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
 
LVL 9

Expert Comment

by:Venci75
ID: 7933441
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
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 7984219
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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question