Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Letters following curve

Reply
Thread Tools

Letters following curve

 
 
Eustace
Guest
Posts: n/a
 
      05-29-2010
I am writing a program that draws arcs and I need to have titles over
each arc. I can use

painter2D.drawString(...);

and even

painter2D.rotate(...);

so that the title will appear at an angle, but what I really want to do
is to have the letters follow the curve of the arc.

I suppose a way to do this is to position each letter of the title and
then rotate each one separately. This is complicated, and besides I
cannot (or it's hard to) calculate with accuracy the desired angle of
rotation of each letter.

Is there another way to do it?

emf

--
It ain't THAT, babe! - A radical reinterpretation
https://files.nyu.edu/emf202/public/...intmebabe.html
 
Reply With Quote
 
 
 
 
Eric Sosman
Guest
Posts: n/a
 
      05-29-2010
On 5/29/2010 5:51 PM, Eustace wrote:
> I am writing a program that draws arcs and I need to have titles over
> each arc. I can use
>
> painter2D.drawString(...);
>
> and even
>
> painter2D.rotate(...);
>
> so that the title will appear at an angle, but what I really want to do
> is to have the letters follow the curve of the arc.
>
> I suppose a way to do this is to position each letter of the title and
> then rotate each one separately. This is complicated, and besides I
> cannot (or it's hard to) calculate with accuracy the desired angle of
> rotation of each letter.
>
> Is there another way to do it?


Googling for "curved text in java" gets several likely-
looking hits, including

http://www.java2s.com/Code/Java/2D-G...longacurve.htm

--
Eric Sosman
http://www.velocityreviews.com/forums/(E-Mail Removed)lid
 
Reply With Quote
 
 
 
 
Eustace
Guest
Posts: n/a
 
      06-01-2010
On 2010-05-29 18:16 Peter Duniho wrote:
> Eustace wrote:
>> I am writing a program that draws arcs and I need to have titles over
>> each arc. I can use
>>
>> painter2D.drawString(...);
>>
>> and even
>>
>> painter2D.rotate(...);
>>
>> so that the title will appear at an angle, but what I really want to
>> do is to have the letters follow the curve of the arc.
>>
>> I suppose a way to do this is to position each letter of the title and
>> then rotate each one separately. This is complicated, and besides I
>> cannot (or it's hard to) calculate with accuracy the desired angle of
>> rotation of each letter.
>>
>> Is there another way to do it?

>
> Calculating the angle should not be difficult, assuming you have a
> reasonable way to define the arc. For example, if the arc is defined as
> a segment of an ellipse, then the tangent at the letter's position along
> the arc is easily determined, and of course the tangent defines the
> baseline rotation for the letter.
>
> Then you have to determine what position along the arc the letter is
> drawn. However, that also should not be that hard. The string will
> take a certain length without transformation, with each letter being at
> a specific position. So simply map the straight-line distances for the
> untransformed string onto the arc on which you want to draw the string.
> That will allow you to find positions for the individual characters
> along the arc.
>
> As for making it easier, well…that's what OOP is all about. Write a
> simple class that does the harder work of enumerating each character and
> drawing it individually with the appropriate rotation for its position.
> Once you've done that, then where you actually have the need to draw
> entire strings along some arc, just use that class. Then the code where
> you need that drawing done remains nice and simple.
>
> Pete


It was easier than I thought. Even for an ellipse. Though there are
minor adjustments necessary because the coordinates do not point to the
middle of the character. And then, clearly monospaced font appears
better... Thanks, emf

--
It ain't THAT, babe! - A radical reinterpretation
https://files.nyu.edu/emf202/public/...intmebabe.html
 
Reply With Quote
 
Eustace
Guest
Posts: n/a
 
      06-01-2010
On 2010-05-29 18:20 Eric Sosman wrote:
> On 5/29/2010 5:51 PM, Eustace wrote:
>> I am writing a program that draws arcs and I need to have titles over
>> each arc. I can use
>>
>> painter2D.drawString(...);
>>
>> and even
>>
>> painter2D.rotate(...);
>>
>> so that the title will appear at an angle, but what I really want to do
>> is to have the letters follow the curve of the arc.
>>
>> I suppose a way to do this is to position each letter of the title and
>> then rotate each one separately. This is complicated, and besides I
>> cannot (or it's hard to) calculate with accuracy the desired angle of
>> rotation of each letter.
>>
>> Is there another way to do it?

>
> Googling for "curved text in java" gets several likely-
> looking hits, including
>
> http://www.java2s.com/Code/Java/2D-G...longacurve.htm


Interesting. However the letters seem a little more inclined than I
think they should, and I haven't yet found out why and how to affect it.
emf

--
It ain't THAT, babe! - A radical reinterpretation
https://files.nyu.edu/emf202/public/...intmebabe.html
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The Web server reported the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/822319ev1'. 'HTTP/1.1 500 Internal Server Error'. chanmm ASP .Net 2 09-07-2010 07:37 AM
curve and curve with error objects : sorting , friend Hicham Mouline C++ 2 09-14-2009 02:11 PM
making all letters Caps/Small Letters Merrigan Python 4 12-14-2007 10:10 AM
RE: The Web server reported the following error when attempting to create or open the Web project located at the following URL: <URL> =?Utf-8?B?VHJldm9yIEJlbmVkaWN0IFI=?= ASP .Net 0 06-07-2004 07:36 AM
Changing from capital letters to small letters using perl Venugopal Perl Misc 11 11-05-2003 06:07 PM



Advertisments