Thanks for your help. In fact I finally chose to convert the SVG DOM Elements into awt Shapes. So now I can use the SVGMatrix returned by getTransformToElement() method to create an AffineTransform instance. Then I use AffineTransform.createTransformedShape() method.
Here is the code: SVGSVGElement svg= document.getRootElement(); SVGMatrix matrix = (SVGMatrix) element.getTransformToElement(svg); AffineTransform shapeTransform = new AffineTransform(matrix.getA(), matrix.getB(), matrix.getC(), matrix.getD(), matrix.getE(), matrix.getF()); GraphicsNode shapeNode = (GraphicsNode) bridgeContext.getGraphicsNode(element); Shape shape = ((ShapeNode) shapeNode).getShape(); Shape transformedShape = shapeTransform.createTransformedShape(shape); Regards. 2009/6/19 <[email protected]> > > Paul Wellner Bou <[email protected]> wrote on 06/19/2009 02:22:02 AM: > > > [...] with other (SVG)Elements, I am doing this in plain xml attributes: > > > > String transformMatrix= "matrix(" + mat.getA() + " " + mat.getB() + > > " " + mat.getC() + " " + mat.getD() + " " + mat.getE() + " " > > + mat.getF() + ")"; > > myElement.setAttribute("transform", transformMatrix); > > > Johan Brelet <[email protected]> wrote on 06/05/2009 06:02:15 AM: > > >> I'm trying to work with matrix. What I'd like is to get the > >> transformation matrix of a shape compared to root of SVG, and remove > >> only "translate" transformations. Here is how I'm currently doing it : > >> > >> SVGMatrix matrix = myshape.getTransformToElement(svg); > > Paul is pointing in the right direction. The matrix returned > from getTransformToElement is not a changeable matrix. So modifying it > does not change the document in any way. > > > //Only take into account "translate" transformations, e.g. matrix.e > > (tx) and matrix.f (ty) > > matrix.setA(1); > > matrix.setB(0); > > matrix.setC(0); > > matrix.setD(1); > > > > But the matrix doesn't seems to be updated (a b c and d are kept > unchanged)... > > Am I doing something wrong? > > You need to copy the matrix into one you create from the SVG root > element. Then you need > to set the matrix on something (similar to what Paul suggests). >
