Class PatternElement
- All Implemented Interfaces:
Serializable
<pattern> element.
The <pattern> element defines a repeating pattern that can be used
as a fill or stroke for other SVG elements. The pattern is defined by its
contents and is tiled to fill the target area.
Patterns must be placed inside a <defs> element and referenced
by ID (e.g., fill="url(#myPattern)").
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 pattern.height(double height) Sets the height of the pattern tile.Sets the height with a unit.heightRW(double height) Sets the height of the pattern tile (read-write).Sets the height with a unit (read-write).References another pattern to inherit attributes from.References another pattern to inherit attributes from (read-write).Sets the coordinate system for the pattern contents.Sets the coordinate system for the pattern contents (read-write).patternTransform(String transform) Sets a transform on the pattern.patternTransformRW(String transform) Sets a transform on the pattern (read-write).Sets the coordinate system for x, y, width, height attributes.Sets the coordinate system for x, y, width, height attributes (read-write).preserveAspectRatio(String value) Sets the preserveAspectRatio attribute.Sets the preserveAspectRatio attribute.preserveAspectRatioRW(String value) Sets the preserveAspectRatio attribute (read-write).Sets the preserveAspectRatio attribute (read-write).size(double width, double height) Sets the size of the pattern tile.sizeRW(double width, double height) Sets the size of the pattern tile (read-write).viewBox(double minX, double minY, double width, double height) Sets the viewBox for the pattern contents.viewBoxRW(double minX, double minY, double width, double height) Sets the viewBox for the pattern contents (read-write).width(double width) Sets the width of the pattern tile.Sets the width with a unit.widthRW(double width) Sets the width of the pattern tile (read-write).Sets the width with a unit (read-write).x(double x) Sets the x coordinate of the pattern tile.xRW(double x) Sets the x coordinate of the pattern tile (read-write).y(double y) Sets the y coordinate of the pattern tile.yRW(double y) Sets the y coordinate of the pattern tile (read-write).Methods inherited from class SvgElement
emptySvgRoot, flushPendingAttributes, getOuterHTML, getPendingOrAttribute, getStyle, id, scheduleBeforeClientResponse, setAttribute, setWriteOnlyAttribute, sizeMethods 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
-
PatternElement
public PatternElement() -
PatternElement
Creates a pattern with the given ID.- Parameters:
id- the ID for referencing this pattern
-
-
Method Details
-
x
Sets the x coordinate of the pattern tile.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
-
xRW
Sets the x coordinate of the pattern tile (read-write).- Parameters:
x- the x coordinate- Returns:
- this element for method chaining
-
y
Sets the y coordinate of the pattern tile.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
-
yRW
Sets the y coordinate of the pattern tile (read-write).- Parameters:
y- the y coordinate- Returns:
- this element for method chaining
-
width
Sets the width of the pattern tile.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., "10%", "20px")- Returns:
- this element for method chaining
-
widthRW
Sets the width of the pattern tile (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., "10%", "20px")- Returns:
- this element for method chaining
-
height
Sets the height of the pattern tile.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., "10%", "20px")- Returns:
- this element for method chaining
-
heightRW
Sets the height of the pattern tile (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., "10%", "20px")- Returns:
- this element for method chaining
-
size
Sets the size of the pattern tile.Uses write-only optimization. Use
sizeRW(double, double)if you need to read the values back.- Overrides:
sizein classSvgElement- Parameters:
width- the widthheight- the height- Returns:
- this element for method chaining
-
sizeRW
Sets the size of the pattern tile (read-write).- Parameters:
width- the widthheight- the height- Returns:
- this element for method chaining
-
viewBox
Sets the viewBox for the pattern contents.Uses write-only optimization. Use
viewBoxRW(double, double, double, double)if you need to read the value back.- Overrides:
viewBoxin classSvgElement- Parameters:
minX- the minimum x valueminY- the minimum y valuewidth- the widthheight- the height- Returns:
- this element for method chaining
-
viewBoxRW
Sets the viewBox for the pattern contents (read-write).- Parameters:
minX- the minimum x valueminY- the minimum y valuewidth- the widthheight- the height- Returns:
- this element for method chaining
-
patternUnits
Sets the coordinate system for x, y, width, height attributes.Uses write-only optimization. Use
patternUnitsRW(PatternUnits)if you need to read the value back.- Parameters:
units- the pattern units- Returns:
- this element for method chaining
-
patternUnitsRW
Sets the coordinate system for x, y, width, height attributes (read-write).- Parameters:
units- the pattern units- Returns:
- this element for method chaining
-
patternContentUnits
Sets the coordinate system for the pattern contents.Uses write-only optimization. Use
patternContentUnitsRW(PatternUnits)if you need to read the value back.- Parameters:
units- the pattern content units- Returns:
- this element for method chaining
-
patternContentUnitsRW
Sets the coordinate system for the pattern contents (read-write).- Parameters:
units- the pattern content units- Returns:
- this element for method chaining
-
patternTransform
Sets a transform on the pattern.Uses write-only optimization. Use
patternTransformRW(String)if you need to read the value back.- Parameters:
transform- the transform string- Returns:
- this element for method chaining
-
patternTransformRW
Sets a transform on the pattern (read-write).- Parameters:
transform- the transform string- Returns:
- this element for method chaining
-
href
References another pattern to inherit attributes from.Uses write-only optimization. Use
hrefRW(String)if you need to read the value back.- Parameters:
href- the reference (e.g., "#otherPattern")- Returns:
- this element for method chaining
-
hrefRW
References another pattern to inherit attributes from (read-write).- Parameters:
href- the reference (e.g., "#otherPattern")- Returns:
- this element for method chaining
-
preserveAspectRatio
Sets the preserveAspectRatio attribute.Uses write-only optimization. Use
preserveAspectRatioRW(String)if you need to read the value back.- Overrides:
preserveAspectRatioin classSvgElement- Parameters:
value- the preserveAspectRatio value- Returns:
- this element for method chaining
-
preserveAspectRatioRW
Sets the preserveAspectRatio attribute (read-write).- Parameters:
value- the preserveAspectRatio value- Returns:
- this element for method chaining
-
preserveAspectRatio
Sets the preserveAspectRatio attribute.Uses write-only optimization. Use
preserveAspectRatioRW(PreserveAspectRatio)if you need to read the value back.- Overrides:
preserveAspectRatioin classSvgElement- Parameters:
ratio- the preserveAspectRatio setting- Returns:
- this element for method chaining
-
preserveAspectRatioRW
Sets the preserveAspectRatio attribute (read-write).- Parameters:
ratio- the preserveAspectRatio setting- Returns:
- this element for method chaining
-
add
Adds content elements to this pattern.- Parameters:
elements- the elements that define the pattern- Returns:
- this element for method chaining
-