Hi Charles,

On Feb 20, 2012, at 6:37 PM, Andrew Rowlands <a.rowla...@uq.edu.au> wrote:

> FWIW, I thought timing was a problem too with bbox(),

   I don't think so. If you are using the canvas you need to be very careful 
about threading since changing the document during rendering is going to cause 
problems.

    The bbox and other APIs in Batik should always return the right value as 
long as you don't have multiple threads manipulating the tree at the same time.

> but when I was modifying text nodes (on a path) using UpdateManager and 
> subsequently calling bbox it would fail (reproducibly and in the same way as 
> not using UM)

This probably indicates some misunderstanding in how the update manager works.  
If you care to explain things a bit more I might be able to help you understand 
the issue.

   Thomas DeWeese

> On 21/02/2012, at 11:04 AM, Martin J wrote:
> 
>> Charles,
>> 
>> bbox() is indeed tricky! Try doing it on rotated text, or worse, text
>> on a path! However, your problem may only be a timing issue -- Batik
>> only knows the bbox once the text has been rendered, and in your
>> example there's probably not time for the renderer to have done its
>> work when you interrogate the properties.
>> 
>> HTH
>> Martin
>> 
>> On 20 February 2012 22:16, Charles Seelig <charles.see...@gmail.com> wrote:
>>> Hello, all.
>>> 
>>> I'm wondering if anyone could point me in the right direction re: coaxing
>>> an SVGTextElement to return a correct bounding box when the text contains
>>> ISO encoded characters.
>>> 
>>> SVGDocument doc = makeSvgDocument(svgString);
>>> 
>>> SVGTextElement svgTextElement = (SVGTextElement)
>>> doc.getElementById("textID");
>>> 
>>> svgTextElement.getFirstChild().setNodeValue("&#913;&#937;");
>>> 
>>> float width = svgTextElement.getBBox().getWidth();
>>> 
>>> 
>>> My document is created as follows -
>>> 
>>> protected SVGDocument makeSvgDocument(String svgString) {
>>> 
>>> SVGDocument svgDoc = null;
>>> 
>>> @SuppressWarnings("unused")
>>> 
>>> GraphicsNode rootGN;
>>> 
>>> UserAgent userAgent    = new UserAgentAdapter();
>>> 
>>> DocumentLoader loader  = new DocumentLoader(userAgent);
>>> 
>>> BridgeContext ctx      = new BridgeContext(userAgent, loader);
>>> 
>>> GVTBuilder builder     = new GVTBuilder();
>>> 
>>> SAXSVGDocumentFactory factory = new
>>> SAXSVGDocumentFactory(SAXParser.class.getCanonicalName(), true);
>>> 
>>> try {
>>> 
>>> svgDoc = (SVGDocument)
>>> factory.createDocument("file:///dummy/dummy/file.svg", new
>>> StringReader(svgString));
>>> 
>>> ctx.setDynamicState(BridgeContext.DYNAMIC);
>>> 
>>> rootGN = builder.build(ctx, svgDoc);
>>> 
>>> } catch (IOException e) {
>>> 
>>> e.printStackTrace();
>>> 
>>> }
>>> 
>>> return svgDoc;
>>> 
>>> }
>>> 
>>> 
>>> It appears to me that the result (especially evident for width) is
>>> calculated as if the 1 character is actually 6 characters.
>>> 
>>> Thank you.
>>> 
>>> Best regards,
>>> 
>>> Charles Seelig
>>> 
>> 
>> 
>> 
>> -- 
>> From my MacBook Pro
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
>> For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org

Reply via email to