Class StrategyBasedLinearGradientBuilder
- java.lang.Object
-
- com.itextpdf.kernel.colors.gradients.AbstractLinearGradientBuilder
-
- com.itextpdf.kernel.colors.gradients.StrategyBasedLinearGradientBuilder
-
public class StrategyBasedLinearGradientBuilder extends AbstractLinearGradientBuilder
The linear gradient builder with automatic coordinates vector evaluation for the target filled area based on configured strategy
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StrategyBasedLinearGradientBuilder.GradientStrategy
Specifies the predefined strategies
-
Field Summary
Fields Modifier and Type Field Description private StrategyBasedLinearGradientBuilder.GradientStrategy
gradientStrategy
private boolean
isCentralRotationAngleStrategy
private double
rotateVectorAngle
-
Fields inherited from class com.itextpdf.kernel.colors.gradients.AbstractLinearGradientBuilder
ZERO_EPSILON
-
-
Constructor Summary
Constructors Constructor Description StrategyBasedLinearGradientBuilder()
Create a new instance of the builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static Point[]
buildCentralRotationCoordinates(Rectangle targetBoundingBox, double angle)
private static Point[]
buildCoordinates(Rectangle targetBoundingBox, AffineTransform transformation)
private static Point[]
buildCoordinatesWithGradientStrategy(Rectangle targetBoundingBox, StrategyBasedLinearGradientBuilder.GradientStrategy gradientStrategy)
private static Point[]
buildToCornerCoordinates(Rectangle targetBoundingBox, Point gradientCenterLineRightCorner)
private static AffineTransform
buildToCornerTransform(Point center, Point gradientCenterLineRightCorner)
private static Point[]
createCoordinates(double x1, double y1, double x2, double y2)
StrategyBasedLinearGradientBuilder.GradientStrategy
getGradientStrategy()
Get the last set predefined strategyprotected Point[]
getGradientVector(Rectangle targetBoundingBox, AffineTransform contextTransform)
Returns the base gradient vector in gradient vector space.double
getRotateVectorAngle()
Get the last set rotate vector angleboolean
isCentralRotationAngleStrategy()
Is the central rotation angle strategy was set lastStrategyBasedLinearGradientBuilder
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.StrategyBasedLinearGradientBuilder
setGradientDirectionAsStrategy(StrategyBasedLinearGradientBuilder.GradientStrategy gradientStrategy)
Set the strategy to predefined one-
Methods inherited from class com.itextpdf.kernel.colors.gradients.AbstractLinearGradientBuilder
addColorStop, buildColor, createCoordinatesForNewDomain, evaluateCoveringDomain, getColorStops, getCurrentSpaceToGradientVectorSpaceTransformation, getSpreadMethod, setSpreadMethod
-
-
-
-
Field Detail
-
rotateVectorAngle
private double rotateVectorAngle
-
gradientStrategy
private StrategyBasedLinearGradientBuilder.GradientStrategy gradientStrategy
-
isCentralRotationAngleStrategy
private boolean isCentralRotationAngleStrategy
-
-
Method Detail
-
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
public StrategyBasedLinearGradientBuilder.GradientStrategy 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:
true
if the last strategy that has been set is a custom rotation angle
-
getGradientVector
protected 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 classAbstractLinearGradientBuilder
- Parameters:
targetBoundingBox
- the rectangle to be covered by constructed color in current spacecontextTransform
- the current canvas transformation- Returns:
- the array of exactly two elements specifying the gradient coordinates vector
-
buildCoordinatesWithGradientStrategy
private static Point[] buildCoordinatesWithGradientStrategy(Rectangle targetBoundingBox, StrategyBasedLinearGradientBuilder.GradientStrategy gradientStrategy)
-
buildCentralRotationCoordinates
private static Point[] buildCentralRotationCoordinates(Rectangle targetBoundingBox, double angle)
-
buildToCornerCoordinates
private static Point[] buildToCornerCoordinates(Rectangle targetBoundingBox, Point gradientCenterLineRightCorner)
-
buildToCornerTransform
private static AffineTransform buildToCornerTransform(Point center, Point gradientCenterLineRightCorner)
-
buildCoordinates
private static Point[] buildCoordinates(Rectangle targetBoundingBox, AffineTransform transformation)
-
createCoordinates
private static Point[] createCoordinates(double x1, double y1, double x2, double y2)
-
-