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 "Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> on 2005/11/22 20:15:48 UTC

RE: Conversion for AffineTransform?

OK, time to resurrect an old topic.  Right now I'm only using the
translate portion of a transform.  I really don't care how the rest is
handled.  It really depends on the SVG document.  Here's the scenario.

- Load any SVG document.
- Drag an element around the JSVGCanvas by updating its transform
however it's represented.  I guess it doesn't matter really if the
representation of the transform changes as long as it acts the same for
the rest of the attribute.  If I change the "translate" portion, I want
to keep shear, scale, skew, rotate, etc. intact.

Michael Bishop

-----Original Message-----
From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com] 
Sent: Wednesday, October 26, 2005 9:23 PM
To: batik-users@xmlgraphics.apache.org
Cc: batik-users@xmlgraphics.apache.org
Subject: Re: Conversion for AffineTransform?

Hi Michael,

"Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> wrote on

10/26/2005 02:47:33 PM:

> I?m looking for something similar to SVGColor.toSVG() or 
SVGShape.toSVG().  I 
> see there?s an SVGOMMatrix that takes an AffineTransform as a 
constructor 
> argument, but I don?t see a way to create the ?transform=???? from it.

    It's trivial to construct if you are willing to use the 'matrix()'
form.  You can also have a 'translate(tx, ty) matrix(sx, shy, shx, sy,
0, 
0)'
so the transform is pulled out (sx = scaleX, shx = shearX, etc).
If you don't want to use matrix then it depends on you knowing the
form of your affine.
 
> Does one exist?  Similarly, is there one to go from a ?transform=???? 
back to some 
> object?  I?m doing it with string parsing and it?s kinda ugly.

    You can use the parser classes from Batik:
        batik.parser.TransformListParser
      batik.parser.AWTTransformProducer


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

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


RE: Conversion for AffineTransform?

Posted by th...@kodak.com.
Hi Michael,

"Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> wrote on 
11/22/2005 02:15:48 PM:

> - Load any SVG document.
> - Drag an element around the JSVGCanvas by updating its transform
> however it's represented.  I guess it doesn't matter really if the
> representation of the transform changes as long as it acts the same for
> the rest of the attribute.  If I change the "translate" portion, I want
> to keep shear, scale, skew, rotate, etc. intact.

   So the simplest thing to do is to 'prepend' a translate to the 
transform.  The only problem with this is that in general every
time an element is dragged it will 'accumulate' additional translate
entries in it's transform.  There are a number of potential solutions
like looking to see if the first entry in the transform is a translate
and if so update that part rather than prepending a new one.  I
think the parser classes I point you to earlier can be used to
do this with some additional logic in the handler class.

   The other approach to use is that for all transforms if you
reduce them to a matrix (you can get this from the SVG DOM) the
transform is essentially just 'tacked on' at the end of everything
else.  So with a bit of care it would be possible to just update
the transform portion of the matrix representation of the matrix.
The tricky part is that many of the SVG DOM interfaces will be 
problematic in this case since you need to map points using the 
'original' value for the matrix rather than the matrix that is
actually on the element.  You might be able to get the 
screen CTM for the element once at the start and use it until the
drag completes.
 

> 
> Michael Bishop
> 
> -----Original Message-----
> From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com] 
> Sent: Wednesday, October 26, 2005 9:23 PM
> To: batik-users@xmlgraphics.apache.org
> Cc: batik-users@xmlgraphics.apache.org
> Subject: Re: Conversion for AffineTransform?
> 
> Hi Michael,
> 
> "Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> wrote on
> 
> 10/26/2005 02:47:33 PM:
> 
> > I?m looking for something similar to SVGColor.toSVG() or 
> SVGShape.toSVG().  I 
> > see there?s an SVGOMMatrix that takes an AffineTransform as a 
> constructor 
> > argument, but I don?t see a way to create the ?transform=???? from it.
> 
>     It's trivial to construct if you are willing to use the 'matrix()'
> form.  You can also have a 'translate(tx, ty) matrix(sx, shy, shx, sy,
> 0, 
> 0)'
> so the transform is pulled out (sx = scaleX, shx = shearX, etc).
> If you don't want to use matrix then it depends on you knowing the
> form of your affine.
> 
> > Does one exist?  Similarly, is there one to go from a ?transform=???? 
> back to some 
> > object?  I?m doing it with string parsing and it?s kinda ugly.
> 
>     You can use the parser classes from Batik:
>         batik.parser.TransformListParser
>       batik.parser.AWTTransformProducer
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


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