Class PolygonElement
java.lang.Object
com.vaadin.flow.dom.Node<com.vaadin.flow.dom.Element>
com.vaadin.flow.dom.Element
org.vaadin.firitin.element.svg.SvgElement
org.vaadin.firitin.element.svg.SvgGraphicsElement
org.vaadin.firitin.element.svg.PolygonElement
- All Implemented Interfaces:
Serializable
A typed Java API for the SVG
<polygon> element.
The <polygon> element defines a closed shape consisting of a set of
connected straight line segments. The last point is connected to the first point.
For an open shape (where the last point is not connected to the first), use a polyline element instead.
Write-Only vs Read-Write Methods
This class provides two variants for attribute setters:
- Default methods (e.g.,
points(),pathLength()) - Use an optimized write-only approach. Attribute values are NOT stored on the server and cannot be retrieved viagetAttribute(). - RW methods (e.g.,
pointsRW(),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 TypeMethodDescriptionaddPoint(double x, double y) Adds a point to the polygon.addPoints(double... coords) Adds multiple points to the polygon.Clears all points from the polygon.pathLength(double pathLength) Sets the total length for the polygon's perimeter in user units.pathLengthRW(double pathLength) Sets the total length for the polygon's perimeter in user units (read-write).points(double... coords) Sets the points from an array of coordinate pairs.Sets the points directly as a string.Sets the points directly as a string (read-write).regularPolygon(double cx, double cy, double radius, int sides) Creates a regular polygon with the specified number of sides.star(double cx, double cy, double outerRadius, double innerRadius, int points) Creates a star shape.triangle(double x1, double y1, double x2, double y2, double x3, double y3) Creates a triangle with the specified vertices.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
-
PolygonElement
public PolygonElement()
-
-
Method Details
-
points
Sets the points directly as a string.This replaces any points added using the fluent methods.
Uses write-only optimization. Use
pointsRW(String)if you need to read the value back.- Parameters:
points- the points string (e.g., "0,100 50,25 50,75 100,0")- Returns:
- this element for method chaining
-
pointsRW
Sets the points directly as a string (read-write).This replaces any points added using the fluent methods.
- Parameters:
points- the points string (e.g., "0,100 50,25 50,75 100,0")- Returns:
- this element for method chaining
-
points
Sets the points from an array of coordinate pairs.Each pair of values represents an x,y coordinate.
- Parameters:
coords- the coordinates as x1,y1,x2,y2,... sequence- Returns:
- this element for method chaining
-
addPoint
Adds a point to the polygon.- Parameters:
x- the x coordinatey- the y coordinate- Returns:
- this element for method chaining
-
addPoints
Adds multiple points to the polygon.- Parameters:
coords- the coordinates as x1,y1,x2,y2,... sequence- Returns:
- this element for method chaining
-
clearPoints
Clears all points from the polygon.- Returns:
- this element for method chaining
-
pathLength
Sets the total length for the polygon's perimeter 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 polygon's perimeter in user units (read-write).- Parameters:
pathLength- the total path length- Returns:
- this element for method chaining
-
regularPolygon
Creates a regular polygon with the specified number of sides.- Parameters:
cx- the x coordinate of the centercy- the y coordinate of the centerradius- the radius (distance from center to vertices)sides- the number of sides (minimum 3)- Returns:
- this element for method chaining
-
triangle
Creates a triangle with the specified vertices.- Parameters:
x1- x coordinate of first vertexy1- y coordinate of first vertexx2- x coordinate of second vertexy2- y coordinate of second vertexx3- x coordinate of third vertexy3- y coordinate of third vertex- Returns:
- this element for method chaining
-
star
public PolygonElement star(double cx, double cy, double outerRadius, double innerRadius, int points) Creates a star shape.- Parameters:
cx- the x coordinate of the centercy- the y coordinate of the centerouterRadius- the outer radius (to the points)innerRadius- the inner radius (to the inner corners)points- the number of points on the star (minimum 3)- Returns:
- this element for method chaining
-