Package de.xima.fc.css.builder
Class CssTransformListBuilder
java.lang.Object
de.xima.fc.css.builder.CssTransformListBuilder
Simple builder for creating a CSS transform
list string, e.g.
translateX(50px) scale(1,1.5)
- Author:
- XIMA MEDIA GmbH
-
Method Summary
Modifier and TypeMethodDescriptionactionOnPoints
(float[] oldPoints, float[] newPoints) A transform matrix is uniquely identified by its effect on three linearly independent points.actionOnPoints
(Point2D point1Old, Point2D point1New, Point2D point2Old, Point2D point2New, Point2D point3Old, Point2D point3New) A transform matrix is uniquely identified by its effect on three linearly independent points.build()
matrix
(double a, double b, double c, double d, double tx, double ty) matrix(1.2, 0, 0.8, 0, 20, 30)
.matrix
(AffineTransform transform) matrix(1.2, 0, 0.8, 0, 20, 30)
.mirrorX
(double axis) translateX(axis) scaleX(-1) translateX(-axis)
mirrorY
(double axis) translateY(axis) scaleY(-1) translateY(-axis)
translate(0.5turn)
.scale(1.2)
.scale(1.2, 0.8)
.scaleX(1.2)
.scaleY(1.2)
.skew(0.5turn)
.skew(0.5turn, 0.25turn)
.skewX(0.5turn)
.skewY(0.5turn)
.toString()
translate(50%)
.translate(50rem, 20vw)
.translateX
(Object value) translateX(50em)
.translateY
(Object value) translateY(50em)
.translateZ
(Object value) translateZ(50em)
.
-
Method Details
-
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
- Returns:
- The string representing the CSS transform list.
-
matrix
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 theAffineTransform
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
matrix(1.2, 0, 0.8, 0, 20, 30)
.- Parameters:
a
- Horizontal scale factora
.b
- Horizontal shear factorb
.c
- Vertical shear factorc
.d
- Vertical scale factord
.tx
- Horizontal translatione
.ty
- Vertical translationf
.- Returns:
- This builder instance for chaining method calls.
-
mirrorX
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
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
translate(0.5turn)
.- Parameters:
angle
- Rotation angle- Returns:
- This builder instance for chaining method calls.
-
scale
scale(1.2)
.- Parameters:
scale
- Horizontal and vertical scale factor.- Returns:
- This builder instance for chaining method calls.
-
scale
scale(1.2, 0.8)
.- Parameters:
x
- Horizontal scale factor.y
- Vertical scale factor.- Returns:
- This builder instance for chaining method calls.
-
scaleX
scaleX(1.2)
.- Parameters:
x
- Horizontal scale factor.- Returns:
- This builder instance for chaining method calls.
-
scaleY
scaleY(1.2)
.- Parameters:
y
- Vertical scale factor.- Returns:
- This builder instance for chaining method calls.
-
skew
skew(0.5turn)
.- Parameters:
angle
- Skew angle.- Returns:
- This builder instance for chaining method calls.
-
skew
skew(0.5turn, 0.25turn)
.- Parameters:
x
- Horizontal skew angle.y
- Vertical skew angle.- Returns:
- This builder instance for chaining method calls.
-
skewX
skewX(0.5turn)
.- Parameters:
angle
- Horizontal skew angle.- Returns:
- This builder instance for chaining method calls.
-
skewY
skewY(0.5turn)
.- Parameters:
angle
- Vertical skew angle.- Returns:
- This builder instance for chaining method calls.
-
toString
-
translate
translate(50%)
.- Parameters:
x
- Horizontal translation.- Returns:
- This builder instance for chaining method calls.
-
translate
translate(50rem, 20vw)
.- Parameters:
x
- Horizontal translation.y
- Vertical translation.- Returns:
- This builder instance for chaining method calls.
-
translateX
translateX(50em)
.- Parameters:
value
- Horizontal translation.- Returns:
- This builder instance for chaining method calls.
-
translateY
translateY(50em)
.- Parameters:
value
- Vertical translation.- Returns:
- This builder instance for chaining method calls.
-
translateZ
translateZ(50em)
.- Parameters:
value
- Depth translation.- Returns:
- This builder instance for chaining method calls.
-