Class MaskElement
- All Implemented Interfaces:
Serializable
<mask> element.
The <mask> element defines an alpha mask for compositing the
current object into the background. A mask is used to create transparency
effects that are more complex than simple opacity.
Unlike clip paths which create hard edges, masks can create soft edges and gradual transparency using the luminance or alpha values of the mask contents.
Masks must be placed inside a <defs> element and referenced
using the mask attribute (e.g., mask="url(#myMask)").
Write-Only vs Read-Write Methods
This class provides two variants for each attribute setter:
- Default methods (e.g.,
x(),y()) - Use an optimized write-only approach. Attribute values are NOT stored on the server and cannot be retrieved viagetAttribute(). - RW methods (e.g.,
xRW(),yRW()) - Use traditionalsetAttribute()which stores values on the server for later retrieval.
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class SvgElement
SvgElement.PreserveAspectRatio -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(SvgElement... elements) Adds content elements to this mask.bounds(double x, double y, double width, double height) Sets the bounds of the mask area.boundsRW(double x, double y, double width, double height) Sets the bounds of the mask area (read-write).height(double height) Sets the height of the mask area.Sets the height with a unit.heightRW(double height) Sets the height of the mask area (read-write).Sets the height with a unit (read-write).Sets the coordinate system for the mask contents.Sets the coordinate system for the mask contents (read-write).maskUnits(MaskElement.MaskUnits units) Sets the coordinate system for x, y, width, height attributes.maskUnitsRW(MaskElement.MaskUnits units) Sets the coordinate system for x, y, width, height attributes (read-write).width(double width) Sets the width of the mask area.Sets the width with a unit.widthRW(double width) Sets the width of the mask area (read-write).Sets the width with a unit (read-write).x(double x) Sets the x coordinate of the mask area.Sets the x coordinate with a unit.xRW(double x) Sets the x coordinate of the mask area (read-write).Sets the x coordinate with a unit (read-write).y(double y) Sets the y coordinate of the mask area.Sets the y coordinate with a unit.yRW(double y) Sets the y coordinate of the mask area (read-write).Sets the y coordinate with a unit (read-write).Methods inherited from class SvgElement
emptySvgRoot, flushPendingAttributes, getOuterHTML, getPendingOrAttribute, getStyle, id, preserveAspectRatio, preserveAspectRatio, scheduleBeforeClientResponse, setAttribute, setWriteOnlyAttribute, size, size, viewBoxMethods inherited from class com.vaadin.flow.dom.Element
addAttachListener, addDetachListener, addEventListener, addPropertyChangeListener, addPropertyChangeListener, as, attachShadow, bindAttribute, bindProperty, bindText, callJsFunction, callJsFunction, createText, executeJs, executeJs, get, get, getAttribute, getAttributeNames, getChild, getChildCount, getChildren, getClassList, getComponent, getParent, getProperty, getProperty, getProperty, getProperty, getProperty, getPropertyBean, getPropertyBean, getPropertyNames, getPropertyRaw, getSelf, getShadowRoot, getTag, getText, getTextRecursively, getThemeList, hasAttribute, hasProperty, isEnabled, isTextNode, isVisible, removeAttribute, removeFromParent, removeFromTree, removeFromTree, removeProperty, scrollIntoView, scrollIntoView, setAttribute, setAttribute, setAttribute, setEnabled, setProperty, setProperty, setProperty, setPropertyBean, setPropertyJson, setPropertyList, setPropertyMap, setText, setVisible, toStringMethods inherited from class com.vaadin.flow.dom.Node
accept, appendChild, appendChild, appendVirtualChild, appendVirtualChild, ensureChildHasParent, equals, getNode, getParentNode, getStateProvider, hashCode, indexOfChild, insertChild, insertChild, isVirtualChild, removeAllChildren, removeChild, removeChild, removeChild, removeVirtualChild, removeVirtualChild, setChild
-
Constructor Details
-
MaskElement
public MaskElement() -
MaskElement
Creates a mask with the given ID.- Parameters:
id- the ID for referencing this mask
-
-
Method Details
-
x
Sets the x coordinate of the mask area.Uses write-only optimization. Use
xRW(double)if you need to read the value back.- Parameters:
x- the x coordinate- Returns:
- this element for method chaining
-
x
Sets the x coordinate with a unit.Uses write-only optimization. Use
xRW(String)if you need to read the value back.- Parameters:
x- the x coordinate (e.g., "-10%")- Returns:
- this element for method chaining
-
xRW
Sets the x coordinate of the mask area (read-write).- Parameters:
x- the x coordinate- Returns:
- this element for method chaining
-
xRW
Sets the x coordinate with a unit (read-write).- Parameters:
x- the x coordinate (e.g., "-10%")- Returns:
- this element for method chaining
-
y
Sets the y coordinate of the mask area.Uses write-only optimization. Use
yRW(double)if you need to read the value back.- Parameters:
y- the y coordinate- Returns:
- this element for method chaining
-
y
Sets the y coordinate with a unit.Uses write-only optimization. Use
yRW(String)if you need to read the value back.- Parameters:
y- the y coordinate (e.g., "-10%")- Returns:
- this element for method chaining
-
yRW
Sets the y coordinate of the mask area (read-write).- Parameters:
y- the y coordinate- Returns:
- this element for method chaining
-
yRW
Sets the y coordinate with a unit (read-write).- Parameters:
y- the y coordinate (e.g., "-10%")- Returns:
- this element for method chaining
-
width
Sets the width of the mask area.Uses write-only optimization. Use
widthRW(double)if you need to read the value back.- Overrides:
widthin classSvgElement- Parameters:
width- the width- Returns:
- this element for method chaining
-
width
Sets the width with a unit.Uses write-only optimization. Use
widthRW(String)if you need to read the value back.- Overrides:
widthin classSvgElement- Parameters:
width- the width (e.g., "120%")- Returns:
- this element for method chaining
-
widthRW
Sets the width of the mask area (read-write).- Parameters:
width- the width- Returns:
- this element for method chaining
-
widthRW
Sets the width with a unit (read-write).- Parameters:
width- the width (e.g., "120%")- Returns:
- this element for method chaining
-
height
Sets the height of the mask area.Uses write-only optimization. Use
heightRW(double)if you need to read the value back.- Overrides:
heightin classSvgElement- Parameters:
height- the height- Returns:
- this element for method chaining
-
height
Sets the height with a unit.Uses write-only optimization. Use
heightRW(String)if you need to read the value back.- Overrides:
heightin classSvgElement- Parameters:
height- the height (e.g., "120%")- Returns:
- this element for method chaining
-
heightRW
Sets the height of the mask area (read-write).- Parameters:
height- the height- Returns:
- this element for method chaining
-
heightRW
Sets the height with a unit (read-write).- Parameters:
height- the height (e.g., "120%")- Returns:
- this element for method chaining
-
bounds
Sets the bounds of the mask area.Uses write-only optimization. Use
boundsRW(double, double, double, double)if you need to read the values back.- Parameters:
x- the x coordinatey- the y coordinatewidth- the widthheight- the height- Returns:
- this element for method chaining
-
boundsRW
Sets the bounds of the mask area (read-write).- Parameters:
x- the x coordinatey- the y coordinatewidth- the widthheight- the height- Returns:
- this element for method chaining
-
maskUnits
Sets the coordinate system for x, y, width, height attributes.Uses write-only optimization. Use
maskUnitsRW(MaskUnits)if you need to read the value back.- Parameters:
units- the mask units- Returns:
- this element for method chaining
-
maskUnitsRW
Sets the coordinate system for x, y, width, height attributes (read-write).- Parameters:
units- the mask units- Returns:
- this element for method chaining
-
maskContentUnits
Sets the coordinate system for the mask contents.Uses write-only optimization. Use
maskContentUnitsRW(MaskUnits)if you need to read the value back.- Parameters:
units- the mask content units- Returns:
- this element for method chaining
-
maskContentUnitsRW
Sets the coordinate system for the mask contents (read-write).- Parameters:
units- the mask content units- Returns:
- this element for method chaining
-
add
Adds content elements to this mask.White areas in the mask content will be fully visible, black areas will be fully transparent, and gray areas will be partially transparent.
- Parameters:
elements- the elements that define the mask- Returns:
- this element for method chaining
-