xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cameron McCormack <cam-batik-us...@aka.mcc.id.au>
Subject Re: SVGTextElement.getComputedTextLength()
Date Wed, 26 Jan 2005 13:28:47 GMT
Hi Kristian.

Kristian Spangsege:
> Still I'm left with a "chicken and egg" problem.
> 
> All I need to do is to create an SVG document with a piece of text at a 
> specific position and followed by a vertical separation line. Problem is 
> that I need to know the width of the text before I can place the 
> vertical seperation line.
> 
> It seems wierd to me, if I'm supposed to first add the separation line 
> at some random position, then fire up the DOM, and then calculate the 
> desired position of the separation line.

Well no, you can create the document with the text element, build the
GVT tree, and then get the text size and add the line element.

> - Is there another method of inquiring on the length of a certain string 
> of characters?

You can use getBBox(), but of course, this also needs to be done after
the GVT tree has been built and only if the document is in the
ALWAYS_DYNAMIC state.

> - When the sole purpose is to generate an on-disk document, would it be 
> a resonable approach to actually fire up the DOM with an empty document 
> then construct the SVG elements as needed. I assume that in this case it 
> is legal to call getComputedTextLength() immediately after constructing 
> the SVGTextElement.

Yes, to get the dimensions of the text you will have to have the
graphics tree built.  Starting with an empty SVG element or with a
document with your text element already in it shouldn't matter too much.
(Though there will be a very slight overhead when adding the text
element to the document whose graphics tree has already been built, but
nothing noticeable.)

Cameron

-- 
Cameron McCormack
|  Web: http://mcc.id.au/
|  ICQ: 26955922

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message