Class AffineTransform

    • Field Detail

      • a

        public double a

        The 'a' matrix element.

        This is the 'a' element in the affine transformation matrix [a b 0; c d 0; e f 1]
      • b

        public double b

        The 'b' matrix element.

        This is the 'b' element in the affine transformation matrix [a b 0; c d 0; e f 1]
      • c

        public double c

        The 'c' matrix element.

        This is the 'c' element in the affine transformation matrix [a b 0; c d 0; e f 1]
      • d

        public double d

        The 'd' matrix element.

        This is the 'd' element in the affine transformation matrix [a b 0; c d 0; e f 1]
      • e

        public double e

        The 'e' matrix element.

        This is the 'e' element in the affine transformation matrix [a b 0; c d 0; e f 1]
      • f

        public double f

        The 'f' matrix element.

        This is the 'f' element in the affine transformation matrix [a b 0; c d 0; e f 1]
    • Constructor Detail

      • AffineTransform

        public AffineTransform()
        Constructor.
      • AffineTransform

        public AffineTransform​(double a,
                               double b,
                               double c,
                               double d,
                               double e,
                               double f)
    • Method Detail

      • getA

        public double getA()
        Gets a
      • setA

        public void setA​(double a)
        Sets a
      • getB

        public double getB()
        Gets b
      • setB

        public void setB​(double b)
        Sets b
      • getC

        public double getC()
        Gets c
      • setC

        public void setC​(double c)
        Sets c
      • getD

        public double getD()
        Gets d
      • setD

        public void setD​(double d)
        Sets d
      • getE

        public double getE()
        Gets e
      • setE

        public void setE​(double e)
        Sets e
      • getF

        public double getF()
        Gets f
      • setF

        public void setF​(double f)
        Sets f
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • translate

        public void translate​(double tx,
                              double ty)

        Translate.

        Translations are specified as [1 0 0 1 tx ty], where tx and ty are the distances to translate the origin of the coordinate system in the horizontal and vertical dimensions, respectively.
        Parameters:
        tx - horizontal translation
        ty - vertical translation
        Throws:
        java.lang.IllegalStateException - If the affine transform is singular, e.g. default initialized. (Use getIdentity() as an initial value.)
      • scale

        public void scale​(double sx,
                          double sy)

        Scale.

        Scaling is obtained by [sx 0 0 sy 0 0]. This scales the coordinates so that 1 unit in the horizontal and vertical dimensions of the new coordinate system is the same size as sx and sy units, respectively, in the previous coordinate system.
        Parameters:
        sx - horizontal scale factor
        sy - vertical scale factor
        Throws:
        java.lang.IllegalStateException - If the affine transform is singular, e.g. default initialized. (Use getIdentity() as an initial value.)
      • rotate

        public void rotate​(double angle,
                           Point center)

        Rotate.

        Rotations are produced by [cos(a) sin(a) -sin(a) cos(a) 0 0], which has the effect of rotating the coordinate system axes by an angle "a" in counterclockwise direction around the origin.

        If the given center is not null, then the rotation is performed around the given center point, which is equivalent to the following sequence:

        Parameters:
        angle - The angle of the rotation in degrees.
        center - The center of the rotation. If null then the origin (0/0) is taken as center.
        Throws:
        java.lang.IllegalStateException - If the affine transform is singular, e.g. default initialized. (Use getIdentity() as an initial value.)
      • skew

        public void skew​(double alpha,
                         double beta)

        Skew.

        Skew is specified by [1 tan a tan b 1 0 0], which skews the x axis by an angle a and the y axis by an angle b.
        Parameters:
        alpha - angle a in degrees
        beta - angle b in degrees
        Throws:
        java.lang.IllegalStateException - If the affine transform is singular, e.g. default initialized. (Use getIdentity() as an initial value.)
        java.lang.IllegalArgumentException - if any of the given angles is too close to 90 + k*180 degrees for k = ..., -2, -1, 0, 1, 2, ...
      • concatenate

        public void concatenate​(AffineTransform other)

        Concatenate transform with other transform.

        Concatenating a transform with an other transform is equivalent to left-multiplying the transform's matrix with with the other transform's matrix.
        Parameters:
        other - the transform to be concatenated to this transform
        Throws:
        java.lang.IllegalStateException - If the affine transform is singular, e.g. default initialized. (Use getIdentity() as an initial value.)
        java.lang.IllegalArgumentException - If the other affine transform is singular, e.g. default initialized. (Use getIdentity() as an initial value.)
        java.lang.IllegalArgumentException - if other is null
      • invert

        public void invert()

        Invert the transform

        A transform usually maps from the transformed coordinate system to the untransformed coordinate system. Use this method to create the reverse transform.
        Throws:
        java.lang.IllegalStateException - If the affine transform is singular, e.g. default initialized. (Use getIdentity() as an initial value.)
      • transformPoint

        public Point transformPoint​(Point original)

        Transforms the given point.

        Parameters:
        original - the point to be transformed
        Returns:
        the transformed point
        Throws:
        java.lang.IllegalStateException - If the affine transform is singular, e.g. default initialized. (Use getIdentity() as an initial value.)
        java.lang.IllegalArgumentException - if original is null
      • transformRectangle

        public Quadrilateral transformRectangle​(Rectangle original)

        Transform the given rectangle

        For a general affine transformation, the returned Quadrilateral is a parallelogram.
        Parameters:
        original - the rectangle to be transformed
        Returns:
        the transformed rectangle. For a general affine transform this is a parallelogram.
        Throws:
        java.lang.IllegalStateException - if the affine transform is singular, e.g. default initialized. (Use getIdentity() as an initial value.)
        java.lang.IllegalArgumentException - if original is null
      • transformQuadrilateral

        public Quadrilateral transformQuadrilateral​(Quadrilateral original)

        Transform a given quadrilateral

        If the input quadrilateral is a parallelogram, then the output is also a parallelogram.
        Parameters:
        original - the quadrilateral to be transformed
        Returns:
        the transformed quadrilateral. If the input is a parallelogram then the output is also a parallelogram.
        Throws:
        java.lang.IllegalStateException - if the affine transform is singular, e.g. default initialized. (Use getIdentity() as an initial value.)
        java.lang.IllegalArgumentException - if original is null
      • getIdentity

        public static AffineTransform getIdentity()

        The identity transform (Getter)