Class AffineTransform

java.lang.Object
com.codename1.ui.geom.AffineTransform

public class AffineTransform extends Object
A utility class for expressing 2-D affine transforms in Codename One.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates identity transform.
    AffineTransform(double[] m)
    Creates a new AffineTransform.
    AffineTransform(double m00, double m10, double m01, double m11, double m02, double m12)
    Creates a new AffineTransform.
    AffineTransform(float[] m)
    Creates a new AffineTransform.
    AffineTransform(float m00, float m10, float m01, float m11, float m02, float m12)
    Creates a new AffineTransform.
    Creates new affine transform as a copy of the given transform.
  • Method Summary

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

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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: Transform to copy.
    • AffineTransform

      public AffineTransform(float m00, float m10, float m01, float m11, float m02, float m12)

      Creates a new AffineTransform.

      Parameters
      • m00: the X coordinate scaling element of the 3x3 matrix

      • m10: the Y coordinate shearing element of the 3x3 matrix

      • m01: the X coordinate shearing element of the 3x3 matrix

      • m11: the Y coordinate scaling element of the 3x3 matrix

      • m02: the X coordinate translation element of the 3x3 matrix

      • m12: the Y coordinate translation element of the 3x3 matrix

    • AffineTransform

      public AffineTransform(float[] m)

      Creates a new AffineTransform.

      Parameters
      • m: @param m 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: the X coordinate scaling element of the 3x3 matrix

      • m10: the Y coordinate shearing element of the 3x3 matrix

      • m01: the X coordinate shearing element of the 3x3 matrix

      • m11: the Y coordinate scaling element of the 3x3 matrix

      • m02: the X coordinate translation element of the 3x3 matrix

      • m12: the Y coordinate translation element of the 3x3 matrix

    • AffineTransform

      public AffineTransform(double[] m)

      Creates a new AffineTransform.

      Parameters
      • m: @param m 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: Radian rotation angle.
    • getRotateInstance

      public static AffineTransform getRotateInstance(double theta, double anchorx, double anchory)

      Gets a rotation transform.

      Parameters
      • theta: Radian rotation angle.

      • anchorx: Anchor point x-coord.

      • anchory: Anchor point y-coord.

    • setToScale

      public void setToScale(double sx, double sy)

      Sets transform to a scale transform.

      Parameters
      • sx: X-scale factor

      • sy: Y-scale factor

    • setToShear

      public void setToShear(double shx, double shy)

      Sets transform to a shear transform.

      Parameters
      • shx: The shear-x

      • shy: The shear-y

    • setToRotation

      public void setToRotation(double vecx, double vecy)

      Sets transform to a rotation transform.

      Parameters
      • vecx: x-coordinate of rotation vector.

      • vecy: 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: x-coordinate of rotation vector.

      • vecy: y-coordinate of rotation vector

      • anchorx: Anchor point x-coordinate

      • anchory: 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: x-translation

      • ty: y-translation

    • setToRotation

      public void setToRotation(double theta, double anchorx, double anchory)

      Sets to a rotation transform.

      Parameters
      • theta: Radian rotation angle.

      • anchorx: Anchor point x-coord.

      • anchory: Anchor point y-coord.

    • setToRotation

      public void setToRotation(double theta)

      Sets to a rotation transform.

      Parameters
      • theta: 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: the X coordinate scaling element of the 3x3 matrix

      • m10: the Y coordinate shearing element of the 3x3 matrix

      • m01: the X coordinate shearing element of the 3x3 matrix

      • m11: the Y coordinate scaling element of the 3x3 matrix

      • m02: the X coordinate translation element of the 3x3 matrix

      • m12: the Y coordinate translation element of the 3x3 matrix

    • toTransform

      public Transform toTransform()
      Converts the transform to a Transform
    • toString

      public String toString()
      Description copied from class: Object
      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())
      Overrides:
      toString in class Object