Package com.oorian.css
Class Filter
java.lang.Object
com.oorian.css.Filter
A builder for composing CSS
filter property values.
Filter provides a type-safe, fluent API for building CSS filter strings that contain multiple functions. Functions are maintained in insertion order, and setting the same function again replaces the previous value.
Usage:
// Compose multiple filters
element.setFilter(new Filter()
.blur("5px")
.brightness(1.2f)
.contrast(1.1f));
// Result: filter: blur(5px) brightness(1.2) contrast(1.1)
// Use with CssRule
CssRule rule = new CssRule(".faded");
rule.setFilter(new Filter().grayscale(1.0f).opacity(0.8f));
- Since:
- 2026
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionblur(int px) Adds ablur()function with a pixel value.Adds ablur()function with aUnitsvalue.Adds ablur()function.brightness(float value) Adds abrightness()function.contrast(float value) Adds acontrast()function.dropShadow(int offsetX, int offsetY, int blurRadius, Color color) Adds adrop-shadow()function with pixel values and aColorobject.dropShadow(Units offsetX, Units offsetY, Units blurRadius, Color color) dropShadow(String value) Adds adrop-shadow()function with a raw CSS value.dropShadow(String offsetX, String offsetY, String blurRadius, String color) Adds adrop-shadow()function with individual parameters.grayscale(float value) Adds agrayscale()function.hueRotate(float degrees) Adds ahue-rotate()function.Adds ahue-rotate()function with a raw CSS angle value.invert(float value) Adds aninvert()function.opacity(float value) Adds anopacity()function.saturate(float value) Adds asaturate()function.sepia(float value) Adds asepia()function.toString()Returns the CSS filter string.
-
Constructor Details
-
Filter
public Filter()Constructs an empty Filter.
-
-
Method Details
-
blur
Adds ablur()function.- Parameters:
value- the CSS length value (e.g.,"5px","0.5rem")- Returns:
- this Filter for method chaining
-
blur
Adds ablur()function with a pixel value.- Parameters:
px- the blur radius in pixels- Returns:
- this Filter for method chaining
-
blur
Adds ablur()function with aUnitsvalue.- Parameters:
units- the blur radius as a Units value (e.g.,new Px(5),new Rem(0.5f))- Returns:
- this Filter for method chaining
-
brightness
Adds abrightness()function.- Parameters:
value- the brightness factor (e.g.,1.5ffor 150%,0.5ffor 50%)- Returns:
- this Filter for method chaining
-
contrast
Adds acontrast()function.- Parameters:
value- the contrast factor (e.g.,1.5ffor 150%,0.5ffor 50%)- Returns:
- this Filter for method chaining
-
dropShadow
Adds adrop-shadow()function with a raw CSS value.- Parameters:
value- the drop-shadow value (e.g.,"2px 2px 4px rgba(0,0,0,0.3)")- Returns:
- this Filter for method chaining
-
dropShadow
Adds adrop-shadow()function with individual parameters.- Parameters:
offsetX- the horizontal offset (e.g.,"2px")offsetY- the vertical offset (e.g.,"2px")blurRadius- the blur radius (e.g.,"4px")color- the shadow color (e.g.,"rgba(0,0,0,0.3)")- Returns:
- this Filter for method chaining
-
dropShadow
Adds adrop-shadow()function with pixel values and aColorobject.- Parameters:
offsetX- the horizontal offset in pixelsoffsetY- the vertical offset in pixelsblurRadius- the blur radius in pixelscolor- the shadow Color object- Returns:
- this Filter for method chaining
-
dropShadow
- Parameters:
offsetX- the horizontal offset as a Units valueoffsetY- the vertical offset as a Units valueblurRadius- the blur radius as a Units valuecolor- the shadow Color object- Returns:
- this Filter for method chaining
-
grayscale
Adds agrayscale()function.- Parameters:
value- the grayscale amount from0.0f(none) to1.0f(full grayscale)- Returns:
- this Filter for method chaining
-
hueRotate
Adds ahue-rotate()function.- Parameters:
degrees- the rotation angle in degrees (e.g.,90for 90deg)- Returns:
- this Filter for method chaining
-
hueRotate
Adds ahue-rotate()function with a raw CSS angle value.- Parameters:
value- the CSS angle value (e.g.,"90deg","0.5turn")- Returns:
- this Filter for method chaining
-
invert
Adds aninvert()function.- Parameters:
value- the inversion amount from0.0f(none) to1.0f(full inversion)- Returns:
- this Filter for method chaining
-
opacity
Adds anopacity()function.- Parameters:
value- the opacity amount from0.0f(transparent) to1.0f(opaque)- Returns:
- this Filter for method chaining
-
saturate
Adds asaturate()function.- Parameters:
value- the saturation factor (e.g.,1.5ffor 150%,0.5ffor 50%)- Returns:
- this Filter for method chaining
-
sepia
Adds asepia()function.- Parameters:
value- the sepia amount from0.0f(none) to1.0f(full sepia)- Returns:
- this Filter for method chaining
-
toString
Returns the CSS filter string.
-