xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Ávila <asan...@nextech.com.br>
Subject Replace JSVGCanvas on the fly
Date Fri, 10 Mar 2006 18:51:04 GMT
Hello,

I want to implement a kind of "multi-page" behavior in my application. The idea is to load
a bunch of "pages" (which are SVG files) into memory and display them sequentially as the
user clicks a "next" button. 

I managed to do that in a very simple way. I keep the pages in memory as SVGDocument objects,
and when the user clicks "next", I just call JSVGCanvas.setDocument() passing the next page.
It works fine, except for the fact that it goes through all the rendering process every time,
so performance is really poor.

I then went a step further. Instead of mantaining a bunch of SVGDocument objects in memory,
I mantain JSVGCanvas objects, and pass each page to a different canvas. When the user wants
another page, I simply replace the current canvas for the one with the required page. Not
surprisingly, this doesn't work. 

Here's the kind of thing my code does:

JSVGCanvas currentCanvas; //this is part of the UI
JSVGCanvas newCanvas; //this is is not in the UI

newCanvas.setDocument(mySVGPage); 
currentCanvas = newCanvas(); // this sets the new canvas to the current UI canvas

The question is, why isn't the currentCanvas updated with mySVGPage? Is that another way of
accomplishing something like this?

Thanks in advance for any ideas!

André


Mime
View raw message