You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Ryan Wilson <ry...@ayokasystems.com> on 2008/08/10 08:29:19 UTC

Attempting to use text causes lock up

I have been attempting to add text to an svg document while it is being
displayed by SVGCanvas.However, every time the code reaches the append(text)
call the whole program locks up. Am I missing a step?

The code in question:

Element text = document.createElementNS(svgNS, "text");
System.out.println(text.getTextContent());
text.setTextContent("B");
//Text value = document.createTextNode("Broccoli and Cheese");
//System.out.println(value.getWholeText());

//text.appendChild(value);

text.setAttributeNS(svgNS, "fill", "red");
text.setAttributeNS(svgNS, "x", "0");
text.setAttributeNS(svgNS, "y", "0");


Element svgRoot = document.getDocumentElement();
svgRoot.appendChild(circle);
svgRoot.appendChild(rect2);
//svgRoot.appendChild(text);

This code is being executed from within a object being fed to the
updaterunnablequeue. The two other appends work without complaint, only the
text rendering is causing problems.
The machine running this code is an Ubuntu 8.04 setup with java 1.6 running.

Ryan Wilson

Re: Attempting to use text causes lock up

Posted by Helder Magalhães <he...@gmail.com>.
> That was it. Once I set the font-size attribute it runs smoothly. Thanks for
> the idea!
>
> Seems like an extreme reaction to a missing attribute...

Weird, in deed. :-|

Note that Thomas has made important comments. Have you tried them?
Could the font-size «fix» be hiding more serious issues in your code?

Regards,

 Helder

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


Re: Attempting to use text causes lock up

Posted by Ryan Wilson <ry...@ayokasystems.com>.
That was it. Once I set the font-size attribute it runs smoothly. Thanks for
the idea!

Seems like an extreme reaction to a missing attribute...

Ryan Wilson

On Tue, Aug 12, 2008 at 4:06 AM, Helder Magalhães <
helder.magalhaes@gmail.com> wrote:

> > Am I missing a step?
>
> Have you tried setting font-size [1]? For example:
>
>  text.setAttributeNS(svgNS, "font-size", "12");
>
> Also, which version [2] of Apache Batik are you using? Distribution?
> Trunk/SVN?
>
> Hope this helps,
>
>  Helder Magalhães
>
> [1] http://www.w3.org/TR/SVG/text.html#FontSizeProperty
> [2] http://xmlgraphics.apache.org/batik/download.cgi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>

Re: Attempting to use text causes lock up

Posted by Helder Magalhães <he...@gmail.com>.
> Am I missing a step?

Have you tried setting font-size [1]? For example:

  text.setAttributeNS(svgNS, "font-size", "12");

Also, which version [2] of Apache Batik are you using? Distribution? Trunk/SVN?

Hope this helps,

 Helder Magalhães

[1] http://www.w3.org/TR/SVG/text.html#FontSizeProperty
[2] http://xmlgraphics.apache.org/batik/download.cgi

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


Re: Attempting to use text causes lock up

Posted by th...@kodak.com.
Hi Ryan,

"Ryan Wilson" <ry...@ayokasystems.com> wrote on 08/10/2008 02:29:19 
AM:

> I have been attempting to add text to an svg document while it is 
> being displayed by SVGCanvas.However, every time the code reaches 
> the append(text) call the whole program locks up. Am I missing a step?

   I don't see anything that would cause the lockup in the code posted.
Obviously we have done the same basic thing many times so I suspect
that it has something to do with the rest of your code.  There is
at least one obvious bug but I don't think it's the cause of the
lockup:

> text.setAttributeNS(svgNS, "fill", "red");
> text.setAttributeNS(svgNS, "x", "0");
> text.setAttributeNS(svgNS, "y", "0");

    These should all use 'null' for the namespace.
Attributes (except primarily 'xlink') should use the
null namespace.

> This code is being executed from within a object being fed to the 
> updaterunnablequeue. The two other appends work without complaint, 
> only the text rendering is causing problems.

   Are you using invokeAndWait from the Swing thread?
That can cause lockups if the rendering engine needs to query
the UserAgent about anything (and text might query something
from the UserAgent).