Class LinearGradientBuilder


  • public class LinearGradientBuilder
    extends AbstractLinearGradientBuilder
    The linear gradient builder implementation with direct target gradient vector and shading transformation (more info)
    • Field Detail

      • coordinates

        private final Point[] coordinates
    • Constructor Detail

      • LinearGradientBuilder

        public LinearGradientBuilder()
        Constructs the builder instance
    • Method Detail

      • setGradientVector

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

        public LinearGradientBuilder setCurrentSpaceToGradientVectorSpaceTransformation​(AffineTransform transformation)
        Set the linear gradient space transformation which specifies the transformation from the current coordinates space to gradient vector space

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

        Parameters:
        transformation - the AffineTransform representing the transformation to set
        Returns:
        the current builder instance
      • getGradientVector

        public Point[] getGradientVector​(Rectangle targetBoundingBox,
                                         AffineTransform contextTransform)
        Description copied from class: AbstractLinearGradientBuilder
        Returns the base gradient vector in gradient vector space. This vector would be set as shading coordinates vector and its length would be used to translate all color stops absolute offsets into the relatives.
        Specified by:
        getGradientVector in class AbstractLinearGradientBuilder
        Parameters:
        targetBoundingBox - the rectangle to be covered by constructed color in current space
        contextTransform - the current canvas transformation
        Returns:
        the array of exactly two elements specifying the gradient coordinates vector
      • getCurrentSpaceToGradientVectorSpaceTransformation

        public AffineTransform getCurrentSpaceToGradientVectorSpaceTransformation​(Rectangle targetBoundingBox,
                                                                                  AffineTransform contextTransform)
        Description copied from class: AbstractLinearGradientBuilder
        Returns the current space to gradient vector space transformations that should be applied to the shading color. The transformation should be invertible as the current target bounding box coordinates should be transformed into the resulted shading space coordinates.
        Overrides:
        getCurrentSpaceToGradientVectorSpaceTransformation in class AbstractLinearGradientBuilder
        Parameters:
        targetBoundingBox - the rectangle to be covered by constructed color in current space
        contextTransform - the current canvas transformation
        Returns:
        the additional transformation to be concatenated to the current for resulted shading or null if no additional transformation is specified