Class QuadraticCurveTo
java.lang.Object
com.itextpdf.svg.renderers.path.impl.AbstractPathShape
com.itextpdf.svg.renderers.path.impl.QuadraticCurveTo
- All Implemented Interfaces:
IControlPointCurve, IPathShape
- Direct Known Subclasses:
QuadraticSmoothCurveTo
Implements quadratic Bezier curveTo(Q) attribute of SVG's path element.
-
Field Summary
FieldsFields inherited from class AbstractPathShape
context, coordinates, copier, properties, relative -
Constructor Summary
ConstructorsConstructorDescriptionCreates newQuadraticCurveToinstance.QuadraticCurveTo(boolean relative) Creates newQuadraticCurveToinstance.QuadraticCurveTo(boolean relative, IOperatorConverter copier) Creates newQuadraticCurveToinstance. -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddTValueToList(double t, List<Double> tValuesList) Check that t is in the range [0, 1] and add it to listprivate static doublecalculateExtremeCoordinate(double t, double p0, double p1, double p2) voiddraw()Draws a quadratic Bezier curve from the current point to (x,y) using (x1,y1) as the control pointprivate static double[]getBezierMinMaxPoints(double x0, double y0, double x1, double y1, double x2, double y2) The algorithm is similar to cubic curve in the method CurveTo#getBezierMinMaxPoints, but the initial function is f(t) = (1 - t)^2*P0 + 2*(1-t)*t*P1 + t^2*P2, 0 invalid input: '<'= t invalid input: '<'= 1private static double[]getExtremeTValues(double x0, double y0, double x1, double y1, double x2, double y2) Calculate values of t at which the function reaches its extreme points.Returns coordinates of the last control point (the one closest to the ending point) in the Bezier curve, in SVG space coordinatesgetPathShapeRectangle(Point lastPoint) Get bounding rectangle of the current path shape.private static doublegetTValue(double p0, double p1, double p2) voidsetCoordinates(String[] inputCoordinates, Point startPoint) This method sets the coordinates for the path painting operator and does internal preprocessing, if necessaryMethods inherited from class AbstractPathShape
applyTransform, createPoint, draw, getEndingPoint, isRelative, parseHorizontalLength, parseVerticalLength, setContext, setParent, setTransform
-
Field Details
-
ARGUMENT_SIZE
static final int ARGUMENT_SIZE- See Also:
-
-
Constructor Details
-
QuadraticCurveTo
public QuadraticCurveTo()Creates newQuadraticCurveToinstance. -
QuadraticCurveTo
public QuadraticCurveTo(boolean relative) Creates newQuadraticCurveToinstance.- Parameters:
relative-truein case it is a relative operator,falseif it is an absolute operator
-
QuadraticCurveTo
Creates newQuadraticCurveToinstance.- Parameters:
relative-truein case it is a relative operator,falseif it is an absolute operatorcopier-IOperatorConvertercopier for converting relative coordinates to absolute coordinates
-
-
Method Details
-
draw
public void draw()Draws a quadratic Bezier curve from the current point to (x,y) using (x1,y1) as the control point- Specified by:
drawin classAbstractPathShape
-
setCoordinates
Description copied from interface:IPathShapeThis method sets the coordinates for the path painting operator and does internal preprocessing, if necessary- Specified by:
setCoordinatesin interfaceIPathShape- Parameters:
inputCoordinates- an array containing point values for path coordinatesstartPoint- the ending point of the previous operator, or, in broader terms, the point that the coordinates should be absolutized against, for relative operators
-
getLastControlPoint
Description copied from interface:IControlPointCurveReturns coordinates of the last control point (the one closest to the ending point) in the Bezier curve, in SVG space coordinates- Specified by:
getLastControlPointin interfaceIControlPointCurve- Returns:
- coordinates of the last control point in SVG space coordinates
-
getPathShapeRectangle
Description copied from class:AbstractPathShapeGet bounding rectangle of the current path shape.- Specified by:
getPathShapeRectanglein interfaceIPathShape- Overrides:
getPathShapeRectanglein classAbstractPathShape- Parameters:
lastPoint- start point for this shape- Returns:
- calculated rectangle
-
getBezierMinMaxPoints
private static double[] getBezierMinMaxPoints(double x0, double y0, double x1, double y1, double x2, double y2) The algorithm is similar to cubic curve in the method CurveTo#getBezierMinMaxPoints, but the initial function is f(t) = (1 - t)^2*P0 + 2*(1-t)*t*P1 + t^2*P2, 0 invalid input: '<'= t invalid input: '<'= 1- Parameters:
x0- x coordinate of the starting pointy0- y coordinate of the starting pointx1- x coordinate of the control pointy1- y coordinate of the control pointx2- x coordinate of the ending pointy2- y coordinate of the ending point- Returns:
- array of {xMin, yMin, xMax, yMax} values
-
getExtremeTValues
private static double[] getExtremeTValues(double x0, double y0, double x1, double y1, double x2, double y2) Calculate values of t at which the function reaches its extreme points. To do this, we get the derivative of the function and equate it to 0: f'(t) = 2a*t + b. t can only be in the range [0, 1] and it discarded otherwise.- Parameters:
x0- x coordinate of the starting pointy0- y coordinate of the starting pointx1- x coordinate of the control pointy1- y coordinate of the control pointx2- x coordinate of the ending pointy2- y coordinate of the ending point- Returns:
- array of theta values corresponding to extreme points
-
addTValueToList
-
getTValue
private static double getTValue(double p0, double p1, double p2) -
calculateExtremeCoordinate
private static double calculateExtremeCoordinate(double t, double p0, double p1, double p2)
-