Class CssTransformListBuilder


  • public final class CssTransformListBuilder
    extends Object
    Simple builder for creating a CSS transform list string, e.g. translateX(50px) scale(1,1.5)
    Author:
    XIMA MEDIA GmbH
    • Method Detail

      • actionOnPoints

        public CssTransformListBuilder actionOnPoints​(float[] oldPoints,
                                                      float[] newPoints)
                                               throws org.apache.commons.math3.linear.SingularMatrixException
        A transform matrix is uniquely identified by its effect on three linearly independent points. This methods adds a matrix transform with the effect that it transforms the given three old points into the three given new points. The three old and new points must be linearly independent.
        Parameters:
        oldPoints - Coordinates of the three old points: [x1, y1, x2, y2, x3, y3].
        newPoints - Coordinates of the three new points: [x1', y1', x2', y2', x3', y3'].
        Returns:
        This builder instance for chaining method calls.
        Throws:
        org.apache.commons.math3.linear.SingularMatrixException - When the three points are not linearly independent.
      • actionOnPoints

        public CssTransformListBuilder actionOnPoints​(Point2D point1Old,
                                                      Point2D point1New,
                                                      Point2D point2Old,
                                                      Point2D point2New,
                                                      Point2D point3Old,
                                                      Point2D point3New)
                                               throws org.apache.commons.math3.linear.SingularMatrixException
        A transform matrix is uniquely identified by its effect on three linearly independent points. This methods adds a matrix transform with the effect that it transforms the given three old points into the three given new points. The three old and new points must be linearly independent.
        Parameters:
        point1Old - Coordinates of the first point in the old coordinate system.
        point1New - Coordinates of the first point in the new coordinate system.
        point2Old - Coordinates of the second point in the old coordinate system.
        point2New - Coordinates of the second point in the new coordinate system.
        point3Old - Coordinates of the third point in the old coordinate system.
        point3New - Coordinates of the third point in the new coordinate system.
        Returns:
        This builder instance for chaining method calls.
        Throws:
        org.apache.commons.math3.linear.SingularMatrixException - When the three points are not linearly independent.
      • build

        public String build()
        Returns:
        The string representing the CSS transform list.
      • matrix

        public CssTransformListBuilder matrix​(AffineTransform transform)
        matrix(1.2, 0, 0.8, 0, 20, 30).

        Adds a matrix transform to the list of transformations. Takes the matrix coefficients from an AffineTransform. Note that this method does not perform any coordinate system transformations, use with care when the AffineTransform assumes an underlying coordinate system that is different from CSS coordinates (origin at the top left corner).

        Parameters:
        transform - Transform to apply.
        Returns:
        This builder instance for chaining method calls.
      • matrix

        public CssTransformListBuilder matrix​(double a,
                                              double b,
                                              double c,
                                              double d,
                                              double tx,
                                              double ty)
        matrix(1.2, 0, 0.8, 0, 20, 30).
        Parameters:
        a - Horizontal scale factor a.
        b - Horizontal shear factor b.
        c - Vertical shear factor c.
        d - Vertical scale factor d.
        tx - Horizontal translation e.
        ty - Vertical translation f.
        Returns:
        This builder instance for chaining method calls.
      • mirrorX

        public CssTransformListBuilder mirrorX​(double axis)
        translateX(axis) scaleX(-1) translateX(-axis)

        Adds a mirroring transform around the given x axis.

        Parameters:
        axis - X coordinate of the mirroring axis.
        Returns:
        This builder instance for chaining method calls.
      • mirrorY

        public CssTransformListBuilder mirrorY​(double axis)
        translateY(axis) scaleY(-1) translateY(-axis)

        Adds a mirroring transform around the given y axis.

        Parameters:
        axis - Y coordinate of the mirroring axis.
        Returns:
        This builder instance for chaining method calls.
      • rotate

        public CssTransformListBuilder rotate​(Object angle)
        translate(0.5turn).
        Parameters:
        angle - Rotation angle
        Returns:
        This builder instance for chaining method calls.
      • scale

        public CssTransformListBuilder scale​(Object scale)
        scale(1.2).
        Parameters:
        scale - Horizontal and vertical scale factor.
        Returns:
        This builder instance for chaining method calls.
      • scale

        public CssTransformListBuilder scale​(Object x,
                                             Object y)
        scale(1.2, 0.8).
        Parameters:
        x - Horizontal scale factor.
        y - Vertical scale factor.
        Returns:
        This builder instance for chaining method calls.
      • scaleX

        public CssTransformListBuilder scaleX​(Object x)
        scaleX(1.2).
        Parameters:
        x - Horizontal scale factor.
        Returns:
        This builder instance for chaining method calls.
      • scaleY

        public CssTransformListBuilder scaleY​(Object y)
        scaleY(1.2).
        Parameters:
        y - Vertical scale factor.
        Returns:
        This builder instance for chaining method calls.
      • skew

        public CssTransformListBuilder skew​(Object angle)
        skew(0.5turn).
        Parameters:
        angle - Skew angle.
        Returns:
        This builder instance for chaining method calls.
      • skew

        public CssTransformListBuilder skew​(Object x,
                                            Object y)
        skew(0.5turn, 0.25turn).
        Parameters:
        x - Horizontal skew angle.
        y - Vertical skew angle.
        Returns:
        This builder instance for chaining method calls.
      • skewX

        public CssTransformListBuilder skewX​(Object angle)
        skewX(0.5turn).
        Parameters:
        angle - Horizontal skew angle.
        Returns:
        This builder instance for chaining method calls.
      • skewY

        public CssTransformListBuilder skewY​(Object angle)
        skewY(0.5turn).
        Parameters:
        angle - Vertical skew angle.
        Returns:
        This builder instance for chaining method calls.
      • translate

        public CssTransformListBuilder translate​(Object x)
        translate(50%).
        Parameters:
        x - Horizontal translation.
        Returns:
        This builder instance for chaining method calls.
      • translate

        public CssTransformListBuilder translate​(Object x,
                                                 Object y)
        translate(50rem, 20vw).
        Parameters:
        x - Horizontal translation.
        y - Vertical translation.
        Returns:
        This builder instance for chaining method calls.
      • translateX

        public CssTransformListBuilder translateX​(Object value)
        translateX(50em).
        Parameters:
        value - Horizontal translation.
        Returns:
        This builder instance for chaining method calls.
      • translateY

        public CssTransformListBuilder translateY​(Object value)
        translateY(50em).
        Parameters:
        value - Vertical translation.
        Returns:
        This builder instance for chaining method calls.
      • translateZ

        public CssTransformListBuilder translateZ​(Object value)
        translateZ(50em).
        Parameters:
        value - Depth translation.
        Returns:
        This builder instance for chaining method calls.