Class StrategyBasedLinearGradientBuilder
java.lang.Object
com.itextpdf.kernel.colors.gradients.AbstractGradientBuilder<Point>
com.itextpdf.kernel.colors.gradients.AbstractLinearGradientBuilder
com.itextpdf.kernel.colors.gradients.StrategyBasedLinearGradientBuilder
- All Implemented Interfaces:
-
IGradientBuilder
The linear gradient builder with automatic coordinates vector evaluation for the target filled area based on configured strategy
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSpecifies the predefined strategies -
Field Summary
Fields inherited from class com.itextpdf.kernel.colors.gradients.AbstractLinearGradientBuilder
ZERO_EPSILON -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the last set predefined strategyprotected Point[]getGradientVector(Rectangle targetBoundingBox, AffineTransform contextTransform) Returns the base gradient vector in gradient vector space.protected Tuple2<Point[],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.doubleGet the last set rotate vector anglebooleanIs the central rotation angle strategy was set lastsetGradientDirectionAsCentralRotationAngle(double radians) Set the strategy to use the minimal coordinates vector that passes through the central point of the target rectangle area, rotated by the specified amount of radians counter clockwise and covers the area to be filled.setGradientDirectionAsStrategy(StrategyBasedLinearGradientBuilder.GradientStrategy gradientStrategy) Set the strategy to predefined oneMethods inherited from class com.itextpdf.kernel.colors.gradients.AbstractLinearGradientBuilder
addColorStop, computeCoveringDomain, createCoordinatesForNewDomain, createCoordsDictEntry, createCoordsForNewDomain, createCoveringCoordinates, createPdfShading, evaluateCoveringDomain, getBaseVectorLength, getColorStops, getCurrentSpaceToGradientVectorSpaceTransformation, getSpreadMethod, setSpreadMethodMethods inherited from class com.itextpdf.kernel.colors.gradients.AbstractGradientBuilder
addStopColor, buildColor, getSpread, getStopColors, getToIntervalTransform, isZero, setSpread, setSvgLuminanceMode
-
Constructor Details
-
StrategyBasedLinearGradientBuilder
public StrategyBasedLinearGradientBuilder()Create a new instance of the builder
-
-
Method Details
-
setGradientDirectionAsCentralRotationAngle
public StrategyBasedLinearGradientBuilder setGradientDirectionAsCentralRotationAngle(double radians) Set the strategy to use the minimal coordinates vector that passes through the central point of the target rectangle area, rotated by the specified amount of radians counter clockwise and covers the area to be filled. Zero angle corresponds to the vector from bottom to top.- Parameters:
-
radians- the radians value to rotate the coordinates vector - Returns:
- the current builder instance
-
setGradientDirectionAsStrategy
public StrategyBasedLinearGradientBuilder setGradientDirectionAsStrategy(StrategyBasedLinearGradientBuilder.GradientStrategy gradientStrategy) Set the strategy to predefined one- Parameters:
-
gradientStrategy- the strategy to set - Returns:
- the current builder instance
-
getRotateVectorAngle
public double getRotateVectorAngle()Get the last set rotate vector angle- Returns:
- the last set rotate vector angle
-
getGradientStrategy
Get the last set predefined strategy- Returns:
- the last set predefined strategy
-
isCentralRotationAngleStrategy
public boolean isCentralRotationAngleStrategy()Is the central rotation angle strategy was set last- Returns:
-
trueif the last strategy that has been set is a custom rotation angle
-
getGradientVector
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:
-
getGradientVectorin classAbstractLinearGradientBuilder - 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
-
getGradientVectorWithTransform
protected Tuple2<Point[],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:
-
getGradientVectorWithTransformin classAbstractGradientBuilder<Point> - 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
nullif no additional transformation is specified
-