Class LinearGradientBuilder
- java.lang.Object
-
- com.itextpdf.kernel.colors.gradients.AbstractLinearGradientBuilder
-
- com.itextpdf.kernel.colors.gradients.LinearGradientBuilder
-
public class LinearGradientBuilder extends AbstractLinearGradientBuilder
The linear gradient builder implementation with direct target gradient vector and shading transformation (more info
)
-
-
Field Summary
Fields Modifier and Type Field Description private Point[]
coordinates
private AffineTransform
transformation
-
Fields inherited from class com.itextpdf.kernel.colors.gradients.AbstractLinearGradientBuilder
ZERO_EPSILON
-
-
Constructor Summary
Constructors Constructor Description LinearGradientBuilder()
Constructs the builder instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AffineTransform
getCurrentSpaceToGradientVectorSpaceTransformation(Rectangle targetBoundingBox, AffineTransform contextTransform)
Returns the current space to gradient vector space transformations that should be applied to the shading color.Point[]
getGradientVector(Rectangle targetBoundingBox, AffineTransform contextTransform)
Returns the base gradient vector in gradient vector space.LinearGradientBuilder
setCurrentSpaceToGradientVectorSpaceTransformation(AffineTransform transformation)
Set the linear gradient space transformation which specifies the transformation from the current coordinates space to gradient vector spaceLinearGradientBuilder
setGradientVector(double x0, double y0, double x1, double y1)
Set coordinates for gradient vector (more info
)-
Methods inherited from class com.itextpdf.kernel.colors.gradients.AbstractLinearGradientBuilder
addColorStop, buildColor, createCoordinatesForNewDomain, evaluateCoveringDomain, getColorStops, getSpreadMethod, setSpreadMethod
-
-
-
-
Field Detail
-
coordinates
private final Point[] coordinates
-
transformation
private AffineTransform transformation
-
-
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 starty0
- the y coordinate of the vector startx1
- the x coordinate of the vector endy1
- 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 spaceThe 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
- theAffineTransform
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 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
-
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 classAbstractLinearGradientBuilder
- Parameters:
targetBoundingBox
- the rectangle to be covered by constructed color in current spacecontextTransform
- 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
-
-