public class AffineTransform
- Object
- AffineTransform
A utility class for expressing 2-D affine transforms in Codename One.
Constructors
public AffineTransform() | Creates identity transform. |
public AffineTransform(AffineTransform atx) | Creates new affine transform as a copy of the given transform. |
public AffineTransform(float m00, float m10, float m01, float m11, float m02, float m12) | Creates a new AffineTransform. |
public AffineTransform(float[] m) | Creates a new AffineTransform. |
public AffineTransform(double m00, double m10, double m01, double m11, double m02, double m12) | Creates a new AffineTransform. |
public AffineTransform(double[] m) | Creates a new AffineTransform. |
Methods
Inherited methods
Constructor details
AffineTransform
public AffineTransform()Creates identity transform.
AffineTransform
public AffineTransform(AffineTransform atx)Creates new affine transform as a copy of the given transform.
Parameters
atxAffineTransform- Transform to copy.
AffineTransform
public AffineTransform(float m00, float m10, float m01, float m11, float m02, float m12)Creates a new AffineTransform.
Parameters
m00float- the X coordinate scaling element of the 3x3 matrix
m10float- the Y coordinate shearing element of the 3x3 matrix
m01float- the X coordinate shearing element of the 3x3 matrix
m11float- the Y coordinate scaling element of the 3x3 matrix
m02float- the X coordinate translation element of the 3x3 matrix
m12float- the Y coordinate translation element of the 3x3 matrix
AffineTransform
public AffineTransform(float[] m)Creates a new AffineTransform.
Parameters
mfloat[]- the float array containing the values to be set
in the new
AffineTransformobject. The length of the array is assumed to be at least 4. If the length of the array is less than 6, only the first 4 values are taken. If the length of the array is greater than 6, the first 6 values are taken.
AffineTransform
public AffineTransform(double m00, double m10, double m01, double m11, double m02, double m12)Creates a new AffineTransform.
Parameters
m00double- the X coordinate scaling element of the 3x3 matrix
m10double- the Y coordinate shearing element of the 3x3 matrix
m01double- the X coordinate shearing element of the 3x3 matrix
m11double- the Y coordinate scaling element of the 3x3 matrix
m02double- the X coordinate translation element of the 3x3 matrix
m12double- the Y coordinate translation element of the 3x3 matrix
AffineTransform
public AffineTransform(double[] m)Creates a new AffineTransform.
Parameters
mdouble[]- the double array containing the values to be set
in the new
AffineTransformobject. The length of the array is assumed to be at least 4. If the length of the array is less than 6, only the first 4 values are taken. If the length of the array is greater than 6, the first 6 values are taken.
Method details
getRotateInstance
public static AffineTransform getRotateInstance(double theta)Gets a rotation transform
Parameters
thetadouble- Radian rotation angle.
getRotateInstance
public static AffineTransform getRotateInstance(double theta, double anchorx, double anchory)Gets a rotation transform.
Parameters
thetadouble- Radian rotation angle.
anchorxdouble- Anchor point x-coord.
anchorydouble- Anchor point y-coord.
setToScale
public void setToScale(double sx, double sy)Sets transform to a scale transform.
Parameters
sxdouble- X-scale factor
sydouble- Y-scale factor
setToShear
public void setToShear(double shx, double shy)Sets transform to a shear transform.
Parameters
shxdouble- The shear-x
shydouble- The shear-y
setToRotation
public void setToRotation(double vecx, double vecy)Sets transform to a rotation transform.
Parameters
vecxdouble- x-coordinate of rotation vector.
vecydouble- y-coordinate of rotation vector.
setToRotation
public void setToRotation(double vecx, double vecy, double anchorx, double anchory)Sets the transform to a rotation transform.
Parameters
vecxdouble- x-coordinate of rotation vector.
vecydouble- y-coordinate of rotation vector
anchorxdouble- Anchor point x-coordinate
anchorydouble- Anchor point y-coordinate
setToIdentity
public void setToIdentity()Set to the identity matrix.
setToTranslation
public void setToTranslation(double tx, double ty)Sets transform to a translation transform.
Parameters
txdouble- x-translation
tydouble- y-translation
setToRotation
public void setToRotation(double theta, double anchorx, double anchory)Sets to a rotation transform.
Parameters
thetadouble- Radian rotation angle.
anchorxdouble- Anchor point x-coord.
anchorydouble- Anchor point y-coord.
setToRotation
public void setToRotation(double theta)Sets to a rotation transform.
Parameters
thetadouble- Rotation angle in radians.
setTransform
public void setTransform(double m00, double m10, double m01, double m11, double m02, double m12)Sets the transform to the given double coords.
Parameters
m00double- the X coordinate scaling element of the 3x3 matrix
m10double- the Y coordinate shearing element of the 3x3 matrix
m01double- the X coordinate shearing element of the 3x3 matrix
m11double- the Y coordinate scaling element of the 3x3 matrix
m02double- the X coordinate translation element of the 3x3 matrix
m12double- the Y coordinate translation element of the 3x3 matrix
toTransform
public Transform toTransform()Converts the transform to a
TransformtoString
public String toString()Returns a string representation of the object. In general, the toString method returns a string that “textually represents” this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.
The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@’, and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + ‘@’ + Integer.toHexString(hashCode())