public class AffineTransform

  1. Object
  2. 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

public static AffineTransform getRotateInstance(double theta)Gets a rotation transform
public static AffineTransform getRotateInstance(double theta, double anchorx, double anchory)Gets a rotation transform.
public void setToScale(double sx, double sy)Sets transform to a scale transform.
public void setToShear(double shx, double shy)Sets transform to a shear transform.
public void setToRotation(double vecx, double vecy)Sets transform to a rotation transform.
public void setToRotation(double vecx, double vecy, double anchorx, double anchory)Sets the transform to a rotation transform.
public void setToIdentity()Set to the identity matrix.
public void setToTranslation(double tx, double ty)Sets transform to a translation transform.
public void setToRotation(double theta, double anchorx, double anchory)Sets to a rotation transform.
public void setToRotation(double theta)Sets to a rotation transform.
public void setTransform(double m00, double m10, double m01, double m11, double m02, double m12)Sets the transform to the given double coords.
public Transform toTransform()Converts the transform to a Transform
public String toString()Returns a string representation of the object.

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

atx AffineTransform
Transform to copy.

AffineTransform

public AffineTransform(float m00, float m10, float m01, float m11, float m02, float m12)
Creates a new AffineTransform.

Parameters

m00 float
the X coordinate scaling element of the 3x3 matrix
m10 float
the Y coordinate shearing element of the 3x3 matrix
m01 float
the X coordinate shearing element of the 3x3 matrix
m11 float
the Y coordinate scaling element of the 3x3 matrix
m02 float
the X coordinate translation element of the 3x3 matrix
m12 float
the Y coordinate translation element of the 3x3 matrix

AffineTransform

public AffineTransform(float[] m)
Creates a new AffineTransform.

Parameters

m float[]
the float array containing the values to be set in the new AffineTransform object. 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

m00 double
the X coordinate scaling element of the 3x3 matrix
m10 double
the Y coordinate shearing element of the 3x3 matrix
m01 double
the X coordinate shearing element of the 3x3 matrix
m11 double
the Y coordinate scaling element of the 3x3 matrix
m02 double
the X coordinate translation element of the 3x3 matrix
m12 double
the Y coordinate translation element of the 3x3 matrix

AffineTransform

public AffineTransform(double[] m)
Creates a new AffineTransform.

Parameters

m double[]
the double array containing the values to be set in the new AffineTransform object. 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

theta double
Radian rotation angle.

getRotateInstance

public static AffineTransform getRotateInstance(double theta, double anchorx, double anchory)
Gets a rotation transform.

Parameters

theta double
Radian rotation angle.
anchorx double
Anchor point x-coord.
anchory double
Anchor point y-coord.

setToScale

public void setToScale(double sx, double sy)
Sets transform to a scale transform.

Parameters

sx double
X-scale factor
sy double
Y-scale factor

setToShear

public void setToShear(double shx, double shy)
Sets transform to a shear transform.

Parameters

shx double
The shear-x
shy double
The shear-y

setToRotation

public void setToRotation(double vecx, double vecy)
Sets transform to a rotation transform.

Parameters

vecx double
x-coordinate of rotation vector.
vecy double
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

vecx double
x-coordinate of rotation vector.
vecy double
y-coordinate of rotation vector
anchorx double
Anchor point x-coordinate
anchory double
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

tx double
x-translation
ty double
y-translation

setToRotation

public void setToRotation(double theta, double anchorx, double anchory)
Sets to a rotation transform.

Parameters

theta double
Radian rotation angle.
anchorx double
Anchor point x-coord.
anchory double
Anchor point y-coord.

setToRotation

public void setToRotation(double theta)
Sets to a rotation transform.

Parameters

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

m00 double
the X coordinate scaling element of the 3x3 matrix
m10 double
the Y coordinate shearing element of the 3x3 matrix
m01 double
the X coordinate shearing element of the 3x3 matrix
m11 double
the Y coordinate scaling element of the 3x3 matrix
m02 double
the X coordinate translation element of the 3x3 matrix
m12 double
the Y coordinate translation element of the 3x3 matrix

toTransform

public Transform toTransform()
Converts the transform to a Transform

toString

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