Class UseElement
- All Implemented Interfaces:
Serializable
<use> element.
The <use> element takes nodes from within the SVG document and
duplicates them somewhere else. The effect is the same as if the nodes
were deeply cloned and then pasted where the <use> element is.
The <use> element has optional attributes x, y, width and height
which define the position and size of the referenced element.
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 classes/interfaces inherited from class SvgGraphicsElement
SvgGraphicsElement.LineCap, SvgGraphicsElement.LineJoinNested classes/interfaces inherited from class SvgElement
SvgElement.PreserveAspectRatio -
Constructor Summary
ConstructorsConstructorDescriptionUseElement(SvgElement element) Creates a use element referencing the given element. -
Method Summary
Modifier and TypeMethodDescriptionheight(double height) Sets the height of the use element.Sets the height with a unit.heightRW(double height) Sets the height of the use element (read-write).Sets the height with a unit (read-write).Sets the href attribute to reference another element by ID.Sets the href attribute to reference another element by ID (read-write).position(double x, double y) Sets the position of the use element.positionRW(double x, double y) Sets the position of the use element (read-write).ref(SvgElement element) Sets the reference to the given element.size(double width, double height) Sets the size of the use element.sizeRW(double width, double height) Sets the size of the use element (read-write).width(double width) Sets the width of the use element.Sets the width with a unit.widthRW(double width) Sets the width of the use element (read-write).Sets the width with a unit (read-write).x(double x) Sets the x coordinate where the referenced element will be placed.Sets the x coordinate with a unit.xRW(double x) Sets the x coordinate where the referenced element will be placed (read-write).Sets the x coordinate with a unit (read-write).y(double y) Sets the y coordinate where the referenced element will be placed.Sets the y coordinate with a unit.yRW(double y) Sets the y coordinate where the referenced element will be placed (read-write).Sets the y coordinate with a unit (read-write).Methods inherited from class SvgGraphicsElement
clearTransform, clipPath, clipPathRW, fill, fill, fill, fill, fill, fillOpacity, fillOpacityRW, fillRW, fillRW, fillRW, fillRW, fillRW, mask, maskRW, matrix, matrixRW, noFill, noFillRW, noStroke, noStrokeRW, opacity, opacityRW, rotate, rotate, rotateRW, rotateRW, scale, scale, scaleRW, scaleRW, skewX, skewXRW, skewY, skewYRW, stroke, stroke, stroke, stroke, stroke, strokeDasharray, strokeDasharray, strokeDasharrayRW, strokeDasharrayRW, strokeDashoffset, strokeDashoffsetRW, strokeLinecap, strokeLinecapRW, strokeLinejoin, strokeLinejoinRW, strokeMiterlimit, strokeMiterlimitRW, strokeOpacity, strokeOpacityRW, strokeRW, strokeRW, strokeRW, strokeRW, strokeRW, strokeWidth, strokeWidth, strokeWidthRW, strokeWidthRW, transform, transformRW, translate, translateRW, translateX, translateXRW, translateY, translateYRWMethods inherited from class SvgElement
emptySvgRoot, flushPendingAttributes, getOuterHTML, getPendingOrAttribute, getStyle, id, preserveAspectRatio, preserveAspectRatio, scheduleBeforeClientResponse, setAttribute, setWriteOnlyAttribute, 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
-
UseElement
public UseElement() -
UseElement
Creates a use element referencing the given element. An ID is automatically generated for the referenced element if not already set.- Parameters:
element- the element to reference (typically a SymbolElement)
-
-
Method Details
-
ref
Sets the reference to the given element. An ID is automatically generated for the referenced element if not already set.Note: This method uses read-write approach to ensure ID is properly set.
- Parameters:
element- the element to reference- Returns:
- this element for method chaining
-
href
Sets the href attribute to reference another element by ID.Uses write-only optimization. Use
hrefRW(String)if you need to read the value back.- Parameters:
href- the reference URL (e.g., "#myElement" or "sprites.svg#icon")- Returns:
- this element for method chaining
-
hrefRW
Sets the href attribute to reference another element by ID (read-write).- Parameters:
href- the reference URL (e.g., "#myElement" or "sprites.svg#icon")- Returns:
- this element for method chaining
-
x
Sets the x coordinate where the referenced element will be placed.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 with unit (e.g., "10%", "50px")- Returns:
- this element for method chaining
-
xRW
Sets the x coordinate where the referenced element will be placed (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 with unit (e.g., "10%", "50px")- Returns:
- this element for method chaining
-
y
Sets the y coordinate where the referenced element will be placed.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 with unit (e.g., "10%", "50px")- Returns:
- this element for method chaining
-
yRW
Sets the y coordinate where the referenced element will be placed (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 with unit (e.g., "10%", "50px")- Returns:
- this element for method chaining
-
width
Sets the width of the use element.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 with unit (e.g., "100%", "200px")- Returns:
- this element for method chaining
-
widthRW
Sets the width of the use element (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 with unit (e.g., "100%", "200px")- Returns:
- this element for method chaining
-
height
Sets the height of the use element.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 with unit (e.g., "100%", "200px")- Returns:
- this element for method chaining
-
heightRW
Sets the height of the use element (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 with unit (e.g., "100%", "200px")- Returns:
- this element for method chaining
-
position
Sets the position of the use element.Uses write-only optimization. Use
positionRW(double, double)if you need to read the values back.- Parameters:
x- the x coordinatey- the y coordinate- Returns:
- this element for method chaining
-
positionRW
Sets the position of the use element (read-write).- Parameters:
x- the x coordinatey- the y coordinate- Returns:
- this element for method chaining
-
size
Sets the size of the use element.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 use element (read-write).- Parameters:
width- the widthheight- the height- Returns:
- this element for method chaining
-