Reputation: 965
I have an old library (technical debt) that needs to stay in place for now, and it uses the AWT AffineTransform. Our new graphics code uses the JavaFX Affine. Is there a clear 1:1 mapping between the two?
If there is an existing FLOSS library providing this mapping as a utility, I would appreciate that reference. If not, please describe how to convert an instance of java.awt.geom.AffineTransform to an instance of javafx.scene.transform.Affine.
In lieu of a clear conversion path, I will accept a description of the compatibilities between the two classes and the challenges of working with both.
Upvotes: 0
Views: 370
Reputation: 61
The main differences of Affine and AffineTransform are:
Affine can handle 2D AND 3D transforms while AffineTransform is limited to 2D.
Affine is derived from the class Transform, which is also the base class of Rotate, Translate, Shear and Scale. These classes should be used instead of Affine, if the transformation uses just one of the techniques.
If you want to parse AffineTransform to Affine:
Given constructors:
AffineTransform(double m00, double m10, double m01, double m11, double m02, double m12)
Affine(double mxx, double mxy, double tx, double myx, double myy, double ty)
Where:
mxx = m00
mxy = m01
tx = m02
myx = m10
myy = m11
ty = m12
Parsing AffineTransform at
to Affine a
:
double[] m = new double[6];
at.getMatrix(m);
Affine a = new Affine(m[0],m[2],m[4],m[1],m[3],m[5]);
Upvotes: 1