PDF to JavaFx conversion – Applying Transform matrix to Text

We all know the power of the Matrix, (not the movie) the Transformation Matrix. This combines a few factors including scaling, sheer, translation and rotation. These can be applied individually but when all combine the outcome is usually more fine tuned and neater than individual application.

After successfully applying the transform matrix to our HTML5 divs on rotated text we thought how can we extend this to the JavaFx. I tried using similar commands as is in the HTML5 syntax but applying it how i assumed it could be applied in Java  i.e objectName.transform( matrix(0.56,1.0,-1.0,0.56,711, 15)); How wrong I was!

I also looked up the API for the Type Text and found that it was possible to set practically everything else but the matrix. For example you had methods like setScale, setRotate, setTranslate, etc but no setMatrix or something of the sort.

However I did notice that there was a getTransforms even if there isnt a setTransforms which i thought was a little bit strange. Anyway, after exploring the getTransforms method  I noticed that you could not only use it to get already set Transforms done through the methods above you can also use it to add Transformations of your own.

Using this method gave all the available transforms that could be applied, including the shear and the use of the matrix which is disguised as Affine. This takes 6 values or 12 depending on how fine tuned you want your transformation to be. The best part about the Affine transform is that it allowed you to apply all the known transforms in one method. Hence making it a powerful method. Have you tried it?

 

Related Posts:

The following two tabs change content below.
Chika has written much of the JavaFX converter and also helps with the HTML5 converter. When not experimenting with the new features of JavaFX, he is a keen basketball player (he is the tall guy you might see at Devoxx).
Chika Okereke

About Chika Okereke

Chika has written much of the JavaFX converter and also helps with the HTML5 converter. When not experimenting with the new features of JavaFX, he is a keen basketball player (he is the tall guy you might see at Devoxx).

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>