xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DeWeese Thomas <thomas.dewe...@gmail.com>
Subject Re: How to assert that a document is done loading
Date Tue, 05 Jun 2012 22:47:00 GMT
Hi Marco,
	I would suggest adding your listener before starting the load of the document.
Then you know for sure that the document hasn't finished when you add your listener.

	Also I should point out that getSVGDocument might return true before the SVG DOM
is really ready to be used so just checking that could be bad you really need to use the
LoadEventDispatcherListener.

	Finally you need to make sure that you set the canvas to ALWAYS_DYNAMIC
otherwise you might not get the load event called for static looking SVG documents.

	Thomas

On Jun 5, 2012, at 7:31 AM, ml@mherrn.de wrote:

> Hi,
> 
> when trying to access the DOM of an SVG document in a JSVGCanvas, it
> should be done via an SVGLoadEventDispatcherListener, to assert that the
> document is only accessed, when the parsing finished.
> For example:
> 
> this.svgCanvas.addSVGLoadEventDispatcherListener(new
> SVGLoadEventDispatcherAdapter() {
>          @Override
>          public void
> svgLoadEventDispatchStarted(SVGLoadEventDispatcherEvent e) {
>              final Element element=
> svgCanvas.getSVGDocument().getElementById(elementId);
>                  element.setAttribute("visibility", "hidden");
>              }
>          }
>      });
> 
> 
> But, of course, this handler is only called once, when the document was
> loaded. But what, if I can't be sure whether the document was already
> loaded, but still want to apply this code?
> 
> What is the recommended approach to modify the DOM, regardless of the
> fact, whether the document finished loading or not?
> 
> 
> Regards
> Marco
> 
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message