public abstract class AbstractLinearGradientBuilder extends Object
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.
Modifier and Type | Field and Description |
---|---|
protected static double |
ZERO_EPSILON
The epsilon value used for data creation
|
Constructor and Description |
---|
AbstractLinearGradientBuilder() |
Modifier and Type | Method and Description |
---|---|
AbstractLinearGradientBuilder |
addColorStop(GradientColorStop gradientColorStop)
Adds the new color stop to the end ( more info ).
|
Color |
buildColor(Rectangle targetBoundingBox, AffineTransform contextTransform, PdfDocument document)
Builds the Color object representing the linear gradient with specified configuration that fills the target bounding box.
|
protected static Point[] |
createCoordinatesForNewDomain(double[] newDomain, Point[] baseVector)
Expand the base vector to cover the new domain
|
protected static double[] |
evaluateCoveringDomain(Point[] coords, Rectangle toCover)
Evaluates the minimal domain that covers the box with vector normals.
|
List<GradientColorStop> |
getColorStops()
Get the copy of current color stops list.
|
protected AffineTransform |
getCurrentSpaceToGradientVectorSpaceTransformation(Rectangle targetBoundingBox, AffineTransform contextTransform)
Returns the current space to gradient vector space transformations that should be applied to the shading color.
|
protected abstract Point[] |
getGradientVector(Rectangle targetBoundingBox, AffineTransform contextTransform)
Returns the base gradient vector in gradient vector space.
|
GradientSpreadMethod |
getSpreadMethod()
Get the current spread method
|
AbstractLinearGradientBuilder |
setSpreadMethod(GradientSpreadMethod gradientSpreadMethod)
Set the spread method to use for the gradient
|
protected static final double ZERO_EPSILON
public AbstractLinearGradientBuilder addColorStop(GradientColorStop gradientColorStop)
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.)
gradientColorStop
- the gradient stop color to add
public AbstractLinearGradientBuilder setSpreadMethod(GradientSpreadMethod gradientSpreadMethod)
gradientSpreadMethod
- the gradient spread method to set
public List<GradientColorStop> getColorStops()
public GradientSpreadMethod getSpreadMethod()
public Color buildColor(Rectangle targetBoundingBox, AffineTransform contextTransform, PdfDocument document)
Color
object representing the linear gradient with specified configuration that fills the target bounding box.
targetBoundingBox
- the bounding box to be filled in current space
contextTransform
- the transformation from the base coordinates space into the current space. The null
value is valid and can be used if there is no transformation from base coordinates to current space specified, or it is equal to identity transformation.
document
- the PdfDocument
for which the linear gradient would be built.
Color
or null
if no color to be applied or base gradient vector has been specified
protected abstract Point[] getGradientVector(Rectangle targetBoundingBox, AffineTransform contextTransform)
targetBoundingBox
- the rectangle to be covered by constructed color in current space
contextTransform
- the current canvas transformation
protected AffineTransform getCurrentSpaceToGradientVectorSpaceTransformation(Rectangle targetBoundingBox, AffineTransform contextTransform)
targetBoundingBox
- the rectangle to be covered by constructed color in current space
contextTransform
- the current canvas transformation
null
if no additional transformation is specified
protected static double[] evaluateCoveringDomain(Point[] coords, Rectangle toCover)
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
protected static Point[] createCoordinatesForNewDomain(double[] newDomain, Point[] baseVector)
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
Copyright © 1998–2022 iText Group NV. All rights reserved.