Class StrategyBasedRadialGradientBuilder

All Implemented Interfaces:
IGradientBuilder

public class StrategyBasedRadialGradientBuilder extends AbstractRadialGradientBuilder
The radial gradient builder with automatic end circle (or ellipse) evaluation for the target filled area based on configured strategy. Start center would be equal to end center, radius would be 0.
  • Constructor Details

    • StrategyBasedRadialGradientBuilder

      public StrategyBasedRadialGradientBuilder()
      Constructs the builder instance
  • Method Details

    • setCenterStrategy

      public StrategyBasedRadialGradientBuilder setCenterStrategy (boolean leftToRight, double xOffset, boolean xOffsetRelative, boolean bottomToTop, double yOffset, boolean yOffsetRelative)
      Specifies the strategy to determine center point.
      Parameters:
      leftToRight - if true then X offset would be added to the left side X value, if false then X offset would be subtracted from the right side X value
      xOffset - the offset value to add/subtract for X
      xOffsetRelative - if true then X offset treated as relative to bbox width, if false then X offset treated as absolute
      bottomToTop - if true then Y offset would be subtracted from the top side Y value, if false then Y offset would be added to the bottom side Y value
      yOffset - the offset value to add/subtract for Y
      yOffsetRelative - if true then Y offset treated as relative to bbox height, if false then Y offset treated as absolute
      Returns:
      the current builder instance
    • setRadiusRelativeToBoundingBoxSize

      public StrategyBasedRadialGradientBuilder setRadiusRelativeToBoundingBoxSize (double xRadius, boolean xRadiusRelative, double yRadius, boolean yRadiusRelative)
      Set the strategy to calculate radius based on bounding box dimensions.
      Parameters:
      xRadius - X radius value
      xRadiusRelative - if true then X radius treated as relative to bbox width, if false then X radius treated as absolute
      yRadius - Y radius value
      yRadiusRelative - if true then Y radius treated as relative to bbox height, if false then Y radius treated as absolute
      Returns:
      the current builder instance
    • setRadiusFromCenterStrategy

      public StrategyBasedRadialGradientBuilder setRadiusFromCenterStrategy (boolean isCircular, StrategyBasedRadialGradientBuilder.GradientStrategy gradientStrategy)
      Set the strategy to predefined one from gradient center.
      Parameters:
      isCircular - whether the gradient strategy to be applied for circular or elliptical gradient spreading
      gradientStrategy - strategy to be used for calculating target radius from gradient center
      Returns:
      the current builder instance
    • getGradientVectorWithTransform

      protected Tuple2<RadialGradientPoint[],AffineTransform> getGradientVectorWithTransform (Rectangle targetBoundingBox, AffineTransform contextTransform)
      Returns the base gradient vector in gradient vector space and the current space to gradient vector space transformations that should be applied to the shading color.

      The vector would be set as shading coordinates vector and its length would be used to translate all color stops absolute offsets into the relatives.

      The transformation should be invertible as the current target bounding box coordinates should be transformed into the resulted shading space coordinates.

      Overrides:
      getGradientVectorWithTransform in class AbstractGradientBuilder<RadialGradientPoint>
      Parameters:
      targetBoundingBox - the rectangle to be covered by constructed color in current space
      contextTransform - the current canvas transformation
      Returns:
      the pair of the vector, which is an array of exactly two elements specifying the gradient coordinates vector, and the additional transformation to be concatenated to the current for resulted shading or null if no additional transformation is specified