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 Tacio Santos <ta...@gmail.com> on 2007/03/07 06:21:02 UTC

UpdateManager thread not refreshing dynamic svg in JSVGCanvas

Hi,

I'm new to batik and to svg. I'm trying to dynamically add elements to
a JSVGCanvas but updates are not been displayed. I went throgh the FAQ
and the mailing list archives( from 200501 to 200703) but I haven't
found a hint to my problem. Does anybody know what am I missing or
mistaking in the code below?

Thanks in advance,
Tacio

PS:

canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
canvas.setURI( MY_SVG_FILE );
..
// after gvtRenderingCompleted event I'm doing:

canvas.getUpdateManager().getUpdateRunnableQueue()
		.invokeLater(
				new Runnable() {
					public void run() {

						SVGDocument doc = canvas.getSVGDocument();
						SVGSVGElement root =doc.getRootElement();
						String svgNS="http://www.w3.org/2000/svg";
						Element rectangle = doc.createElementNS(svgNS, "rect");
						rectangle.setAttributeNS(null, "x", "200");
						rectangle.setAttributeNS(null, "y", "200" );
						rectangle.setAttributeNS(null, "width", "100");
						rectangle.setAttributeNS(null, "height", "510");
                  }
            );

PS2: My system

BATIK version 1.6

JAVA:

java version "1.5.0_10"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_10-b03, mixed mode)

OS:
Debian GNU/Linux 4.0 (etch)
Linux  2.6.18-3-amd64  SMP x86_64

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


Re: UpdateManager thread not refreshing dynamic svg in JSVGCanvas

Posted by Tacio Santos <ta...@gmail.com>.
Thanks, it now works! :-) It was my fault. The ancestor had visibility hidden.
cheers,
Tacio

On 3/7/07, thomas.deweese@kodak.com <th...@kodak.com> wrote:
> Hi Tacio,
>
> "Tacio Santos" <ta...@gmail.com> wrote on 03/07/2007 04:25:51 AM:
>
> > thanks for the replies, I was indeed forgetting to append rectangle
> > I've created. But I'm still not getting it displayed though with the
> > DOM Viewer I can see it was added, any ideas?
>
>    What does the root element of the document you are loading look
> like?  Also what element are you appending it to?  You aren't setting
> any fill/stroke attributes (so it will inherit from it's parent).
>
>    It could be a simple matter of the rect being "off screen".
> The rect could be a child of an undisplayed element (ancestor
> has display="none", visibility="hidden", etc).
>
> > thanks,
> > Tacio
> >
> >
> >
> > On 3/7/07, Tonny Kohar <to...@kiyut.com> wrote:
> > > Hi,
> > >
> > > On Wed, 2007-03-07 at 07:59 +0100, Pepping, Florian wrote:
> > > > Hi Tacio,
> > > >
> > > > I don't see any line of code where you are adding the created
> Element to
> > > > your document. Try adding something like this to your code:
> > > > root.appendChild(rectangle);
> > > >
> > > > Than it should work, the rest looks ok.
> > >
> > > Yup exactly, creating an element does not means adding an element.
> > > So after creating element you still need to add that created element
> > > into some node eg: root node, g node, etc
> > >
> > >
> > > Regards
> > > Tonny Kohar
> > > --
> > > Sketsa
> > > SVG Graphics Editor
> > > http://www.kiyut.com
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > > For additional commands, e-mail:
> batik-users-help@xmlgraphics.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>

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


Re: UpdateManager thread not refreshing dynamic svg in JSVGCanvas

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

"Tacio Santos" <ta...@gmail.com> wrote on 03/07/2007 04:25:51 AM:

> thanks for the replies, I was indeed forgetting to append rectangle
> I've created. But I'm still not getting it displayed though with the
> DOM Viewer I can see it was added, any ideas?

   What does the root element of the document you are loading look
like?  Also what element are you appending it to?  You aren't setting
any fill/stroke attributes (so it will inherit from it's parent).

   It could be a simple matter of the rect being "off screen".
The rect could be a child of an undisplayed element (ancestor
has display="none", visibility="hidden", etc).

> thanks,
> Tacio
> 
> 
> 
> On 3/7/07, Tonny Kohar <to...@kiyut.com> wrote:
> > Hi,
> >
> > On Wed, 2007-03-07 at 07:59 +0100, Pepping, Florian wrote:
> > > Hi Tacio,
> > >
> > > I don't see any line of code where you are adding the created 
Element to
> > > your document. Try adding something like this to your code:
> > > root.appendChild(rectangle);
> > >
> > > Than it should work, the rest looks ok.
> >
> > Yup exactly, creating an element does not means adding an element.
> > So after creating element you still need to add that created element
> > into some node eg: root node, g node, etc
> >
> >
> > Regards
> > Tonny Kohar
> > --
> > Sketsa
> > SVG Graphics Editor
> > http://www.kiyut.com
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: 
batik-users-help@xmlgraphics.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


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


Re: UpdateManager thread not refreshing dynamic svg in JSVGCanvas

Posted by Tacio Santos <ta...@gmail.com>.
Hi,
thanks for the replies, I was indeed forgetting to append rectangle
I've created. But I'm still not getting it displayed though with the
DOM Viewer I can see it was added, any ideas?

thanks,
Tacio



On 3/7/07, Tonny Kohar <to...@kiyut.com> wrote:
> Hi,
>
> On Wed, 2007-03-07 at 07:59 +0100, Pepping, Florian wrote:
> > Hi Tacio,
> >
> > I don't see any line of code where you are adding the created Element to
> > your document. Try adding something like this to your code:
> > root.appendChild(rectangle);
> >
> > Than it should work, the rest looks ok.
>
> Yup exactly, creating an element does not means adding an element.
> So after creating element you still need to add that created element
> into some node eg: root node, g node, etc
>
>
> Regards
> Tonny Kohar
> --
> Sketsa
> SVG Graphics Editor
> http://www.kiyut.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>

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


RE: UpdateManager thread not refreshing dynamic svg in JSVGCanvas

Posted by Tonny Kohar <to...@kiyut.com>.
Hi,

On Wed, 2007-03-07 at 07:59 +0100, Pepping, Florian wrote:
> Hi Tacio,
> 
> I don't see any line of code where you are adding the created Element to
> your document. Try adding something like this to your code:
> root.appendChild(rectangle);
> 
> Than it should work, the rest looks ok.

Yup exactly, creating an element does not means adding an element.
So after creating element you still need to add that created element
into some node eg: root node, g node, etc


Regards
Tonny Kohar
-- 
Sketsa 
SVG Graphics Editor
http://www.kiyut.com


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


RE: UpdateManager thread not refreshing dynamic svg in JSVGCanvas

Posted by "Pepping, Florian" <fl...@wincor-nixdorf.com>.
Hi Tacio,

I don't see any line of code where you are adding the created Element to
your document. Try adding something like this to your code:
root.appendChild(rectangle);

Than it should work, the rest looks ok.

Good luck and have fun

Florian

-----Original Message-----
From: Tacio Santos [mailto:tacio.santos@gmail.com] 
Sent: Wednesday, March 07, 2007 6:21 AM
To: batik-users@xmlgraphics.apache.org
Subject: UpdateManager thread not refreshing dynamic svg in JSVGCanvas

Hi,

I'm new to batik and to svg. I'm trying to dynamically add elements to
a JSVGCanvas but updates are not been displayed. I went throgh the FAQ
and the mailing list archives( from 200501 to 200703) but I haven't
found a hint to my problem. Does anybody know what am I missing or
mistaking in the code below?

Thanks in advance,
Tacio

PS:

canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
canvas.setURI( MY_SVG_FILE );
..
// after gvtRenderingCompleted event I'm doing:

canvas.getUpdateManager().getUpdateRunnableQueue()
		.invokeLater(
				new Runnable() {
					public void run() {

						SVGDocument doc =
canvas.getSVGDocument();
						SVGSVGElement root
=doc.getRootElement();
						String
svgNS="http://www.w3.org/2000/svg";
						Element rectangle =
doc.createElementNS(svgNS, "rect");
	
rectangle.setAttributeNS(null, "x", "200");
	
rectangle.setAttributeNS(null, "y", "200" );
	
rectangle.setAttributeNS(null, "width", "100");
	
rectangle.setAttributeNS(null, "height", "510");
                  }
            );

PS2: My system

BATIK version 1.6

JAVA:

java version "1.5.0_10"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_10-b03, mixed mode)

OS:
Debian GNU/Linux 4.0 (etch)
Linux  2.6.18-3-amd64  SMP x86_64

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


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