xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: JSVGCanvas does not update with modified DOM using Update Manager
Date Tue, 06 Nov 2007 11:17:00 GMT
Hi Marc,

"Marc-Wayne M. Formales" <mformales@msn.com> wrote on 10/24/2007 03:00:33 

> I have a JApplet that loads an SVG via JSVGCanvas.
> setDocument(xmlDoc).  If a user clicks on a certain part of the 
> document (any <a> tag), then I have some code that will animate that
> node and replace it in the document object.  I am doing this in the 
> update manager, which does run in the gvtRendering event, but the UI
> is not updated with the changes I made.

>    um.getUpdateRunnableQueue().invokeLater(new Runnable() {
>      public void run() {
>          System.out.println("connID: " + connID);
>          diagramSVG.getDocumentElement().replaceChild(animatedALink,
> aLink);  //where animatedALink is the modified
>          canvas.setDocument(diagramSVG);

    You should not reset the document.  This will be _very_ slow.
However if that did not work then there is almost certainly something
wrong with the elements you construct.

> I know that the DOM object is correct because if I write that 
> to the file system, the changes are there.  Is there something 
> that I'm missing?

   This test is almost useless for detecting namespace problems.
The majority of common namespace errors are corrected by writing 
the file and reparsing it.

"Tonny Kohar" <tonny.kohar@gmail.com> wrote on 11/01/2007 12:07:32 AM:

> On 11/1/07, Marc-Wayne M. Formales <mformales@msn.com> wrote:
> >
> >     Element animate = diagramSVG.createElement("animateColor"); 
> > diagramSVG is Document type

> Batik is namespace aware, so you need to use namespace when creating
> or set attribute using the namespace aware methods

> String svgNS = SVGConstants.SVG_NAMESPACE_URI;
> diagramSVG.createElementNS(svgNS,...)

    Tonny is correct here.  'createElement("animateColor")'
will not work.  It needs to be 'createElementNS(svgNS, "animateColor")'.


> >     //set attributes
> >     animate.setAttribute( ...);
> animate.setAttributeNS(svgNS,...)

   This is generally _not_ correct.  With the exception of
the 'xlink' attributes (most notably xlink:href), all attributes
in SVN need to be set with:

   animate.setAttributeNS(null, ...)

   This could be your problem as if you don't set any
attributes on the animate element (which is what it would
look like to Batik if you put them all in the SVG Namespace
instead of the null namespace).

View raw message