Re: Read/Write transform values

jonathan wood <[email protected]>
Newsgroups gmane.text.xml.batik.user
Message-ID <CAKiJDQRkAaoA_fnAD3YLCHyb+xb9rVPvkvrQ-AtppiusaCryDg@mail.gmail.com>
Batik contains a lot of useful parsers for just such purposes...

http://xmlgraphics.apache.org/batik/using/parsers.html

with the TransformListParser you can produce an AffineTransform

       AffineTransform at = null;
        TransformListParser tlp = new TransformListParser();
        AWTTransformProducer atp = new AWTTransformProducer();
        tlp.setTransformListHandler(atp);
        tlp.parse(el.getAttributeNS(null,
SVGConstants.SVG_TRANSFORM_ATTRIBUTE));
        at = atp.getAffineTransform();




On Fri, Aug 10, 2012 at 3:43 PM, fireball <[email protected]> wrote:

> Maybe this has been discussed before but I could not find one article that
> explains it.
>
> I am trying to figure out the proper way to read/write element's transform
> values. I.e. X, Y, Scale,
> Rotate, etc..
>
> Below is a few things I have tried. Sometimes they work and sometimes they
> don't. And I am not sure which way is correct.
>
> Please point me in the right direction.
>
> Thanks,
>
> fireball.
>
>
>
> Read
> ------
> - X value:
>
>
> ((SVGOMGElement)elt).getTransform().getBaseVal().getItem(0).getMatrix().getE();
> or
> ((SVGLocatable)elt).getScreenCTM().getE();
>
>
> Write
> ------
> - X value:
>
> elt.setAttributeNS(null, "transform", "matrix(" + a + ",0,0," + d + "," + e
> + ",
> " + f + ")");
> or
> ((SVGLocatable)elt).getScreenCTM().setE(e);
>
>
>
> - Rotation angle:
>
>
> ((SVGOMGElement)elt).getTransform().getBaseVal().getItem(0).setRotate(Float.valueOf(rotate),
> Float.valueOf(0), Float.valueOf(0));
> or
> ((SVGLocatable)elt).getScreenCTM().rotate(Float.valueOf(45));
>
> In the above we are setting the rotate value but how do we get(read) it?
>
>
>
> --
> View this message in context:
> http://batik.2283329.n4.nabble.com/Read-Write-transform-values-tp4655190.html
> Sent from the Batik - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.