Class RadialGradientElement

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.RadialGradientElement
All Implemented Interfaces:
Serializable

public class RadialGradientElement extends SvgElement
A typed Java API for the SVG <radialGradient> element.

The <radialGradient> element defines a radial gradient to be used as a fill or stroke for other SVG elements. The gradient radiates from a focal point to the edge of a circle.

Radial gradients must be placed inside a <defs> element and referenced by ID (e.g., fill="url(#myGradient)").

Write-Only vs Read-Write Methods

This class provides two variants for each attribute setter:

  • Default methods (e.g., cx(), cy()) - Use an optimized write-only approach. Attribute values are NOT stored on the server and cannot be retrieved via getAttribute().
  • RW methods (e.g., cxRW(), cyRW()) - Use traditional setAttribute() which stores values on the server for later retrieval.
See Also:
  • Constructor Details

    • RadialGradientElement

      public RadialGradientElement()
    • RadialGradientElement

      public RadialGradientElement(String id)
      Creates a radial gradient with the given ID.
      Parameters:
      id - the ID for referencing this gradient
  • Method Details

    • cx

      public RadialGradientElement cx(double cx)
      Sets the x coordinate of the gradient circle center.

      Uses write-only optimization. Use cxRW(double) if you need to read the value back.

      Parameters:
      cx - the x coordinate (default is 0.5 or 50%)
      Returns:
      this element for method chaining
    • cx

      public RadialGradientElement cx(String cx)
      Sets the x coordinate of the gradient circle center with a unit.

      Uses write-only optimization. Use cxRW(String) if you need to read the value back.

      Parameters:
      cx - the x coordinate (e.g., "50%")
      Returns:
      this element for method chaining
    • cxRW

      public RadialGradientElement cxRW(double cx)
      Sets the x coordinate of the gradient circle center (read-write).
      Parameters:
      cx - the x coordinate (default is 0.5 or 50%)
      Returns:
      this element for method chaining
    • cxRW

      public RadialGradientElement cxRW(String cx)
      Sets the x coordinate of the gradient circle center with a unit (read-write).
      Parameters:
      cx - the x coordinate (e.g., "50%")
      Returns:
      this element for method chaining
    • cy

      public RadialGradientElement cy(double cy)
      Sets the y coordinate of the gradient circle center.

      Uses write-only optimization. Use cyRW(double) if you need to read the value back.

      Parameters:
      cy - the y coordinate (default is 0.5 or 50%)
      Returns:
      this element for method chaining
    • cy

      public RadialGradientElement cy(String cy)
      Sets the y coordinate of the gradient circle center with a unit.

      Uses write-only optimization. Use cyRW(String) if you need to read the value back.

      Parameters:
      cy - the y coordinate (e.g., "50%")
      Returns:
      this element for method chaining
    • cyRW

      public RadialGradientElement cyRW(double cy)
      Sets the y coordinate of the gradient circle center (read-write).
      Parameters:
      cy - the y coordinate (default is 0.5 or 50%)
      Returns:
      this element for method chaining
    • cyRW

      public RadialGradientElement cyRW(String cy)
      Sets the y coordinate of the gradient circle center with a unit (read-write).
      Parameters:
      cy - the y coordinate (e.g., "50%")
      Returns:
      this element for method chaining
    • r

      public RadialGradientElement r(double r)
      Sets the radius of the gradient circle.

      Uses write-only optimization. Use rRW(double) if you need to read the value back.

      Parameters:
      r - the radius (default is 0.5 or 50%)
      Returns:
      this element for method chaining
    • r

      Sets the radius of the gradient circle with a unit.

      Uses write-only optimization. Use rRW(String) if you need to read the value back.

      Parameters:
      r - the radius (e.g., "50%")
      Returns:
      this element for method chaining
    • rRW

      public RadialGradientElement rRW(double r)
      Sets the radius of the gradient circle (read-write).
      Parameters:
      r - the radius (default is 0.5 or 50%)
      Returns:
      this element for method chaining
    • rRW

      public RadialGradientElement rRW(String r)
      Sets the radius of the gradient circle with a unit (read-write).
      Parameters:
      r - the radius (e.g., "50%")
      Returns:
      this element for method chaining
    • fx

      public RadialGradientElement fx(double fx)
      Sets the x coordinate of the focal point.

      The focal point is where the gradient starts (0% stop). If not specified, defaults to the center (cx).

      Uses write-only optimization. Use fxRW(double) if you need to read the value back.

      Parameters:
      fx - the x coordinate
      Returns:
      this element for method chaining
    • fx

      public RadialGradientElement fx(String fx)
      Sets the x coordinate of the focal point with a unit.

      Uses write-only optimization. Use fxRW(String) if you need to read the value back.

      Parameters:
      fx - the x coordinate (e.g., "25%")
      Returns:
      this element for method chaining
    • fxRW

      public RadialGradientElement fxRW(double fx)
      Sets the x coordinate of the focal point (read-write).
      Parameters:
      fx - the x coordinate
      Returns:
      this element for method chaining
    • fxRW

      public RadialGradientElement fxRW(String fx)
      Sets the x coordinate of the focal point with a unit (read-write).
      Parameters:
      fx - the x coordinate (e.g., "25%")
      Returns:
      this element for method chaining
    • fy

      public RadialGradientElement fy(double fy)
      Sets the y coordinate of the focal point.

      Uses write-only optimization. Use fyRW(double) if you need to read the value back.

      Parameters:
      fy - the y coordinate
      Returns:
      this element for method chaining
    • fy

      public RadialGradientElement fy(String fy)
      Sets the y coordinate of the focal point with a unit.

      Uses write-only optimization. Use fyRW(String) if you need to read the value back.

      Parameters:
      fy - the y coordinate (e.g., "25%")
      Returns:
      this element for method chaining
    • fyRW

      public RadialGradientElement fyRW(double fy)
      Sets the y coordinate of the focal point (read-write).
      Parameters:
      fy - the y coordinate
      Returns:
      this element for method chaining
    • fyRW

      public RadialGradientElement fyRW(String fy)
      Sets the y coordinate of the focal point with a unit (read-write).
      Parameters:
      fy - the y coordinate (e.g., "25%")
      Returns:
      this element for method chaining
    • fr

      public RadialGradientElement fr(double fr)
      Sets the radius of the focal point circle.

      This creates a focal ring instead of a focal point.

      Uses write-only optimization. Use frRW(double) if you need to read the value back.

      Parameters:
      fr - the focal radius (default is 0)
      Returns:
      this element for method chaining
    • frRW

      public RadialGradientElement frRW(double fr)
      Sets the radius of the focal point circle (read-write).
      Parameters:
      fr - the focal radius (default is 0)
      Returns:
      this element for method chaining
    • center

      public RadialGradientElement center(double cx, double cy)
      Sets the center of the gradient circle.

      Uses write-only optimization. Use centerRW(double, double) if you need to read the values back.

      Parameters:
      cx - the x coordinate
      cy - the y coordinate
      Returns:
      this element for method chaining
    • centerRW

      public RadialGradientElement centerRW(double cx, double cy)
      Sets the center of the gradient circle (read-write).
      Parameters:
      cx - the x coordinate
      cy - the y coordinate
      Returns:
      this element for method chaining
    • focalPoint

      public RadialGradientElement focalPoint(double fx, double fy)
      Sets the focal point of the gradient.

      Uses write-only optimization. Use focalPointRW(double, double) if you need to read the values back.

      Parameters:
      fx - the x coordinate
      fy - the y coordinate
      Returns:
      this element for method chaining
    • focalPointRW

      public RadialGradientElement focalPointRW(double fx, double fy)
      Sets the focal point of the gradient (read-write).
      Parameters:
      fx - the x coordinate
      fy - the y coordinate
      Returns:
      this element for method chaining
    • gradientUnits

      Sets the coordinate system for the gradient.

      Uses write-only optimization. Use gradientUnitsRW(LinearGradientElement.GradientUnits) if you need to read the value back.

      Parameters:
      units - the gradient units
      Returns:
      this element for method chaining
    • gradientUnitsRW

      Sets the coordinate system for the gradient (read-write).
      Parameters:
      units - the gradient units
      Returns:
      this element for method chaining
    • spreadMethod

      Sets how the gradient behaves outside its bounds.

      Uses write-only optimization. Use spreadMethodRW(LinearGradientElement.SpreadMethod) if you need to read the value back.

      Parameters:
      method - the spread method
      Returns:
      this element for method chaining
    • spreadMethodRW

      Sets how the gradient behaves outside its bounds (read-write).
      Parameters:
      method - the spread method
      Returns:
      this element for method chaining
    • gradientTransform

      public RadialGradientElement gradientTransform(String transform)
      Sets a transform on the gradient.

      Uses write-only optimization. Use gradientTransformRW(String) if you need to read the value back.

      Parameters:
      transform - the transform string
      Returns:
      this element for method chaining
    • gradientTransformRW

      public RadialGradientElement gradientTransformRW(String transform)
      Sets a transform on the gradient (read-write).
      Parameters:
      transform - the transform string
      Returns:
      this element for method chaining
    • href

      public RadialGradientElement href(String href)
      References another gradient to inherit stops and attributes from.

      Uses write-only optimization. Use hrefRW(String) if you need to read the value back.

      Parameters:
      href - the reference (e.g., "#otherGradient")
      Returns:
      this element for method chaining
    • hrefRW

      public RadialGradientElement hrefRW(String href)
      References another gradient to inherit stops and attributes from (read-write).
      Parameters:
      href - the reference (e.g., "#otherGradient")
      Returns:
      this element for method chaining
    • addStops

      public RadialGradientElement addStops(StopElement... stops)
      Adds stop elements to this gradient.
      Parameters:
      stops - the stop elements
      Returns:
      this element for method chaining
    • addStop

      public RadialGradientElement addStop(double offset, in.virit.color.Color color)
      Adds a stop at the specified offset with the given color.
      Parameters:
      offset - the offset (0.0 to 1.0)
      color - the color
      Returns:
      this element for method chaining
    • addStop

      public RadialGradientElement addStop(double offset, String color)
      Adds a stop at the specified offset with the given color.
      Parameters:
      offset - the offset (0.0 to 1.0)
      color - the color string
      Returns:
      this element for method chaining