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 Lars Eirik Rønning <la...@gmail.com> on 2008/06/03 12:37:11 UTC

Transform attribute

Hi.
Is there an easy way for me to retrieve the affine transformation such as an
element's matrix from an exisiting svg file and alter only the translation
aspect of the matrix?
I was hoping i could get this as a string attribute and then have a object
which allowed me to extract the values i wanted without having to parse the
string..
When the values are altered i would like to insert this back as a string
into the svg file.

Thanks
Lars

RE: Transform attribute

Posted by "Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil>.
I think you want the org.apache.batik.parser.AWTTransformProducer.createAffineTransform(...) method.  Getting it back to the transform="matrix(...)" is messier.  I used AffineTransform.getMatrix() and MessageFormat to put it back into the element.

Michael Bishop



From: Lars Eirik Rønning
Sent: Tue 6/3/2008 7:21 AM
To: batik-users@xmlgraphics.apache.org
Subject: Re: Transform attribute


thanks.
I was more interesting in finding a way to retrive the transform attribute and modify this without having to parse the string myself..
transform="matrix(1 0 0 1 349 384)".. i do not really consider it the best idea to do this parsing myself if there exisits a method which allows me to do for instance do somthing similar to

pseudocode:
Transformation t = Transformation.getMatrixObject(String matrixString);
double x = t.getTranslateX();
t.setTraslateX(x+40);
element.setAttribute(SVGConstants.SVG_Transform_Attribute,t.getString());




On Tue, Jun 3, 2008 at 12:49 PM, Guillaume Rosauro <g....@gmail.com> wrote:


Hi,

You can retrieve all elements from the SVG file like any other XML file. So getElementById or something like that should be sufficient.


Guillaume 

 



On Tue, Jun 3, 2008 at 12:37 PM, Lars Eirik Rønning <la...@gmail.com> wrote:

Hi.
Is there an easy way for me to retrieve the affine transformation such as an element's matrix from an exisiting svg file and alter only the translation aspect of the matrix?
I was hoping i could get this as a string attribute and then have a object which allowed me to extract the values i wanted without having to parse the string..
When the values are altered i would like to insert this back as a string into the svg file.

Thanks
Lars

Re: Transform attribute

Posted by Lars Eirik Rønning <la...@gmail.com>.
thanks.
I was more interesting in finding a way to retrive the transform attribute
and modify this without having to parse the string myself..
transform="matrix(1 0 0 1 349 384)".. i do not really consider it the best
idea to do this parsing myself if there exisits a method which allows me to
do for instance do somthing similar to

pseudocode:
Transformation t = Transformation.getMatrixObject(String matrixString);
double x = t.getTranslateX();
t.setTraslateX(x+40);
element.setAttribute(SVGConstants.SVG_Transform_Attribute,t.getString());



On Tue, Jun 3, 2008 at 12:49 PM, Guillaume Rosauro <g....@gmail.com>
wrote:

>
> Hi,
>
> You can retrieve all elements from the SVG file like any other XML file. So
> getElementById or something like that should be sufficient.
>
>
> Guillaume
>
>
>
>
> On Tue, Jun 3, 2008 at 12:37 PM, Lars Eirik Rønning <la...@gmail.com>
> wrote:
>
>> Hi.
>> Is there an easy way for me to retrieve the affine transformation such as
>> an element's matrix from an exisiting svg file and alter only the
>> translation aspect of the matrix?
>> I was hoping i could get this as a string attribute and then have a object
>> which allowed me to extract the values i wanted without having to parse the
>> string..
>> When the values are altered i would like to insert this back as a string
>> into the svg file.
>>
>> Thanks
>> Lars
>>
>
>

Re: Transform attribute

Posted by Guillaume Rosauro <g....@gmail.com>.
Hi,

You can retrieve all elements from the SVG file like any other XML file. So
getElementById or something like that should be sufficient.


Guillaume



On Tue, Jun 3, 2008 at 12:37 PM, Lars Eirik Rønning <la...@gmail.com>
wrote:

> Hi.
> Is there an easy way for me to retrieve the affine transformation such as
> an element's matrix from an exisiting svg file and alter only the
> translation aspect of the matrix?
> I was hoping i could get this as a string attribute and then have a object
> which allowed me to extract the values i wanted without having to parse the
> string..
> When the values are altered i would like to insert this back as a string
> into the svg file.
>
> Thanks
> Lars
>