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 Fredrik Medby Hagen <Fr...@idi.ntnu.no> on 2005/04/23 17:04:21 UTC

setDocument doesn't set document

Hi. My problem is: when calling JSVGComponent.setDocument, document is not
set (at line [*] in the code below the old doc is returned)... I have no
clue of what can be the problem. I've probably gone code-blind.

---CODE---

SVGDocument oldDoc = svgCanvas.getSVGDocument(); //document before update
svgCanvas.setDocument(doc); //changing to new document
if(svgCanvas.getSVGDocument() == oldDoc) //if new document hasn't been
installed yet (method might return before doc is set), wait 10sec
   //try{synchronized(dla){dla.wait(0);}}catch(Exception
e){e.printStackTrace();}
   try{synchronized(this){wait(10000);}}
   catch(Exception e){e.printStackTrace();
}
[*]   svgDocument = svgCanvas.getSVGDocument(); //document should now have
been changed.

---CODE---

Any ideas?

Sincerely,

Fredrik


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


Re: setDocument doesn't set document

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Fredrik,

Fredrik Medby Hagen wrote:
> Hi. My problem is: when calling JSVGComponent.setDocument, document is not
> set (at line [*] in the code below the old doc is returned)... I have no
> clue of what can be the problem. I've probably gone code-blind.

    The problem is that the install of the document is asynchronous
most of the work is done in another thread but it needs to come
back to the Swing thread to finish the install of the document.

    Your waiting in the swing thread prevents this.  If you want
to be notified when the document is installed you should
register a GVTTreeBuilderListener when it starts your document
will have been installed.

> 
> ---CODE---
> 
> SVGDocument oldDoc = svgCanvas.getSVGDocument(); //document before update
> svgCanvas.setDocument(doc); //changing to new document
> if(svgCanvas.getSVGDocument() == oldDoc) //if new document hasn't been
> installed yet (method might return before doc is set), wait 10sec
>    //try{synchronized(dla){dla.wait(0);}}catch(Exception
> e){e.printStackTrace();}
>    try{synchronized(this){wait(10000);}}
>    catch(Exception e){e.printStackTrace();
> }
> [*]   svgDocument = svgCanvas.getSVGDocument(); //document should now have
> been changed.
> 
> ---CODE---
> 
> Any ideas?
> 
> Sincerely,
> 
> Fredrik
> 
> 
> ---------------------------------------------------------------------
> 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