?
Solved

Draw Text from Right

Posted on 2002-04-08
8
Medium Priority
?
465 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month12 days, 23 hours left to enroll

777 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