Hi Cui,

Cui Jian <[email protected]> wrote on 02/03/2009 12:20:23 PM:

> Sorry, to make it more understandable, I changed some codes and here 
> again is the test program...

   I suggest you rewrite the constructor as follows.  The basic issue
is that you were setting the rendering transform before the asynchronous
loading of the document happened so the document load reset the inital
rendering transform.  The other option would have been to set an 'onload'
event handler and set the rendering transform in that callback (but this
is slightly simpler).  Also note that I reorganized the setMySize calls
for similar reasons.


    public Resizer(){
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        final Resizer resizerInstance = this;
        this.canvas = new JSVGCanvas() { 
                public void setGraphicsNode(GraphicsNode gn, 
                                               boolean createDispatcher) {
                    super.setGraphicsNode(gn, createDispatcher);
                    AffineTransform at = canvas.getRenderingTransform();
                    at.scale(5, 5);
                    canvas.setRenderingTransform(at);
                }
                public void setMySize(Dimension d) {
                    setPreferredSize(new Dimension(canvasFixedWidth, 
                                                   canvasFixedHeight));
                    resizerInstance.pack();
                }
            };
        this.canvas.setDocumentState (JSVGCanvas.ALWAYS_DYNAMIC);
        DOMImplementation dom = 
            SVGDOMImplementation.getDOMImplementation ();
        svgDoc =
            dom.createDocument(SVGConstants.SVG_NAMESPACE_URI, 
                               SVGConstants.SVG_SVG_TAG, null);
        this.getContentPane().add(this.canvas, "Center");
        /**
         * here I tried to scale it by setting a new renderingtransform...
         */
        this.setVisible(true);
        this.initBall();
        this.canvas.setDocument(svgDoc);
    }

 I hope that helps...

Reply via email to