Hi Mike:

That happened to me also, and it turned out that my original SVG file was the source of the error. You have to specify the viewport with the exact same dimensions as the width height attributes in your SVG declaration:

<svg width="1000" height ="500" viewport="0 0 1000 500" ..... >
...
</svg>

Or another solution you could use, in case you have no control over the original SVG (i.e. a user is providing it to your app), you can try adding a Load listener and set the canvas dimensions from the SVG file:

....
// Set the JSVGCanvas listeners.
svgCanvas.addSVGDocumentLoaderListener(new SVGDocumentLoaderAdapter() {
public void documentLoadingStarted(SVGDocumentLoaderEvent e) {
}


public void documentLoadingCompleted(SVGDocumentLoaderEvent e) {

SVGDocument document = e.getSVGDocument();
SVGOMSVGElement documentElement = (SVGOMSVGElement)document.getDocumentElement();


              //Get the dimensions from the SVG document
                String theW = documentElement.getAttribute("width");
                String theH = documentElement.getAttribute("height");

                Integer WW = new Integer(theW);
                Integer HH = new Integer(theH);

//this is actually where we indicate the JSVGCanvas to modify its viewport size
svgCanvas.setMySize(new Dimension(WW.intValue(), HH.intValue()));
}
});


protected JSVGCanvas svgCanvas;


This might work for you. It does for me. Best regards,

Andres.

On Tuesday, April 6, 2004, at 10:15 AM, Mike Favata wrote:

Hello all,

I am having a small problem when my JSVGCanvas first loads a document. When the document is first loaded it is scaled down and only takes up a small portion of the canvas. When I move the mouse over the canvas the document scales to best fit the size of the canvas. What am I doing wrong? I would like the document to best fit the canvas on first load without having to wait for the user to move the mouse over the canvas. Has anyone ran into this problem before? Any help would be appreciated. Thanks!

-Mike Favata

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to