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 "HODAC, Olivier" <OL...@airbus.com> on 2009/09/02 16:04:16 UTC

transform attribute marshaller

Hello,

I am totally newby with batik and I am wondering if I am thinking right.
I have seen that there is some parsers that are used with handlers. Butr
here is my requirement:

I want to change dynamically in java the position and some attributes of
my initial svg file. I am focussing for the moment on the transform
attribute (to move and rescale my object) and the fill attr ( to change
the color)

I am doing the following. You can see that I have to create the whole
transform value string each time (I could have used the format method,
by the way) by hand
Is there a way to do that with some ready to use classes (ex:
TransformableElement.setTransform(X_POS, value)) ?

	protected void setSize(double d) {
		getElt().setAttributeNS(null, "transform", "matrix("+d+"
0 0 "+d+" 243.3438 143.687)");
	}

	
getSvgCanvas().getUpdateManager().getUpdateRunnableQueue().invokeLater(n
ew Runnable() {
			public void run() {
                setSize(theNewSize));
			}
		});
	}

Olivier Dao Ho Dac
Flight Test Software Architect
Airbus France - EVIDA

Phone : + 33 (0)5 67 19 81 34
Fax : +33(0)5 61 93 80 02
Mailto:olivier.hodac@airbus.com




The information in this e-mail is confidential. The contents may not be disclosed or used by anyone other than the addressee. Access to this e-mail by anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of this e-mail as it has been sent over public networks. If you have any concerns over the content of this message or its Accuracy or Integrity, please contact Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus scanning software but you should take whatever measures you deem to be appropriate to ensure that this message and any attachments are virus free.


RE: transform attribute marshaller

Posted by "Bishop, Michael W. CTR USJFCOM JFL" <mi...@jfcom.mil>.
Hello,

I use Batik's AWTTransformProducer to go from a "transform" attribute to
an AffineTransform.  I manipulate the AffineTransform however I need to,
then use the MessageFormat class to write out the "transform" attribute
with the 6 values of the matrix.  I haven't found a better way to
produce the "transform" attribute, but I find manipulating an
AffineTransform to be easier to work with.

I don't know how familiar you are with transforms, but you might want to
search this list for "AffineTransformUtil" if transform operations don't
work the way you "expect" them to with cumulative updates.

Michael Bishop

-----Original Message-----
From: HODAC, Olivier [mailto:OLIVIER.HODAC@airbus.com] 
Sent: Wednesday, September 02, 2009 10:04 AM
To: batik-users@xmlgraphics.apache.org
Subject: transform attribute marshaller

Hello,

I am totally newby with batik and I am wondering if I am thinking right.

I have seen that there is some parsers that are used with handlers. Butr
here is my requirement:

I want to change dynamically in java the position and some attributes of
my initial svg file. I am focussing for the moment on the transform
attribute (to move and rescale my object) and the fill attr ( to change
the color)

I am doing the following. You can see that I have to create the whole
transform value string each time (I could have used the format method,
by the way) by hand

Is there a way to do that with some ready to use classes (ex:
TransformableElement.setTransform(X_POS, value)) ?

        protected void setSize(double d) {

                getElt().setAttributeNS(null, "transform", "matrix("+d+"
0 0 "+d+" 243.3438 143.687)");

        }

 
getSvgCanvas().getUpdateManager().getUpdateRunnableQueue().invokeLater(n
ew Runnable() {

                        public void run() {

                setSize(theNewSize));

                        }

                });

        }

Olivier Dao Ho Dac

Flight Test Software Architect

Airbus France - EVIDA

Phone : + 33 (0)5 67 19 81 34

Fax : +33(0)5 61 93 80 02

Mailto:olivier.hodac@airbus.com

The information in this e-mail is confidential. The contents may not be
disclosed or used by anyone other than the addressee. Access to this
e-mail by anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately
and delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness
of this e-mail as it has been sent over public networks. If you have any
concerns over the content of this message or its Accuracy or Integrity,
please contact Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated
virus scanning software but you should take whatever measures you deem
to be appropriate to ensure that this message and any attachments are
virus free.

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


RE: transform attribute marshaller

Posted by "Bishop, Michael W. CTR USJFCOM JFL" <mi...@jfcom.mil>.
Yes, except for at.getScaleX(), I do:

double[] matrixValues = new double[6];
matrix.getMatrix(matrixValues);

Then I use matrixValues[0 - 5] to populate the "matrix" part of the "transform" attribute.

Although, reading the Javadoc, I guess it doesn't matter.  You could use:

getScaleX(), getShearY(), getShearX(), getScaleY(), getTranslateX(), and getTranslateY() in that order to get the same values.

Either way, it's a little tedious, but it works.

Michael

-----Original Message-----
From: HODAC, Olivier [mailto:OLIVIER.HODAC@airbus.com] 
Sent: Wednesday, September 02, 2009 10:56 AM
To: batik-users@xmlgraphics.apache.org
Subject: RE: transform attribute marshaller

Thanks michael

If I understand well, I create a new affineTransform from the attribute transform string using the static method AffineTransform  at = AWTTransformProducer.createAffineTransform(String s)

Then, I use the setters from the AffineTransform to set the rotation value, etc...

Finally, I use the standart java MessageFormat stuff to marshall it? You mean that I explicitely write:

MessageFormat.format("matrix(%f %f %f %f %f %f)", at.getScaleX() , etc...)?




-----Message d'origine-----
De : Bishop, Michael W. CTR USJFCOM JFL [mailto:michael.bishop.ctr@jfcom.mil]
Envoyé : mercredi 2 septembre 2009 16:35 À : batik-users@xmlgraphics.apache.org
Objet : RE: transform attribute marshaller

Hello,

I use Batik's AWTTransformProducer to go from a "transform" attribute to an AffineTransform.  I manipulate the AffineTransform however I need to, then use the MessageFormat class to write out the "transform" attribute with the 6 values of the matrix.  I haven't found a better way to produce the "transform" attribute, but I find manipulating an AffineTransform to be easier to work with.

I don't know how familiar you are with transforms, but you might want to search this list for "AffineTransformUtil" if transform operations don't work the way you "expect" them to with cumulative updates.

Michael Bishop

-----Original Message-----
From: HODAC, Olivier [mailto:OLIVIER.HODAC@airbus.com]
Sent: Wednesday, September 02, 2009 10:04 AM
To: batik-users@xmlgraphics.apache.org
Subject: transform attribute marshaller

Hello,

I am totally newby with batik and I am wondering if I am thinking right.

I have seen that there is some parsers that are used with handlers. Butr here is my requirement:

I want to change dynamically in java the position and some attributes of my initial svg file. I am focussing for the moment on the transform attribute (to move and rescale my object) and the fill attr ( to change the color)

I am doing the following. You can see that I have to create the whole transform value string each time (I could have used the format method, by the way) by hand

Is there a way to do that with some ready to use classes (ex:
TransformableElement.setTransform(X_POS, value)) ?

        protected void setSize(double d) {

                getElt().setAttributeNS(null, "transform", "matrix("+d+"
0 0 "+d+" 243.3438 143.687)");

        }

 
getSvgCanvas().getUpdateManager().getUpdateRunnableQueue().invokeLater(n
ew Runnable() {

                        public void run() {

                setSize(theNewSize));

                        }

                });

        }

Olivier Dao Ho Dac

Flight Test Software Architect

Airbus France - EVIDA

Phone : + 33 (0)5 67 19 81 34

Fax : +33(0)5 61 93 80 02

Mailto:olivier.hodac@airbus.com

The information in this e-mail is confidential. The contents may not be disclosed or used by anyone other than the addressee. Access to this e-mail by anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of this e-mail as it has been sent over public networks. If you have any concerns over the content of this message or its Accuracy or Integrity, please contact Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus scanning software but you should take whatever measures you deem to be appropriate to ensure that this message and any attachments are virus free.

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


This mail has originated outside your organization, either from an external partner or the Global Internet.
Keep this in mind if you answer this message.




The information in this e-mail is confidential. The contents may not be disclosed or used by anyone other than the addressee. Access to this e-mail by anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of this e-mail as it has been sent over public networks. If you have any concerns over the content of this message or its Accuracy or Integrity, please contact Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus scanning software but you should take whatever measures you deem to be appropriate to ensure that this message and any attachments are virus free.


---------------------------------------------------------------------
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: transform attribute marshaller

Posted by "HODAC, Olivier" <OL...@airbus.com>.
OK, thank's (so fast!!!)

-----Message d'origine-----
De : Bishop, Michael W. CTR USJFCOM JFL [mailto:michael.bishop.ctr@jfcom.mil] 
Envoyé : mercredi 2 septembre 2009 17:11
À : batik-users@xmlgraphics.apache.org
Objet : RE: transform attribute marshaller

Yes, except for at.getScaleX(), I do:

double[] matrixValues = new double[6];
matrix.getMatrix(matrixValues);

Then I use matrixValues[0 - 5] to populate the "matrix" part of the "transform" attribute.

Although, reading the Javadoc, I guess it doesn't matter.  You could use:

getScaleX(), getShearY(), getShearX(), getScaleY(), getTranslateX(), and getTranslateY() in that order to get the same values.

Either way, it's a little tedious, but it works.

Michael

-----Original Message-----
From: HODAC, Olivier [mailto:OLIVIER.HODAC@airbus.com] 
Sent: Wednesday, September 02, 2009 10:56 AM
To: batik-users@xmlgraphics.apache.org
Subject: RE: transform attribute marshaller

Thanks michael

If I understand well, I create a new affineTransform from the attribute transform string using the static method AffineTransform  at = AWTTransformProducer.createAffineTransform(String s)

Then, I use the setters from the AffineTransform to set the rotation value, etc...

Finally, I use the standart java MessageFormat stuff to marshall it? You mean that I explicitely write:

MessageFormat.format("matrix(%f %f %f %f %f %f)", at.getScaleX() , etc...)?




-----Message d'origine-----
De : Bishop, Michael W. CTR USJFCOM JFL [mailto:michael.bishop.ctr@jfcom.mil]
Envoyé : mercredi 2 septembre 2009 16:35 À : batik-users@xmlgraphics.apache.org
Objet : RE: transform attribute marshaller

Hello,

I use Batik's AWTTransformProducer to go from a "transform" attribute to an AffineTransform.  I manipulate the AffineTransform however I need to, then use the MessageFormat class to write out the "transform" attribute with the 6 values of the matrix.  I haven't found a better way to produce the "transform" attribute, but I find manipulating an AffineTransform to be easier to work with.

I don't know how familiar you are with transforms, but you might want to search this list for "AffineTransformUtil" if transform operations don't work the way you "expect" them to with cumulative updates.

Michael Bishop

-----Original Message-----
From: HODAC, Olivier [mailto:OLIVIER.HODAC@airbus.com]
Sent: Wednesday, September 02, 2009 10:04 AM
To: batik-users@xmlgraphics.apache.org
Subject: transform attribute marshaller

Hello,

I am totally newby with batik and I am wondering if I am thinking right.

I have seen that there is some parsers that are used with handlers. Butr here is my requirement:

I want to change dynamically in java the position and some attributes of my initial svg file. I am focussing for the moment on the transform attribute (to move and rescale my object) and the fill attr ( to change the color)

I am doing the following. You can see that I have to create the whole transform value string each time (I could have used the format method, by the way) by hand

Is there a way to do that with some ready to use classes (ex:
TransformableElement.setTransform(X_POS, value)) ?

        protected void setSize(double d) {

                getElt().setAttributeNS(null, "transform", "matrix("+d+"
0 0 "+d+" 243.3438 143.687)");

        }

 
getSvgCanvas().getUpdateManager().getUpdateRunnableQueue().invokeLater(n
ew Runnable() {

                        public void run() {

                setSize(theNewSize));

                        }

                });

        }

Olivier Dao Ho Dac

Flight Test Software Architect

Airbus France - EVIDA

Phone : + 33 (0)5 67 19 81 34

Fax : +33(0)5 61 93 80 02

Mailto:olivier.hodac@airbus.com

The information in this e-mail is confidential. The contents may not be disclosed or used by anyone other than the addressee. Access to this e-mail by anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of this e-mail as it has been sent over public networks. If you have any concerns over the content of this message or its Accuracy or Integrity, please contact Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus scanning software but you should take whatever measures you deem to be appropriate to ensure that this message and any attachments are virus free.

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


This mail has originated outside your organization, either from an external partner or the Global Internet.
Keep this in mind if you answer this message.




The information in this e-mail is confidential. The contents may not be disclosed or used by anyone other than the addressee. Access to this e-mail by anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of this e-mail as it has been sent over public networks. If you have any concerns over the content of this message or its Accuracy or Integrity, please contact Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus scanning software but you should take whatever measures you deem to be appropriate to ensure that this message and any attachments are virus free.


---------------------------------------------------------------------
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


This mail has originated outside your organization, either from an external partner or the Global Internet.
Keep this in mind if you answer this message.




The information in this e-mail is confidential. The contents may not be disclosed or used by anyone other than the addressee. Access to this e-mail by anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of this e-mail as it has been sent over public networks. If you have any concerns over the content of this message or its Accuracy or Integrity, please contact Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus scanning software but you should take whatever measures you deem to be appropriate to ensure that this message and any attachments are virus free.


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


RE: transform attribute marshaller

Posted by "HODAC, Olivier" <OL...@airbus.com>.
Thanks michael

If I understand well, I create a new affineTransform from the attribute transform string using the static method
AffineTransform  at = AWTTransformProducer.createAffineTransform(String s)

Then, I use the setters from the AffineTransform to set the rotation value, etc...

Finally, I use the standart java MessageFormat stuff to marshall it? You mean that I explicitely write:

MessageFormat.format("matrix(%f %f %f %f %f %f)", at.getScaleX() , etc...)?




-----Message d'origine-----
De : Bishop, Michael W. CTR USJFCOM JFL [mailto:michael.bishop.ctr@jfcom.mil] 
Envoyé : mercredi 2 septembre 2009 16:35
À : batik-users@xmlgraphics.apache.org
Objet : RE: transform attribute marshaller

Hello,

I use Batik's AWTTransformProducer to go from a "transform" attribute to
an AffineTransform.  I manipulate the AffineTransform however I need to,
then use the MessageFormat class to write out the "transform" attribute
with the 6 values of the matrix.  I haven't found a better way to
produce the "transform" attribute, but I find manipulating an
AffineTransform to be easier to work with.

I don't know how familiar you are with transforms, but you might want to
search this list for "AffineTransformUtil" if transform operations don't
work the way you "expect" them to with cumulative updates.

Michael Bishop

-----Original Message-----
From: HODAC, Olivier [mailto:OLIVIER.HODAC@airbus.com] 
Sent: Wednesday, September 02, 2009 10:04 AM
To: batik-users@xmlgraphics.apache.org
Subject: transform attribute marshaller

Hello,

I am totally newby with batik and I am wondering if I am thinking right.

I have seen that there is some parsers that are used with handlers. Butr
here is my requirement:

I want to change dynamically in java the position and some attributes of
my initial svg file. I am focussing for the moment on the transform
attribute (to move and rescale my object) and the fill attr ( to change
the color)

I am doing the following. You can see that I have to create the whole
transform value string each time (I could have used the format method,
by the way) by hand

Is there a way to do that with some ready to use classes (ex:
TransformableElement.setTransform(X_POS, value)) ?

        protected void setSize(double d) {

                getElt().setAttributeNS(null, "transform", "matrix("+d+"
0 0 "+d+" 243.3438 143.687)");

        }

 
getSvgCanvas().getUpdateManager().getUpdateRunnableQueue().invokeLater(n
ew Runnable() {

                        public void run() {

                setSize(theNewSize));

                        }

                });

        }

Olivier Dao Ho Dac

Flight Test Software Architect

Airbus France - EVIDA

Phone : + 33 (0)5 67 19 81 34

Fax : +33(0)5 61 93 80 02

Mailto:olivier.hodac@airbus.com

The information in this e-mail is confidential. The contents may not be
disclosed or used by anyone other than the addressee. Access to this
e-mail by anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately
and delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness
of this e-mail as it has been sent over public networks. If you have any
concerns over the content of this message or its Accuracy or Integrity,
please contact Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated
virus scanning software but you should take whatever measures you deem
to be appropriate to ensure that this message and any attachments are
virus free.

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


This mail has originated outside your organization, either from an external partner or the Global Internet.
Keep this in mind if you answer this message.




The information in this e-mail is confidential. The contents may not be disclosed or used by anyone other than the addressee. Access to this e-mail by anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of this e-mail as it has been sent over public networks. If you have any concerns over the content of this message or its Accuracy or Integrity, please contact Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus scanning software but you should take whatever measures you deem to be appropriate to ensure that this message and any attachments are virus free.


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


Re: transform attribute marshaller

Posted by th...@kodak.com.
Hi Olivier

"HODAC, Olivier" <OL...@airbus.com> wrote on 09/02/2009 10:04:16 
AM:

> I want to change dynamically in java the position and some 
> attributes of my initial svg file. I am focussing for the moment on 
> the transform attribute (to move and rescale my object) and the fill
> attr ( to change the color) I am doing the following. You can see that 
> I have to create the whole transform value string each time (I could 
> have used the format method, by the way) by hand
> Is there a way to do that with some ready to use classes (ex: 
> TransformableElement.setTransform(X_POS, value)) ?

   If you check out the SVG DOM there are interfaces to get the 
transform list associated with an element.  Note that, at least
in Batik, everything is still based on the DOM String so we will
effectively do what you are doing.

   Something like:
        ((SVGTransformable)
getElt()).getTransform().getBaseVal().getItem(0).setTranslate(x, y);

   The getItem is needed because it tracks 'complex' transform attributes.
This can be useful as it would allow you to keep your scale transform 
independent
of the translate (otherwise you may need to multiply your transform values 
by the
scale values).