Class Rotate

  • All Implemented Interfaces:
    Cloneable, EventTarget

    public class Rotate
    extends Transform
    This class represents an Affine object that rotates coordinates around an anchor point. This operation is equivalent to translating the coordinates so that the anchor point is at the origin (S1), then rotating them about the new origin (S2), and finally translating so that the intermediate origin is restored to the coordinates of the original anchor point (S3).

    The matrix representing the rotation transformation around an axis (x,y,z) by an angle t is as follows:

                  [   cos(t)   -sin(t)   0   x-x*cos(t)+y*sin(t)   ]
                  [   sin(t)    cos(t)   0   y-x*sin(t)-y*cos(t)   ]
                  [     0         0      1           z             ]
     

    For example, to rotate a text 30 degrees around the Z-axis at anchor point of (50,30):

    
     Text text = new Text("This is a test");
     text.setX(10);
     text.setY(50);
     text.setFont(new Font(20));
    
     text.getTransforms().add(new Rotate(30, 50, 30));
     
    Since:
    JavaFX 2.0
    • Field Detail

      • X_AXIS

        public static final Point3D X_AXIS
        Specifies the X-axis as the axis of rotation.
      • Y_AXIS

        public static final Point3D Y_AXIS
        Specifies the Y-axis as the axis of rotation.
      • Z_AXIS

        public static final Point3D Z_AXIS
        Specifies the Z-axis as the axis of rotation.
    • Constructor Detail

      • Rotate

        public Rotate()
        Creates a default Rotate transform (identity).
      • Rotate

        public Rotate​(double angle)
        Creates a two-dimensional Rotate transform. The pivot point is set to (0,0)
        Parameters:
        angle - the angle of rotation measured in degrees
      • Rotate

        public Rotate​(double angle,
                      Point3D axis)
        Creates a three-dimensional Rotate transform. The pivot point is set to (0,0,0)
        Parameters:
        angle - the angle of rotation measured in degrees
        axis - the axis of rotation
      • Rotate

        public Rotate​(double angle,
                      double pivotX,
                      double pivotY)
        Creates a two-dimensional Rotate transform with pivot.
        Parameters:
        angle - the angle of rotation measured in degrees
        pivotX - the X coordinate of the rotation pivot point
        pivotY - the Y coordinate of the rotation pivot point
      • Rotate

        public Rotate​(double angle,
                      double pivotX,
                      double pivotY,
                      double pivotZ)
        Creates a simple Rotate transform with three-dimensional pivot.
        Parameters:
        angle - the angle of rotation measured in degrees
        pivotX - the X coordinate of the rotation pivot point
        pivotY - the Y coordinate of the rotation pivot point
        pivotZ - the Z coordinate of the rotation pivot point
      • Rotate

        public Rotate​(double angle,
                      double pivotX,
                      double pivotY,
                      double pivotZ,
                      Point3D axis)
        Creates a three-dimensional Rotate transform with pivot.
        Parameters:
        angle - the angle of rotation measured in degrees
        pivotX - the X coordinate of the rotation pivot point
        pivotY - the Y coordinate of the rotation pivot point
        pivotZ - the Z coordinate of the rotation pivot point
        axis - the axis of rotation
    • Method Detail

      • setAngle

        public final void setAngle​(double value)
        Sets the value of the property angle.
        Property description:
        Defines the angle of rotation measured in degrees.
      • getAngle

        public final double getAngle()
        Gets the value of the property angle.
        Property description:
        Defines the angle of rotation measured in degrees.
      • setPivotX

        public final void setPivotX​(double value)
        Sets the value of the property pivotX.
        Property description:
        Defines the X coordinate of the rotation pivot point.
        Default value:
        0.0
      • getPivotX

        public final double getPivotX()
        Gets the value of the property pivotX.
        Property description:
        Defines the X coordinate of the rotation pivot point.
        Default value:
        0.0
      • setPivotY

        public final void setPivotY​(double value)
        Sets the value of the property pivotY.
        Property description:
        Defines the Y coordinate of the rotation pivot point.
        Default value:
        0.0
      • getPivotY

        public final double getPivotY()
        Gets the value of the property pivotY.
        Property description:
        Defines the Y coordinate of the rotation pivot point.
        Default value:
        0.0
      • setPivotZ

        public final void setPivotZ​(double value)
        Sets the value of the property pivotZ.
        Property description:
        Defines the Z coordinate of the rotation pivot point.
        Default value:
        0.0
      • getPivotZ

        public final double getPivotZ()
        Gets the value of the property pivotZ.
        Property description:
        Defines the Z coordinate of the rotation pivot point.
        Default value:
        0.0
      • setAxis

        public final void setAxis​(Point3D value)
        Sets the value of the property axis.
        Property description:
        Defines the axis of rotation at the pivot point.
      • getAxis

        public final Point3D getAxis()
        Gets the value of the property axis.
        Property description:
        Defines the axis of rotation at the pivot point.
      • getMxx

        public double getMxx()
        Description copied from class: Transform
        Gets the X coordinate scaling element of the 3x4 matrix.
        Overrides:
        getMxx in class Transform
        Returns:
        the X coordinate scaling element of the 3x4 matrix
      • getMxy

        public double getMxy()
        Description copied from class: Transform
        Gets the XY coordinate element of the 3x4 matrix.
        Overrides:
        getMxy in class Transform
        Returns:
        the XY coordinate element of the 3x4 matrix
      • getMxz

        public double getMxz()
        Description copied from class: Transform
        Gets the XZ coordinate element of the 3x4 matrix.
        Overrides:
        getMxz in class Transform
        Returns:
        the XZ coordinate element of the 3x4 matrix
      • getTx

        public double getTx()
        Description copied from class: Transform
        Gets the X coordinate translation element of the 3x4 matrix.
        Overrides:
        getTx in class Transform
        Returns:
        the X coordinate translation element of the 3x4 matrix
      • getMyx

        public double getMyx()
        Description copied from class: Transform
        Gets the YX coordinate element of the 3x4 matrix.
        Overrides:
        getMyx in class Transform
        Returns:
        the YX coordinate element of the 3x4 matrix
      • getMyy

        public double getMyy()
        Description copied from class: Transform
        Gets the Y coordinate scaling element of the 3x4 matrix.
        Overrides:
        getMyy in class Transform
        Returns:
        the Y coordinate scaling element of the 3x4 matrix
      • getMyz

        public double getMyz()
        Description copied from class: Transform
        Gets the YZ coordinate element of the 3x4 matrix.
        Overrides:
        getMyz in class Transform
        Returns:
        the YZ coordinate element of the 3x4 matrix
      • getTy

        public double getTy()
        Description copied from class: Transform
        Gets the Y coordinate translation element of the 3x4 matrix.
        Overrides:
        getTy in class Transform
        Returns:
        the Y coordinate translation element of the 3x4 matrix
      • getMzx

        public double getMzx()
        Description copied from class: Transform
        Gets the ZX coordinate element of the 3x4 matrix.
        Overrides:
        getMzx in class Transform
        Returns:
        the ZX coordinate element of the 3x4 matrix
      • getMzy

        public double getMzy()
        Description copied from class: Transform
        Gets the ZY coordinate element of the 3x4 matrix.
        Overrides:
        getMzy in class Transform
        Returns:
        the ZY coordinate element of the 3x4 matrix
      • getMzz

        public double getMzz()
        Description copied from class: Transform
        Gets the Z coordinate scaling element of the 3x4 matrix.
        Overrides:
        getMzz in class Transform
        Returns:
        the Z coordinate scaling element of the 3x4 matrix
      • getTz

        public double getTz()
        Description copied from class: Transform
        Gets the Z coordinate translation element of the 3x4 matrix.
        Overrides:
        getTz in class Transform
        Returns:
        the Z coordinate translation element of the 3x4 matrix
      • createConcatenation

        public Transform createConcatenation​(Transform transform)
        Description copied from class: Transform
        Returns the concatenation of this transform and the specified transform. Applying the resulting transform to a node has the same effect as adding the two transforms to its getTransforms() list, this transform first and the specified transform second.
        Overrides:
        createConcatenation in class Transform
        Parameters:
        transform - transform to be concatenated with this transform
        Returns:
        The concatenated transform
      • clone

        public Rotate clone()
        Description copied from class: Transform
        Returns a deep copy of this transform.
        Overrides:
        clone in class Transform
        Returns:
        a copy of this transform
      • transform

        public Point2D transform​(double x,
                                 double y)
        Description copied from class: Transform
        Transforms the specified point by this transform. This method can be used only for 2D transforms.
        Overrides:
        transform in class Transform
        Parameters:
        x - the X coordinate of the point
        y - the Y coordinate of the point
        Returns:
        the transformed point
      • transform

        public Point3D transform​(double x,
                                 double y,
                                 double z)
        Description copied from class: Transform
        Transforms the specified point by this transform.
        Overrides:
        transform in class Transform
        Parameters:
        x - the X coordinate of the point
        y - the Y coordinate of the point
        z - the Z coordinate of the point
        Returns:
        the transformed point
      • deltaTransform

        public Point2D deltaTransform​(double x,
                                      double y)
        Description copied from class: Transform
        Transforms the relative magnitude vector by this transform. The vector is transformed without applying the translation components of the affine transformation matrix. This method can be used only for a 2D transform.
        Overrides:
        deltaTransform in class Transform
        Parameters:
        x - vector magnitude in the direction of the X axis
        y - vector magnitude in the direction of the Y axis
        Returns:
        the transformed relative magnitude vector represented by a Point2D instance
      • deltaTransform

        public Point3D deltaTransform​(double x,
                                      double y,
                                      double z)
        Description copied from class: Transform
        Transforms the relative magnitude vector by this transform. The vector is transformed without applying the translation components of the affine transformation matrix.
        Overrides:
        deltaTransform in class Transform
        Parameters:
        x - vector magnitude in the direction of the X axis
        y - vector magnitude in the direction of the Y axis
        z - vector magnitude in the direction of the Z axis
        Returns:
        the transformed relative magnitude vector represented by a Point3D instance
      • inverseTransform

        public Point2D inverseTransform​(double x,
                                        double y)
        Description copied from class: Transform
        Transforms the specified point by the inverse of this transform. This method can be used only for 2D transforms.
        Overrides:
        inverseTransform in class Transform
        Parameters:
        x - the X coordinate of the point
        y - the Y coordinate of the point
        Returns:
        the inversely transformed point
      • inverseTransform

        public Point3D inverseTransform​(double x,
                                        double y,
                                        double z)
        Description copied from class: Transform
        Transforms the specified point by the inverse of this transform.
        Overrides:
        inverseTransform in class Transform
        Parameters:
        x - the X coordinate of the point
        y - the Y coordinate of the point
        z - the Z coordinate of the point
        Returns:
        the inversely transformed point
      • inverseDeltaTransform

        public Point2D inverseDeltaTransform​(double x,
                                             double y)
        Description copied from class: Transform
        Transforms the relative magnitude vector by the inverse of this transform. The vector is transformed without applying the translation components of the affine transformation matrix. This method can be used only for a 2D transform.
        Overrides:
        inverseDeltaTransform in class Transform
        Parameters:
        x - vector magnitude in the direction of the X axis
        y - vector magnitude in the direction of the Y axis
        Returns:
        the inversely transformed relative magnitude vector represented by a Point2D instance
      • inverseDeltaTransform

        public Point3D inverseDeltaTransform​(double x,
                                             double y,
                                             double z)
        Description copied from class: Transform
        Transforms the relative magnitude vector by the inverse of this transform. The vector is transformed without applying the translation components of the affine transformation matrix.
        Overrides:
        inverseDeltaTransform in class Transform
        Parameters:
        x - vector magnitude in the direction of the X axis
        y - vector magnitude in the direction of the Y axis
        z - vector magnitude in the direction of the Z axis
        Returns:
        the inversely transformed relative magnitude vector represented by a Point3D instance
      • toString

        public String toString()
        Returns a string representation of this Rotate object.
        Overrides:
        toString in class Object
        Returns:
        a string representation of this Rotate object.
      • transformChanged

        protected void transformChanged()
        Description copied from class: Transform
        This method must be called by all transforms whenever any of their parameters changes. It is typically called when any of the transform's properties is invalidated (it is OK to skip the call if an invalid property is set).
        Overrides:
        transformChanged in class Transform