Class LineElement
- All Implemented Interfaces:
Serializable
<line> element.
The <line> element is a basic SVG shape that draws a straight line
connecting two points.
Note: A line element must have a stroke color specified to be visible, as lines have no fill.
Write-Only vs Read-Write Methods
This class provides two variants for each attribute setter:
- Default methods (e.g.,
x1(),y1()) - Use an optimized write-only approach. Attribute values are NOT stored on the server and cannot be retrieved viagetAttribute(). - RW methods (e.g.,
x1RW(),y1RW()) - 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfrom(double x1, double y1) Convenience method to set the starting point (x1, y1) at once.Convenience method to set the starting point with strings (supports units/percentages).fromRW(double x1, double y1) Convenience method to set the starting point (x1, y1) at once (read-write).Convenience method to set the starting point with strings (read-write).pathLength(double pathLength) Sets the total length for the line's path in user units.pathLengthRW(double pathLength) Sets the total length for the line's path in user units (read-write).points(double x1, double y1, double x2, double y2) Convenience method to set both start and end points at once.pointsRW(double x1, double y1, double x2, double y2) Convenience method to set both start and end points at once (read-write).to(double x2, double y2) Convenience method to set the ending point (x2, y2) at once.Convenience method to set the ending point with strings (supports units/percentages).toRW(double x2, double y2) Convenience method to set the ending point (x2, y2) at once (read-write).Convenience method to set the ending point with strings (read-write).x1(double x1) Sets the x-axis coordinate of the line starting point.Sets the x-axis coordinate of the line starting point with a unit or percentage.x1RW(double x1) Sets the x-axis coordinate of the line starting point (read-write).Sets the x-axis coordinate of the line starting point with a unit or percentage (read-write).x2(double x2) Sets the x-axis coordinate of the line ending point.Sets the x-axis coordinate of the line ending point with a unit or percentage.x2RW(double x2) Sets the x-axis coordinate of the line ending point (read-write).Sets the x-axis coordinate of the line ending point with a unit or percentage (read-write).y1(double y1) Sets the y-axis coordinate of the line starting point.Sets the y-axis coordinate of the line starting point with a unit or percentage.y1RW(double y1) Sets the y-axis coordinate of the line starting point (read-write).Sets the y-axis coordinate of the line starting point with a unit or percentage (read-write).y2(double y2) Sets the y-axis coordinate of the line ending point.Sets the y-axis coordinate of the line ending point with a unit or percentage.y2RW(double y2) Sets the y-axis coordinate of the line ending point (read-write).Sets the y-axis coordinate of the line ending point with a unit or percentage (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, height, height, id, preserveAspectRatio, preserveAspectRatio, scheduleBeforeClientResponse, setAttribute, setWriteOnlyAttribute, size, size, viewBox, width, widthMethods 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
-
LineElement
public LineElement()
-
-
Method Details
-
x1
Sets the x-axis coordinate of the line starting point.Uses write-only optimization. The value is NOT stored on the server. Use
x1RW(double)if you need to read the value back.- Parameters:
x1- the x coordinate of the start point in user units- Returns:
- this element for method chaining
-
x1
Sets the x-axis coordinate of the line starting point with a unit or percentage.Uses write-only optimization. The value is NOT stored on the server. Use
x1RW(String)if you need to read the value back.- Parameters:
x1- the x coordinate of the start point (e.g., "10", "10%", "10px")- Returns:
- this element for method chaining
-
x1RW
Sets the x-axis coordinate of the line starting point (read-write).Uses
SvgElement.setAttribute(String, String)so the value can be retrieved viaElement.getAttribute(String).- Parameters:
x1- the x coordinate of the start point in user units- Returns:
- this element for method chaining
-
x1RW
Sets the x-axis coordinate of the line starting point with a unit or percentage (read-write).Uses
SvgElement.setAttribute(String, String)so the value can be retrieved viaElement.getAttribute(String).- Parameters:
x1- the x coordinate of the start point (e.g., "10", "10%", "10px")- Returns:
- this element for method chaining
-
y1
Sets the y-axis coordinate of the line starting point.Uses write-only optimization. The value is NOT stored on the server. Use
y1RW(double)if you need to read the value back.- Parameters:
y1- the y coordinate of the start point in user units- Returns:
- this element for method chaining
-
y1
Sets the y-axis coordinate of the line starting point with a unit or percentage.Uses write-only optimization. The value is NOT stored on the server. Use
y1RW(String)if you need to read the value back.- Parameters:
y1- the y coordinate of the start point (e.g., "10", "10%", "10px")- Returns:
- this element for method chaining
-
y1RW
Sets the y-axis coordinate of the line starting point (read-write).Uses
SvgElement.setAttribute(String, String)so the value can be retrieved viaElement.getAttribute(String).- Parameters:
y1- the y coordinate of the start point in user units- Returns:
- this element for method chaining
-
y1RW
Sets the y-axis coordinate of the line starting point with a unit or percentage (read-write).Uses
SvgElement.setAttribute(String, String)so the value can be retrieved viaElement.getAttribute(String).- Parameters:
y1- the y coordinate of the start point (e.g., "10", "10%", "10px")- Returns:
- this element for method chaining
-
x2
Sets the x-axis coordinate of the line ending point.Uses write-only optimization. The value is NOT stored on the server. Use
x2RW(double)if you need to read the value back.- Parameters:
x2- the x coordinate of the end point in user units- Returns:
- this element for method chaining
-
x2
Sets the x-axis coordinate of the line ending point with a unit or percentage.Uses write-only optimization. The value is NOT stored on the server. Use
x2RW(String)if you need to read the value back.- Parameters:
x2- the x coordinate of the end point (e.g., "90", "90%", "90px")- Returns:
- this element for method chaining
-
x2RW
Sets the x-axis coordinate of the line ending point (read-write).Uses
SvgElement.setAttribute(String, String)so the value can be retrieved viaElement.getAttribute(String).- Parameters:
x2- the x coordinate of the end point in user units- Returns:
- this element for method chaining
-
x2RW
Sets the x-axis coordinate of the line ending point with a unit or percentage (read-write).Uses
SvgElement.setAttribute(String, String)so the value can be retrieved viaElement.getAttribute(String).- Parameters:
x2- the x coordinate of the end point (e.g., "90", "90%", "90px")- Returns:
- this element for method chaining
-
y2
Sets the y-axis coordinate of the line ending point.Uses write-only optimization. The value is NOT stored on the server. Use
y2RW(double)if you need to read the value back.- Parameters:
y2- the y coordinate of the end point in user units- Returns:
- this element for method chaining
-
y2
Sets the y-axis coordinate of the line ending point with a unit or percentage.Uses write-only optimization. The value is NOT stored on the server. Use
y2RW(String)if you need to read the value back.- Parameters:
y2- the y coordinate of the end point (e.g., "90", "90%", "90px")- Returns:
- this element for method chaining
-
y2RW
Sets the y-axis coordinate of the line ending point (read-write).Uses
SvgElement.setAttribute(String, String)so the value can be retrieved viaElement.getAttribute(String).- Parameters:
y2- the y coordinate of the end point in user units- Returns:
- this element for method chaining
-
y2RW
Sets the y-axis coordinate of the line ending point with a unit or percentage (read-write).Uses
SvgElement.setAttribute(String, String)so the value can be retrieved viaElement.getAttribute(String).- Parameters:
y2- the y coordinate of the end point (e.g., "90", "90%", "90px")- Returns:
- this element for method chaining
-
pathLength
Sets the total length for the line's path in user units.This value is used to calibrate the browser's distance calculations with those of the author, by scaling all distance computations using the ratio pathLength / (computed value of path length).
Uses write-only optimization. The value is NOT stored on the server. Use
pathLengthRW(double)if you need to read the value back.- Parameters:
pathLength- the total path length in user units- Returns:
- this element for method chaining
-
pathLengthRW
Sets the total length for the line's path in user units (read-write).Uses
SvgElement.setAttribute(String, String)so the value can be retrieved viaElement.getAttribute(String).- Parameters:
pathLength- the total path length in user units- Returns:
- this element for method chaining
-
from
Convenience method to set the starting point (x1, y1) at once.Uses write-only optimization. Use
fromRW(double, double)if you need to read the values back.- Parameters:
x1- the x coordinate of the start point in user unitsy1- the y coordinate of the start point in user units- Returns:
- this element for method chaining
-
from
Convenience method to set the starting point with strings (supports units/percentages).Uses write-only optimization. Use
fromRW(String, String)if you need to read the values back.- Parameters:
x1- the x coordinate of the start point (e.g., "10%")y1- the y coordinate of the start point (e.g., "10%")- Returns:
- this element for method chaining
-
fromRW
Convenience method to set the starting point (x1, y1) at once (read-write).- Parameters:
x1- the x coordinate of the start point in user unitsy1- the y coordinate of the start point in user units- Returns:
- this element for method chaining
-
fromRW
Convenience method to set the starting point with strings (read-write).- Parameters:
x1- the x coordinate of the start point (e.g., "10%")y1- the y coordinate of the start point (e.g., "10%")- Returns:
- this element for method chaining
-
to
Convenience method to set the ending point (x2, y2) at once.Uses write-only optimization. Use
toRW(double, double)if you need to read the values back.- Parameters:
x2- the x coordinate of the end point in user unitsy2- the y coordinate of the end point in user units- Returns:
- this element for method chaining
-
to
Convenience method to set the ending point with strings (supports units/percentages).Uses write-only optimization. Use
toRW(String, String)if you need to read the values back.- Parameters:
x2- the x coordinate of the end point (e.g., "90%")y2- the y coordinate of the end point (e.g., "90%")- Returns:
- this element for method chaining
-
toRW
Convenience method to set the ending point (x2, y2) at once (read-write).- Parameters:
x2- the x coordinate of the end point in user unitsy2- the y coordinate of the end point in user units- Returns:
- this element for method chaining
-
toRW
Convenience method to set the ending point with strings (read-write).- Parameters:
x2- the x coordinate of the end point (e.g., "90%")y2- the y coordinate of the end point (e.g., "90%")- Returns:
- this element for method chaining
-
points
Convenience method to set both start and end points at once.Uses write-only optimization. Use
pointsRW(double, double, double, double)if you need to read the values back.- Parameters:
x1- the x coordinate of the start point in user unitsy1- the y coordinate of the start point in user unitsx2- the x coordinate of the end point in user unitsy2- the y coordinate of the end point in user units- Returns:
- this element for method chaining
-
pointsRW
Convenience method to set both start and end points at once (read-write).- Parameters:
x1- the x coordinate of the start point in user unitsy1- the y coordinate of the start point in user unitsx2- the x coordinate of the end point in user unitsy2- the y coordinate of the end point in user units- Returns:
- this element for method chaining
-