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 "Durocher, Pascal (EXP)" <pa...@lmco.com> on 2003/03/20 23:53:54 UTC

gvtRoot and AffineTransform, how to get them?

I've been stuck on the following problem for a couple of days.

I am very new to the Batik API.

I would like to manually scale a picture.  I would like to use the
code found in JSVGCanvas.ZoomInAction to do the work.

Here is the code :

    protected class ZoomInAction extends AbstractAction {
        public void actionPerformed(ActionEvent evt) {
            if (gvtRoot == null) {
                return;
            }
            AffineTransform at = getRenderingTransform();
            if (at != null) {
                Dimension dim = getSize();
                int x = dim.width / 2;
                int y = dim.height / 2;
                AffineTransform t = AffineTransform.getTranslateInstance(x,
y);
                t.scale(2, 2);
                t.translate(-x, -y);
                t.concatenate(at);
                setRenderingTransform(t);
            }
        }
    }

What I did is I created a new class extending 'JSVGCanvas' and I
implemented a test method called 'test(').  In 'test()' I check if 
'gvtRoot' is non-null and then try to call 'getRenderingTransform()' 
to get an 'AffineTransform'.  Both the 'gvtRoot' and the returned 
'AffineTransform' are null.

Why?

Of course, that 'test()' method currently does _not_ do any kind of
scaling.  I just want to get a hold on an AffineTransform before doing
anything fancy. ;)

Where is the 'gvtRoot' attribute setted?

Thanks for your help !!

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