Class ImageElement
- All Implemented Interfaces:
Serializable
<image> element.
The <image> element includes images inside SVG documents.
It can display raster image files (PNG, JPEG) or other SVG files.
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
ConstructorsConstructorDescriptionImageElement(String href) Creates an image element with the given href.ImageElement(String href, double x, double y, double width, double height) Creates an image element with position and size. -
Method Summary
Modifier and TypeMethodDescriptionbounds(double x, double y, double width, double height) Sets the bounds of the image (position and size).boundsRW(double x, double y, double width, double height) Sets the bounds of the image (position and size) (read-write).crossorigin(String crossorigin) Sets the crossorigin attribute for CORS requests.crossoriginRW(String crossorigin) Sets the crossorigin attribute for CORS requests (read-write).height(double height) Sets the height of the image.Sets the height with a unit.heightRW(double height) Sets the height of the image (read-write).Sets the height with a unit (read-write).Sets the URL of the image.Sets the URL of the image (read-write).position(double x, double y) Sets the position of the image.positionRW(double x, double y) Sets the position of the image (read-write).preserveAspectRatio(String preserveAspectRatio) Sets how the image should be scaled to fit.Sets how the image should be scaled to fit.preserveAspectRatioRW(String preserveAspectRatio) Sets how the image should be scaled to fit (read-write).Sets how the image should be scaled to fit (read-write).size(double width, double height) Sets the size of the image.sizeRW(double width, double height) Sets the size of the image (read-write).width(double width) Sets the width of the image.Sets the width with a unit.widthRW(double width) Sets the width of the image (read-write).Sets the width with a unit (read-write).x(double x) Sets the x coordinate of the image.Sets the x coordinate with a unit.xRW(double x) Sets the x coordinate of the image (read-write).Sets the x coordinate with a unit (read-write).y(double y) Sets the y coordinate of the image.Sets the y coordinate with a unit.yRW(double y) Sets the y coordinate of the image (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, 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
-
ImageElement
public ImageElement() -
ImageElement
Creates an image element with the given href.- Parameters:
href- the URL of the image
-
ImageElement
Creates an image element with position and size.- Parameters:
href- the URL of the imagex- the x coordinatey- the y coordinatewidth- the widthheight- the height
-
-
Method Details
-
href
Sets the URL of the image.Uses write-only optimization. Use
hrefRW(String)if you need to read the value back.- Parameters:
href- the image URL- Returns:
- this element for method chaining
-
hrefRW
Sets the URL of the image (read-write).- Parameters:
href- the image URL- Returns:
- this element for method chaining
-
x
Sets the x coordinate of the image.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 image (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 image.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 image (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 image.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., "100%", "200px")- Returns:
- this element for method chaining
-
widthRW
Sets the width of the image (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., "100%", "200px")- Returns:
- this element for method chaining
-
height
Sets the height of the image.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., "100%", "200px")- Returns:
- this element for method chaining
-
heightRW
Sets the height of the image (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., "100%", "200px")- Returns:
- this element for method chaining
-
position
Sets the position of the image.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 image (read-write).- Parameters:
x- the x coordinatey- the y coordinate- Returns:
- this element for method chaining
-
size
Sets the size of the image.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 image (read-write).- Parameters:
width- the widthheight- the height- Returns:
- this element for method chaining
-
bounds
Sets the bounds of the image (position and size).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 image (position and size) (read-write).- Parameters:
x- the x coordinatey- the y coordinatewidth- the widthheight- the height- Returns:
- this element for method chaining
-
preserveAspectRatio
Sets how the image should be scaled to fit.Uses write-only optimization. Use
preserveAspectRatioRW(String)if you need to read the value back.- Overrides:
preserveAspectRatioin classSvgElement- Parameters:
preserveAspectRatio- the preserveAspectRatio value (e.g., "xMidYMid meet")- Returns:
- this element for method chaining
-
preserveAspectRatioRW
Sets how the image should be scaled to fit (read-write).- Parameters:
preserveAspectRatio- the preserveAspectRatio value (e.g., "xMidYMid meet")- Returns:
- this element for method chaining
-
preserveAspectRatio
Sets how the image should be scaled to fit.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 how the image should be scaled to fit (read-write).- Parameters:
ratio- the preserveAspectRatio setting- Returns:
- this element for method chaining
-
crossorigin
Sets the crossorigin attribute for CORS requests.Uses write-only optimization. Use
crossoriginRW(String)if you need to read the value back.- Parameters:
crossorigin- the crossorigin value ("anonymous" or "use-credentials")- Returns:
- this element for method chaining
-
crossoriginRW
Sets the crossorigin attribute for CORS requests (read-write).- Parameters:
crossorigin- the crossorigin value ("anonymous" or "use-credentials")- Returns:
- this element for method chaining
-