Class PathElement
- All Implemented Interfaces:
Serializable
<path> element.
The <path> element is the generic element to define a shape.
All basic shapes can be created with a path element.
Use the d(String) method to set the path data directly, or use
the fluent path builder methods like moveTo(double, double),
lineTo(double, double), etc.
Write-Only vs Read-Write Methods
This class provides two variants for attribute setters:
- Default methods (e.g.,
d(),pathLength()) - Use an optimized write-only approach. Attribute values are NOT stored on the server and cannot be retrieved viagetAttribute(). - RW methods (e.g.,
dRW(),pathLengthRW()) - 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 TypeMethodDescriptionarcTo(double rx, double ry, double xAxisRotation, boolean largeArcFlag, boolean sweepFlag, double x, double y) Draw an elliptical arc (absolute coordinates).arcToRelative(double rx, double ry, double xAxisRotation, boolean largeArcFlag, boolean sweepFlag, double dx, double dy) Draw an elliptical arc (relative coordinates).clear()Clears the currently scheduled drawing commands.Close the current path by drawing a straight line back to the start.cubicBezierTo(double x1, double y1, double x2, double y2, double x, double y) Draw a cubic Bézier curve (absolute coordinates).cubicBezierToRelative(double dx1, double dy1, double dx2, double dy2, double dx, double dy) Draw a cubic Bézier curve (relative coordinates).Sets the path data directly.Sets the path data directly (read-write).protected voidhorizontalLineTo(double x) Draw a horizontal line to the specified x coordinate (absolute).horizontalLineToRelative(double dx) Draw a horizontal line by the specified offset (relative).lineTo(double x, double y) Draw a line to the specified point (absolute coordinates).lineToRelative(double dx, double dy) Draw a line to the specified point (relative coordinates).moveTo(double x, double y) Move to the specified point (absolute coordinates).moveToRelative(double dx, double dy) Move to the specified point (relative coordinates).pathLength(double pathLength) Sets the total length for the path in user units.pathLengthRW(double pathLength) Sets the total length for the path in user units (read-write).quadraticBezierTo(double x1, double y1, double x, double y) Draw a quadratic Bézier curve (absolute coordinates).quadraticBezierToRelative(double dx1, double dy1, double dx, double dy) Draw a quadratic Bézier curve (relative coordinates).smoothCubicBezierTo(double x2, double y2, double x, double y) Draw a smooth cubic Bézier curve (absolute coordinates).smoothCubicBezierToRelative(double dx2, double dy2, double dx, double dy) Draw a smooth cubic Bézier curve (relative coordinates).smoothQuadraticBezierTo(double x, double y) Draw a smooth quadratic Bézier curve (absolute coordinates).smoothQuadraticBezierToRelative(double dx, double dy) Draw a smooth quadratic Bézier curve (relative coordinates).verticalLineTo(double y) Draw a vertical line to the specified y coordinate (absolute).verticalLineToRelative(double dy) Draw a vertical line by the specified offset (relative).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, 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
-
PathElement
public PathElement()
-
-
Method Details
-
d
Sets the path data directly.This replaces any path data built using the fluent methods.
Uses write-only optimization. Use
dRW(String)if you need to read the value back.- Parameters:
d- the path data string- Returns:
- this element for method chaining
-
dRW
Sets the path data directly (read-write).This replaces any path data built using the fluent methods.
- Parameters:
d- the path data string- Returns:
- this element for method chaining
-
clear
Clears the currently scheduled drawing commands.- Returns:
- this element for method chaining
-
pathLength
Sets the total length for the path in user units.Uses write-only optimization. Use
pathLengthRW(double)if you need to read the value back.- Parameters:
pathLength- the total path length- Returns:
- this element for method chaining
-
pathLengthRW
Sets the total length for the path in user units (read-write).- Parameters:
pathLength- the total path length- Returns:
- this element for method chaining
-
moveTo
Move to the specified point (absolute coordinates).Equivalent to the "M" command.
- Parameters:
x- the x coordinatey- the y coordinate- Returns:
- this element for method chaining
-
moveToRelative
Move to the specified point (relative coordinates).Equivalent to the "m" command.
- Parameters:
dx- the relative x offsetdy- the relative y offset- Returns:
- this element for method chaining
-
lineTo
Draw a line to the specified point (absolute coordinates).Equivalent to the "L" command.
- Parameters:
x- the x coordinatey- the y coordinate- Returns:
- this element for method chaining
-
lineToRelative
Draw a line to the specified point (relative coordinates).Equivalent to the "l" command.
- Parameters:
dx- the relative x offsetdy- the relative y offset- Returns:
- this element for method chaining
-
horizontalLineTo
Draw a horizontal line to the specified x coordinate (absolute).Equivalent to the "H" command.
- Parameters:
x- the x coordinate- Returns:
- this element for method chaining
-
horizontalLineToRelative
Draw a horizontal line by the specified offset (relative).Equivalent to the "h" command.
- Parameters:
dx- the relative x offset- Returns:
- this element for method chaining
-
verticalLineTo
Draw a vertical line to the specified y coordinate (absolute).Equivalent to the "V" command.
- Parameters:
y- the y coordinate- Returns:
- this element for method chaining
-
verticalLineToRelative
Draw a vertical line by the specified offset (relative).Equivalent to the "v" command.
- Parameters:
dy- the relative y offset- Returns:
- this element for method chaining
-
closePath
Close the current path by drawing a straight line back to the start.Equivalent to the "Z" or "z" command.
- Returns:
- this element for method chaining
-
cubicBezierTo
Draw a cubic Bézier curve (absolute coordinates).Equivalent to the "C" command.
- Parameters:
x1- x coordinate of the first control pointy1- y coordinate of the first control pointx2- x coordinate of the second control pointy2- y coordinate of the second control pointx- x coordinate of the end pointy- y coordinate of the end point- Returns:
- this element for method chaining
-
cubicBezierToRelative
public PathElement cubicBezierToRelative(double dx1, double dy1, double dx2, double dy2, double dx, double dy) Draw a cubic Bézier curve (relative coordinates).Equivalent to the "c" command.
- Parameters:
dx1- relative x offset of the first control pointdy1- relative y offset of the first control pointdx2- relative x offset of the second control pointdy2- relative y offset of the second control pointdx- relative x offset of the end pointdy- relative y offset of the end point- Returns:
- this element for method chaining
-
smoothCubicBezierTo
Draw a smooth cubic Bézier curve (absolute coordinates).Equivalent to the "S" command. The first control point is assumed to be the reflection of the second control point of the previous command.
- Parameters:
x2- x coordinate of the second control pointy2- y coordinate of the second control pointx- x coordinate of the end pointy- y coordinate of the end point- Returns:
- this element for method chaining
-
smoothCubicBezierToRelative
Draw a smooth cubic Bézier curve (relative coordinates).Equivalent to the "s" command.
- Parameters:
dx2- relative x offset of the second control pointdy2- relative y offset of the second control pointdx- relative x offset of the end pointdy- relative y offset of the end point- Returns:
- this element for method chaining
-
quadraticBezierTo
Draw a quadratic Bézier curve (absolute coordinates).Equivalent to the "Q" command.
- Parameters:
x1- x coordinate of the control pointy1- y coordinate of the control pointx- x coordinate of the end pointy- y coordinate of the end point- Returns:
- this element for method chaining
-
quadraticBezierToRelative
Draw a quadratic Bézier curve (relative coordinates).Equivalent to the "q" command.
- Parameters:
dx1- relative x offset of the control pointdy1- relative y offset of the control pointdx- relative x offset of the end pointdy- relative y offset of the end point- Returns:
- this element for method chaining
-
smoothQuadraticBezierTo
Draw a smooth quadratic Bézier curve (absolute coordinates).Equivalent to the "T" command. The control point is assumed to be the reflection of the control point of the previous command.
- Parameters:
x- x coordinate of the end pointy- y coordinate of the end point- Returns:
- this element for method chaining
-
smoothQuadraticBezierToRelative
Draw a smooth quadratic Bézier curve (relative coordinates).Equivalent to the "t" command.
- Parameters:
dx- relative x offset of the end pointdy- relative y offset of the end point- Returns:
- this element for method chaining
-
arcTo
public PathElement arcTo(double rx, double ry, double xAxisRotation, boolean largeArcFlag, boolean sweepFlag, double x, double y) Draw an elliptical arc (absolute coordinates).Equivalent to the "A" command.
- Parameters:
rx- x radius of the ellipsery- y radius of the ellipsexAxisRotation- rotation of the ellipse in degreeslargeArcFlag- if true, draw the larger arcsweepFlag- if true, draw the arc in positive angle directionx- x coordinate of the end pointy- y coordinate of the end point- Returns:
- this element for method chaining
-
arcToRelative
public PathElement arcToRelative(double rx, double ry, double xAxisRotation, boolean largeArcFlag, boolean sweepFlag, double dx, double dy) Draw an elliptical arc (relative coordinates).Equivalent to the "a" command.
- Parameters:
rx- x radius of the ellipsery- y radius of the ellipsexAxisRotation- rotation of the ellipse in degreeslargeArcFlag- if true, draw the larger arcsweepFlag- if true, draw the arc in positive angle directiondx- relative x offset of the end pointdy- relative y offset of the end point- Returns:
- this element for method chaining
-
flushPendingAttributes
protected void flushPendingAttributes()- Overrides:
flushPendingAttributesin classSvgElement
-