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 "Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> on 2006/11/20 20:18:44 UTC

GVT Tree Rendering

Simple question:

     In what cases do I need to stop and wait for the GVT Tree to
render?  The first time I initialize the canvas?  Every time I switch
documents on the canvas?  Resizing the canvas?  Can anyone tell me when
I need to reset and recheck this value?  I get errors in my application
about a null UpdateManager when refreshing documents and switching
pages.

 

Michael Bishop


RE: GVT Tree Rendering

Posted by "Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil>.
Ouch, OK, that gets complicated.  I have some synchronization on
incoming XMPP events so they arrive in order and I'll have to get things
straight between that queue, the queue going to the UpdateManager and
whether or not the update manager's available.  The code that changes
the document wasn't in the UpdateManager queue, but I recall now that
it's based in the Swing queue as well.  Thanks.

Michael

-----Original Message-----
From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com] 
Sent: Tuesday, November 21, 2006 10:21 AM
To: batik-users@xmlgraphics.apache.org
Cc: batik-users@xmlgraphics.apache.org
Subject: RE: GVT Tree Rendering

Hi Michael,

"Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> wrote on

11/21/2006 08:48:35 AM:

> OK, that's what I thought.  I'm having some trouble with that.  How 
would I 
> wait for that tree to render?  This is what I have (condensed):

   The problem is that you are trying to wait in the Swing thread.
But in order for the GVT rendering to occur it needs to run code
in the Swing thread, that can't happen while you are sitting in
your while loop.

> [...] what I want to do is associate every call to 
> JSVGCanvas.setDocument(...) with a pause to wait for 
> the tree to finish rendering before moving on to process 
> other events.

   Then you will need to create a queue for the events that
arrive while the document is being prepared and play those
events back after the rendering completes.

> As it stands, every call 
> to JSVGCanvas.setDocument(...) is followed by a 5 second pause, then 
> notification of the "rendering complete" method.
> 
> 
> 
> Michael Bishop
> 
> 
> ________________________________
> 
> From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com]
> Sent: Tue 11/21/2006 7:07 AM
> To: batik-users@xmlgraphics.apache.org
> Cc: batik-users@xmlgraphics.apache.org
> Subject: Re: GVT Tree Rendering
> 
> 
> 
> Hi Michael,
> 
> "Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> wrote
on
> 11/20/2006 02:18:44 PM:
> 
> >      In what cases do I need to stop and wait for the GVT Tree to
> render?  The
> > first time I initialize the canvas?  Every time I switch documents
on
> the
> > canvas?
> 
>     Everytime you load a document, the current UpdateManager is
disposed
> of
> and the new UpdateManager is not available until after the first
> rendering.
> The UpdateManager is tied to the document not the Canvas.
> 
> 
> > Resizing the canvas?  Can anyone tell me when I need to reset and
> > recheck this value?  I get errors in my application about a null
> UpdateManager
> > when refreshing documents and switching pages.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail:
batik-users-help@xmlgraphics.apache.org
> 
> 
> [attachment "winmail.dat" deleted by Thomas E. DeWeese/449433/EKC] 
> ---------------------------------------------------------------------
> 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: GVT Tree Rendering

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

"Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> wrote on 
11/21/2006 08:48:35 AM:

> OK, that's what I thought.  I'm having some trouble with that.  How 
would I 
> wait for that tree to render?  This is what I have (condensed):

   The problem is that you are trying to wait in the Swing thread.
But in order for the GVT rendering to occur it needs to run code
in the Swing thread, that can't happen while you are sitting in
your while loop.

> [...] what I want to do is associate every call to 
> JSVGCanvas.setDocument(...) with a pause to wait for 
> the tree to finish rendering before moving on to process 
> other events.

   Then you will need to create a queue for the events that
arrive while the document is being prepared and play those
events back after the rendering completes.

> As it stands, every call 
> to JSVGCanvas.setDocument(...) is followed by a 5 second pause, then 
> notification of the "rendering complete" method.
> 
> 
> 
> Michael Bishop
> 
> 
> ________________________________
> 
> From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com]
> Sent: Tue 11/21/2006 7:07 AM
> To: batik-users@xmlgraphics.apache.org
> Cc: batik-users@xmlgraphics.apache.org
> Subject: Re: GVT Tree Rendering
> 
> 
> 
> Hi Michael,
> 
> "Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> wrote on
> 11/20/2006 02:18:44 PM:
> 
> >      In what cases do I need to stop and wait for the GVT Tree to
> render?  The
> > first time I initialize the canvas?  Every time I switch documents on
> the
> > canvas?
> 
>     Everytime you load a document, the current UpdateManager is disposed
> of
> and the new UpdateManager is not available until after the first
> rendering.
> The UpdateManager is tied to the document not the Canvas.
> 
> 
> > Resizing the canvas?  Can anyone tell me when I need to reset and
> > recheck this value?  I get errors in my application about a null
> UpdateManager
> > when refreshing documents and switching pages.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> [attachment "winmail.dat" deleted by Thomas E. DeWeese/449433/EKC] 
> ---------------------------------------------------------------------
> 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: GVT Tree Rendering

Posted by "Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil>.
OK, that's what I thought.  I'm having some trouble with that.  How would I wait for that tree to render?  This is what I have (condensed):
 
// This variable is set to true when the "rendering complete" event fires.
boolean treeRendered = false;
 
jsvgCanvas.setDocument(svgDocument);
this.waitForGVTTree();
// Returns when the GVT "rendering complete" method is fired or after 5000ms.

public boolean waitForGVTTree() {
     final long startTime = System.currentTimeMillis();
     final long waitTime = 5000;
     long currentTime = System.currentTimeMillis();
     long timeElapsed = currentTime - startTime;

     try {
         while (!treeRendered && (timeElapsed < waitTime)) {
             Thread.sleep(250);

             Thread.yield();
             currentTime = System.currentTimeMillis();
             timeElapsed = currentTime - startTime;
             treeRendered = // Check to see if the "rendering complete" event has been fired.
          }
     } catch (InterruptedException intEx) {
         intEx.printStackTrace();
     }

     return returnValue;
 }

 

What currently happens is that I experience the 5 second timeout, THEN the "rendering complete" method fires.  I'm not sure why this is blocking the entire time.  Essentially what I want to do is associate every call to JSVGCanvas.setDocument(...) with a pause to wait for the tree to finish rendering before moving on to process other events.  As it stands, every call to JSVGCanvas.setDocument(...) is followed by a 5 second pause, then notification of the "rendering complete" method.

 

Michael Bishop


________________________________

From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com]
Sent: Tue 11/21/2006 7:07 AM
To: batik-users@xmlgraphics.apache.org
Cc: batik-users@xmlgraphics.apache.org
Subject: Re: GVT Tree Rendering



Hi Michael,

"Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> wrote on
11/20/2006 02:18:44 PM:

>      In what cases do I need to stop and wait for the GVT Tree to
render?  The
> first time I initialize the canvas?  Every time I switch documents on
the
> canvas?

    Everytime you load a document, the current UpdateManager is disposed
of
and the new UpdateManager is not available until after the first
rendering.
The UpdateManager is tied to the document not the Canvas.


> Resizing the canvas?  Can anyone tell me when I need to reset and
> recheck this value?  I get errors in my application about a null
UpdateManager
> when refreshing documents and switching pages.


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



Re: GVT Tree Rendering

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

"Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> wrote on 
11/20/2006 02:18:44 PM:

>      In what cases do I need to stop and wait for the GVT Tree to 
render?  The
> first time I initialize the canvas?  Every time I switch documents on 
the 
> canvas?

    Everytime you load a document, the current UpdateManager is disposed 
of
and the new UpdateManager is not available until after the first 
rendering.
The UpdateManager is tied to the document not the Canvas.


> Resizing the canvas?  Can anyone tell me when I need to reset and 
> recheck this value?  I get errors in my application about a null 
UpdateManager
> when refreshing documents and switching pages.


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