Class RadialGradientBuilder

All Implemented Interfaces:
IGradientBuilder

public class RadialGradientBuilder extends AbstractRadialGradientBuilder
The radial gradient builder implementation with direct target gradient vector and shading transformation (more info)
  • Constructor Details

    • RadialGradientBuilder

      public RadialGradientBuilder()
      Constructs the builder instance
  • Method Details

    • setGradientVector

      public RadialGradientBuilder setGradientVector (double x0, double y0, double r0, double x1, double y1, double r1)
      Set coordinates for gradient vector circles (more info)
      Parameters:
      x0 - the x coordinate of the vector start circle
      y0 - the y coordinate of the vector start circle
      r0 - the radius of the vector start circle
      x1 - the x coordinate of the vector end circle
      y1 - the y coordinate of the vector end circle
      r1 - the radius of the vector end circle
      Returns:
      the current builder instance
    • setCurrentSpaceToGradientVectorSpaceTransformation

      public RadialGradientBuilder setCurrentSpaceToGradientVectorSpaceTransformation (AffineTransform transformation)
      Set the radial gradient space transformation which specifies the transformation from the current coordinates space to gradient vector space.

      The current space is the one on which radial gradient will be drawn (as a fill or stroke color for shapes on PDF canvas). This transformation mainly used for ellipse based gradient.

      Parameters:
      transformation - the AffineTransform representing the transformation to set
      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