Class StrategyBasedRadialGradientBuilder
java.lang.Object
com.itextpdf.kernel.colors.gradients.AbstractGradientBuilder<RadialGradientPoint>
com.itextpdf.kernel.colors.gradients.AbstractRadialGradientBuilder
com.itextpdf.kernel.colors.gradients.StrategyBasedRadialGradientBuilder
- All Implemented Interfaces:
-
IGradientBuilder
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSpecifies the predefined strategies -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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.setCenterStrategy(boolean leftToRight, double xOffset, boolean xOffsetRelative, boolean bottomToTop, double yOffset, boolean yOffsetRelative) Specifies the strategy to determine center point.setRadiusFromCenterStrategy(boolean isCircular, StrategyBasedRadialGradientBuilder.GradientStrategy gradientStrategy) Set the strategy to predefined one from gradient center.setRadiusRelativeToBoundingBoxSize(double xRadius, boolean xRadiusRelative, double yRadius, boolean yRadiusRelative) Set the strategy to calculate radius based on bounding box dimensions.Methods inherited from class com.itextpdf.kernel.colors.gradients.AbstractRadialGradientBuilder
computeCoveringDomain, createCoordsDictEntry, createCoordsForNewDomain, createCoveringCoordinates, createPdfShading, getBaseVectorLengthMethods inherited from class com.itextpdf.kernel.colors.gradients.AbstractGradientBuilder
addStopColor, buildColor, getSpread, getStopColors, getToIntervalTransform, isZero, setSpread, setSvgLuminanceMode
-
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- iftruethen X offset would be added to the left side X value, iffalsethen X offset would be subtracted from the right side X value -
xOffset- the offset value to add/subtract for X -
xOffsetRelative- iftruethen X offset treated as relative to bbox width, iffalsethen X offset treated as absolute -
bottomToTop- iftruethen Y offset would be subtracted from the top side Y value, iffalsethen Y offset would be added to the bottom side Y value -
yOffset- the offset value to add/subtract for Y -
yOffsetRelative- iftruethen Y offset treated as relative to bbox height, iffalsethen 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- iftruethen X radius treated as relative to bbox width, iffalsethen X radius treated as absolute -
yRadius- Y radius value -
yRadiusRelative- iftruethen Y radius treated as relative to bbox height, iffalsethen 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:
-
getGradientVectorWithTransformin classAbstractGradientBuilder<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
nullif no additional transformation is specified
-