Package com.oorian.css
Class Transform
java.lang.Object
com.oorian.css.Transform
A builder for composing CSS
transform property values.
Transform provides a type-safe, fluent API for building CSS transform strings that contain multiple functions. Functions are maintained in insertion order, and setting the same function again replaces the previous value.
Usage:
// Compose multiple transforms
element.setTransform(new Transform()
.translateX("50px")
.rotate(45)
.scale(1.5f));
// Result: transform: translateX(50px) rotate(45deg) scale(1.5)
// Order matters — transforms apply right to left
element.setTransform(new Transform()
.scale(2)
.translateX("50px"));
// Result: transform: scale(2.0) translateX(50px)
// Use with CssRule
CssRule rule = new CssRule(".rotated");
rule.setTransform(new Transform().rotate(45).scale(0.8f));
- Since:
- 2026
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionperspective(int pixels) Adds aperspective()function with a pixel value.perspective(Units units) Adds aperspective()function with aUnitsvalue.perspective(String value) Adds aperspective()function.rotate(float degrees) Adds arotate()function.Adds arotate()function with a CSS angle value.Adds arotate3d()function.rotateX(float degrees) Adds arotateX()function for 3D rotation around the X axis.Adds arotateX()function with a CSS angle value.rotateY(float degrees) Adds arotateY()function for 3D rotation around the Y axis.Adds arotateY()function with a CSS angle value.rotateZ(float degrees) Adds arotateZ()function for 3D rotation around the Z axis.Adds arotateZ()function with a CSS angle value.scale(float value) Adds a uniformscale()function.scale(float x, float y) Adds a non-uniformscale()function.scale3d(float x, float y, float z) Adds ascale3d()function.scaleX(float value) Adds ascaleX()function.scaleY(float value) Adds ascaleY()function.scaleZ(float value) Adds ascaleZ()function.skew(float xDegrees, float yDegrees) Adds askew()function for 2D skewing with angles in degrees.Adds askew()function for 2D skewing.skewX(float degrees) Adds askewX()function with an angle in degrees.Adds askewX()function.skewY(float degrees) Adds askewY()function with an angle in degrees.Adds askewY()function.toString()Returns the CSS transform string.translate(int x, int y) Adds atranslate()function for 2D translation with pixel values.Adds atranslate()function for 2D translation withUnitsvalues.Adds atranslate()function for 2D translation.translate3d(int x, int y, int z) Adds atranslate3d()function for 3D translation with pixel values.translate3d(Units x, Units y, Units z) Adds atranslate3d()function for 3D translation withUnitsvalues.translate3d(String x, String y, String z) Adds atranslate3d()function for 3D translation.translateX(int pixels) Adds atranslateX()function with a pixel value.translateX(Units units) Adds atranslateX()function with aUnitsvalue.translateX(String value) Adds atranslateX()function.translateY(int pixels) Adds atranslateY()function with a pixel value.translateY(Units units) Adds atranslateY()function with aUnitsvalue.translateY(String value) Adds atranslateY()function.translateZ(int pixels) Adds atranslateZ()function with a pixel value.translateZ(Units units) Adds atranslateZ()function with aUnitsvalue.translateZ(String value) Adds atranslateZ()function.
-
Constructor Details
-
Transform
public Transform()Constructs an empty Transform.
-
-
Method Details
-
translateX
Adds atranslateX()function.- Parameters:
value- the CSS length value (e.g.,"50px","10%","2rem")- Returns:
- this Transform for method chaining
-
translateX
Adds atranslateX()function with a pixel value.- Parameters:
pixels- the horizontal translation in pixels- Returns:
- this Transform for method chaining
-
translateX
Adds atranslateX()function with aUnitsvalue.- Parameters:
units- the horizontal translation as a Units value (e.g.,new Px(50),new Percent(10))- Returns:
- this Transform for method chaining
-
translateY
Adds atranslateY()function.- Parameters:
value- the CSS length value (e.g.,"50px","10%","2rem")- Returns:
- this Transform for method chaining
-
translateY
Adds atranslateY()function with a pixel value.- Parameters:
pixels- the vertical translation in pixels- Returns:
- this Transform for method chaining
-
translateY
Adds atranslateY()function with aUnitsvalue.- Parameters:
units- the vertical translation as a Units value (e.g.,new Px(50),new Percent(10))- Returns:
- this Transform for method chaining
-
translateZ
Adds atranslateZ()function.- Parameters:
value- the CSS length value (e.g.,"50px","100px")- Returns:
- this Transform for method chaining
-
translateZ
Adds atranslateZ()function with a pixel value.- Parameters:
pixels- the depth translation in pixels- Returns:
- this Transform for method chaining
-
translateZ
Adds atranslateZ()function with aUnitsvalue.- Parameters:
units- the depth translation as a Units value- Returns:
- this Transform for method chaining
-
translate
Adds atranslate()function for 2D translation.- Parameters:
x- the horizontal CSS length valuey- the vertical CSS length value- Returns:
- this Transform for method chaining
-
translate
Adds atranslate()function for 2D translation with pixel values.- Parameters:
x- the horizontal translation in pixelsy- the vertical translation in pixels- Returns:
- this Transform for method chaining
-
translate
Adds atranslate()function for 2D translation withUnitsvalues.- Parameters:
x- the horizontal translation as a Units valuey- the vertical translation as a Units value- Returns:
- this Transform for method chaining
-
translate3d
Adds atranslate3d()function for 3D translation.- Parameters:
x- the horizontal CSS length valuey- the vertical CSS length valuez- the depth CSS length value- Returns:
- this Transform for method chaining
-
translate3d
Adds atranslate3d()function for 3D translation with pixel values.- Parameters:
x- the horizontal translation in pixelsy- the vertical translation in pixelsz- the depth translation in pixels- Returns:
- this Transform for method chaining
-
translate3d
Adds atranslate3d()function for 3D translation withUnitsvalues.- Parameters:
x- the horizontal translation as a Units valuey- the vertical translation as a Units valuez- the depth translation as a Units value- Returns:
- this Transform for method chaining
-
rotate
Adds arotate()function.- Parameters:
degrees- the rotation angle in degrees- Returns:
- this Transform for method chaining
-
rotate
Adds arotate()function with a CSS angle value.- Parameters:
value- the CSS angle value (e.g.,"45deg","0.5turn","1.57rad")- Returns:
- this Transform for method chaining
-
rotateX
Adds arotateX()function for 3D rotation around the X axis.- Parameters:
degrees- the rotation angle in degrees- Returns:
- this Transform for method chaining
-
rotateX
Adds arotateX()function with a CSS angle value.- Parameters:
value- the CSS angle value (e.g.,"45deg","0.5turn","1.57rad")- Returns:
- this Transform for method chaining
-
rotateY
Adds arotateY()function for 3D rotation around the Y axis.- Parameters:
degrees- the rotation angle in degrees- Returns:
- this Transform for method chaining
-
rotateY
Adds arotateY()function with a CSS angle value.- Parameters:
value- the CSS angle value (e.g.,"45deg","0.5turn","1.57rad")- Returns:
- this Transform for method chaining
-
rotateZ
Adds arotateZ()function for 3D rotation around the Z axis.- Parameters:
degrees- the rotation angle in degrees- Returns:
- this Transform for method chaining
-
rotateZ
Adds arotateZ()function with a CSS angle value.- Parameters:
value- the CSS angle value (e.g.,"45deg","0.5turn","1.57rad")- Returns:
- this Transform for method chaining
-
rotate3d
Adds arotate3d()function.- Parameters:
x- the X component of the rotation axis vectory- the Y component of the rotation axis vectorz- the Z component of the rotation axis vectorangle- the CSS angle value (e.g.,"45deg")- Returns:
- this Transform for method chaining
-
scale
Adds a uniformscale()function.- Parameters:
value- the scale factor (e.g.,1.5ffor 150%)- Returns:
- this Transform for method chaining
-
scale
Adds a non-uniformscale()function.- Parameters:
x- the horizontal scale factory- the vertical scale factor- Returns:
- this Transform for method chaining
-
scaleX
Adds ascaleX()function.- Parameters:
value- the horizontal scale factor- Returns:
- this Transform for method chaining
-
scaleY
Adds ascaleY()function.- Parameters:
value- the vertical scale factor- Returns:
- this Transform for method chaining
-
scaleZ
Adds ascaleZ()function.- Parameters:
value- the depth scale factor- Returns:
- this Transform for method chaining
-
scale3d
Adds ascale3d()function.- Parameters:
x- the horizontal scale factory- the vertical scale factorz- the depth scale factor- Returns:
- this Transform for method chaining
-
skewX
Adds askewX()function.- Parameters:
value- the CSS angle value (e.g.,"15deg")- Returns:
- this Transform for method chaining
-
skewX
Adds askewX()function with an angle in degrees.- Parameters:
degrees- the skew angle in degrees- Returns:
- this Transform for method chaining
-
skewY
Adds askewY()function.- Parameters:
value- the CSS angle value (e.g.,"15deg")- Returns:
- this Transform for method chaining
-
skewY
Adds askewY()function with an angle in degrees.- Parameters:
degrees- the skew angle in degrees- Returns:
- this Transform for method chaining
-
skew
Adds askew()function for 2D skewing.- Parameters:
x- the CSS angle value for the X axisy- the CSS angle value for the Y axis- Returns:
- this Transform for method chaining
-
skew
Adds askew()function for 2D skewing with angles in degrees.- Parameters:
xDegrees- the X-axis skew angle in degreesyDegrees- the Y-axis skew angle in degrees- Returns:
- this Transform for method chaining
-
perspective
Adds aperspective()function.- Parameters:
value- the CSS length value (e.g.,"500px")- Returns:
- this Transform for method chaining
-
perspective
Adds aperspective()function with a pixel value.- Parameters:
pixels- the perspective distance in pixels- Returns:
- this Transform for method chaining
-
perspective
Adds aperspective()function with aUnitsvalue.- Parameters:
units- the perspective distance as a Units value- Returns:
- this Transform for method chaining
-
toString
Returns the CSS transform string.
-