Class AbstractLinearGradientBuilder
java.lang.Object
com.itextpdf.kernel.colors.gradients.AbstractGradientBuilder<Point>
com.itextpdf.kernel.colors.gradients.AbstractLinearGradientBuilder
- All Implemented Interfaces:
-
IGradientBuilder
- Direct Known Subclasses:
-
LinearGradientBuilder,StrategyBasedLinearGradientBuilder
Base class for linear gradient builders implementations.
Color transitions for linear gradients are defined by a series of color stops along a gradient vector. A gradient normal defines how the colors in a vector are painted to the surface. For a linear gradient, a normal is a line perpendicular to the vector.
Contains the main logic that works with stop colors and creation of the resulted pdf color object.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddColorStop(GradientColorStop gradientColorStop) Deprecated.protected double[]computeCoveringDomain(Point[] coords, Rectangle toCover) Computes the minimal domain that covers the box with vector normals.protected static Point[]createCoordinatesForNewDomain(double[] newDomain, Point[] baseVector) Expand the base vector to cover the new domainprotected PdfArraycreateCoordsDictEntry(Point[] coordinates) Converts gradient vector into pdf coordinates array for shading.protected Point[]createCoordsForNewDomain(double[] newDomain, Point[] baseVector) Expand the base vector to cover the new domainprotected Point[]createCoveringCoordinates(Rectangle targetBoundingBox) Creates some gradient vector which would cover the target bounding box.protected AbstractPdfShadingcreatePdfShading(PdfColorSpace colorSpace, PdfArray coordinates, PdfArray coordinatesDomain, IPdfFunction stopsFunction) Creates the gradient shading object.protected static double[]evaluateCoveringDomain(Point[] coords, Rectangle toCover) Evaluates the minimal domain that covers the box with vector normals.protected doublegetBaseVectorLength(Point[] coordinates) Evaluates base vector length for future color stops spreading.Deprecated.useAbstractGradientBuilder.getStopColors()insteadprotected AffineTransformgetCurrentSpaceToGradientVectorSpaceTransformation(Rectangle targetBoundingBox, AffineTransform contextTransform) protected abstract Point[]getGradientVector(Rectangle targetBoundingBox, AffineTransform contextTransform) Deprecated.useAbstractGradientBuilder.getSpread()insteadsetSpreadMethod(GradientSpreadMethod gradientSpreadMethod) Deprecated.Methods inherited from class com.itextpdf.kernel.colors.gradients.AbstractGradientBuilder
addStopColor, buildColor, getGradientVectorWithTransform, getSpread, getStopColors, getToIntervalTransform, isZero, setSpread, setSvgLuminanceMode
-
Field Details
-
ZERO_EPSILON
Deprecated.useAbstractGradientBuilder.isZero(double)instead for zero comparisonsThe epsilon value used for data creation- See Also:
-
-
Constructor Details
-
AbstractLinearGradientBuilder
public AbstractLinearGradientBuilder()
-
-
Method Details
-
addColorStop
Deprecated.Adds the new color stop to the end (more info).Note: if the previously added color stop's offset would have grater offset than the added one, then the new offset would be normalized to be equal to the previous one. (Comparison made between relative on coordinates vector offsets. If any of them has the absolute offset, then the absolute value would converted to relative first.)
- Parameters:
-
gradientColorStop- the gradient stop color to add - Returns:
- the current builder instance
-
setSpreadMethod
@Deprecated public AbstractLinearGradientBuilder setSpreadMethod(GradientSpreadMethod gradientSpreadMethod) Deprecated.Set the spread method to use for the gradient- Parameters:
-
gradientSpreadMethod- the gradient spread method to set - Returns:
- the current builder instance
-
getColorStops
Deprecated.useAbstractGradientBuilder.getStopColors()insteadGet the copy of current color stops list. Note that the stop colors are not copied here- Returns:
- the copy of current stop colors list
-
getSpreadMethod
Deprecated.useAbstractGradientBuilder.getSpread()insteadGet the current spread method- Returns:
- the current spread method
-
getGradientVector
@Deprecated protected abstract Point[] getGradientVector(Rectangle targetBoundingBox, AffineTransform contextTransform) 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.- 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
@Deprecated protected AffineTransform getCurrentSpaceToGradientVectorSpaceTransformation(Rectangle targetBoundingBox, AffineTransform contextTransform) 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.- 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
nullif no additional transformation is specified
-
evaluateCoveringDomain
Evaluates the minimal domain that covers the box with vector normals. The domain corresponding to the initial vector is [0, 1].- Parameters:
-
coords- the array of exactly two elements that describe the base vector (corresponding to [0,1] domain, that need to be adjusted to cover the box -
toCover- the box that needs to be covered - Returns:
- the array of two elements in ascending order specifying the calculated covering domain
-
createCoordinatesForNewDomain
Expand the base vector to cover the new domain- Parameters:
-
newDomain- the array of exactly two elements that specifies the domain that should be covered by the created vector -
baseVector- the array of exactly two elements that specifies the base vector which corresponds to [0, 1] domain - Returns:
- the array of two
-
computeCoveringDomain
Computes the minimal domain that covers the box with vector normals. The domain corresponding to the initial vector is [0, 1].- Specified by:
-
computeCoveringDomainin classAbstractGradientBuilder<Point> - Parameters:
-
coords- the array of exactly two elements that describe the base vector (corresponding to [0,1] domain, that need to be adjusted to cover the box -
toCover- the box that needs to be covered - Returns:
- the array of two elements in ascending order specifying the calculated covering domain
-
createCoordsForNewDomain
Expand the base vector to cover the new domain- Specified by:
-
createCoordsForNewDomainin classAbstractGradientBuilder<Point> - Parameters:
-
newDomain- the array of exactly two elements that specifies the domain that should be covered by the created vector -
baseVector- the array of exactly two elements that specifies the base vector which corresponds to [0, 1] domain - Returns:
- the array of two
-
createCoveringCoordinates
Creates some gradient vector which would cover the target bounding box.- Specified by:
-
createCoveringCoordinatesin classAbstractGradientBuilder<Point> - Parameters:
-
targetBoundingBox- the bounding box to cover - Returns:
- constructed gradient vector
-
getBaseVectorLength
Evaluates base vector length for future color stops spreading.- Specified by:
-
getBaseVectorLengthin classAbstractGradientBuilder<Point> - Parameters:
-
coordinates- the base vector - Returns:
- base vector length
-
createCoordsDictEntry
Converts gradient vector into pdf coordinates array for shading.- Specified by:
-
createCoordsDictEntryin classAbstractGradientBuilder<Point> - Parameters:
-
coordinates- vector to convert - Returns:
- constructed pdf array
-
createPdfShading
protected AbstractPdfShading createPdfShading(PdfColorSpace colorSpace, PdfArray coordinates, PdfArray coordinatesDomain, IPdfFunction stopsFunction) Creates the gradient shading object.- Specified by:
-
createPdfShadingin classAbstractGradientBuilder<Point> - Parameters:
-
colorSpace- colorspace to use -
coordinates- gradient coordinates -
coordinatesDomain- gradient coordinates domain -
stopsFunction- color stops function - Returns:
- constructed gradient shading
-
AbstractGradientBuilder.isZero(double)instead for zero comparisons