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 th...@sympatico.ca on 2009/06/02 06:16:57 UTC
Differences between JSVGCanvas.setDocument() and
JSVGCanvas.loadSVGDocument()
I build a DOM on the fly and do this:
//myDoc that has been built on the fly.
myJSVGCanvas.setDocument(myDoc);
//Add the myJSVGCanvas into a JSVGScrollPane, add the JSVGScrollPane into a JPanel, and display it in a JFrame.
No matter how I resize the frame, the scroll bars will never show up.
But if I save the myDoc into a file after I build the doc and load the file back to the myJSVGCanvas, scrolling works like a charm. Something like this:
//The same myDoc is saved to a file at theFilePath.
myJSVGCanvas.loadSVGDocument(theFilePath)
//The rest is same as the above.
How can I make the former work?
RE: Differences between JSVGCanvas.setDocument() and
JSVGCanvas.loadSVGDocument()
Posted by th...@sympatico.ca.
>Don't set the document until after the canvas has been
>added to the swing tree and packed.
An excellent advice. That fixed the problem. Thanks.
Re: Differences between JSVGCanvas.setDocument() and
JSVGCanvas.loadSVGDocument()
Posted by Abraham Rodriguez Mota <ab...@gmail.com>.
Hi,
I agree with Thomas.
But If you don't have problems creating a composite with a fix size and then
resize it as soon as the svg document has been loaded on the JSVGCanvas, you
can add a GVTTreeBuilderListener to your instance of the JSVGCanvas, and
resize the container as part of the gvtBuildCompleted method of the
listener.
Hope this helps
Abraham
On Tue, Jun 2, 2009 at 5:16 AM, <th...@sympatico.ca> wrote:
> I build a DOM on the fly and do this:
>
> //myDoc that has been built on the fly.
>
> myJSVGCanvas.setDocument(myDoc);
>
> //Add the myJSVGCanvas into a JSVGScrollPane, add the JSVGScrollPane into a
> JPanel, and display it in a JFrame.
>
> No matter how I resize the frame, the scroll bars will never show up.
>
> But if I save the myDoc into a file after I build the doc and load the file
> back to the myJSVGCanvas, scrolling works like a charm. Something like this:
>
> //The same myDoc is saved to a file at theFilePath.
>
> myJSVGCanvas.loadSVGDocument(theFilePath)
>
> //The rest is same as the above.
>
>
> How can I make the former work?
>
>
>
Re: Differences between JSVGCanvas.setDocument() and JSVGCanvas.loadSVGDocument()
Posted by th...@kodak.com.
Hi The.Networker,
<th...@sympatico.ca> wrote on 06/02/2009 12:16:57 AM:
> I build a DOM on the fly and do this:
>
> //myDoc that has been built on the fly.
>
> myJSVGCanvas.setDocument(myDoc);
>
> //Add the myJSVGCanvas into a JSVGScrollPane, add the JSVGScrollPane
> into a JPanel, and display it in a JFrame.
> No matter how I resize the frame, the scroll bars will never show up.
Don't set the document until after the canvas has been
added to the swing tree and packed. Without a sample app I
can't say for certain but in general setting the document
before the canvas is in the swing hierarchy is bad.
> But if I save the myDoc into a file after I build the doc and load
> the file back to the myJSVGCanvas, scrolling works like a charm.
You could also have some brokeness in namespaces, etc.
Which tend to be fixed by writing to disk and reading back.
>