Class QuadraticCurveTo

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static void addTValueToList​(double t, java.util.List<java.lang.Double> tValuesList)
      Check that t is in the range [0, 1] and add it to list
      private static double calculateExtremeCoordinate​(double t, double p0, double p1, double p2)  
      void draw​(PdfCanvas canvas)
      Draws a quadratic Bezier curve from the current point to (x,y) using (x1,y1) as the control point
      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 <= t <= 1
      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.
      Point getLastControlPoint()
      Returns coordinates of the last control point (the one closest to the ending point) in the Bezier curve, in SVG space coordinates
      Rectangle getPathShapeRectangle​(Point lastPoint)
      Get bounding rectangle of the current path shape.
      private static double getTValue​(double p0, double p1, double p2)  
      void setCoordinates​(java.lang.String[] inputCoordinates, Point startPoint)
      This method sets the coordinates for the path painting operator and does internal preprocessing, if necessary
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • QuadraticCurveTo

        public QuadraticCurveTo()
      • QuadraticCurveTo

        public QuadraticCurveTo​(boolean relative)
      • QuadraticCurveTo

        public QuadraticCurveTo​(boolean relative,
                                IOperatorConverter copier)
    • Method Detail

      • draw

        public void draw​(PdfCanvas canvas)
        Draws a quadratic Bezier curve from the current point to (x,y) using (x1,y1) as the control point
        Specified by:
        draw in interface IPathShape
        Parameters:
        canvas - to which this instruction is drawn
      • setCoordinates

        public void setCoordinates​(java.lang.String[] inputCoordinates,
                                   Point startPoint)
        Description copied from interface: IPathShape
        This method sets the coordinates for the path painting operator and does internal preprocessing, if necessary
        Specified by:
        setCoordinates in interface IPathShape
        Parameters:
        inputCoordinates - an array containing point values for path coordinates
        startPoint - the ending point of the previous operator, or, in broader terms, the point that the coordinates should be absolutized against, for relative operators
      • getLastControlPoint

        public Point getLastControlPoint()
        Description copied from interface: IControlPointCurve
        Returns coordinates of the last control point (the one closest to the ending point) in the Bezier curve, in SVG space coordinates
        Specified by:
        getLastControlPoint in interface IControlPointCurve
        Returns:
        coordinates of the last control point in SVG space coordinates
      • 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 <= t <= 1
        Parameters:
        x0 - x coordinate of the starting point
        y0 - y coordinate of the starting point
        x1 - x coordinate of the control point
        y1 - y coordinate of the control point
        x2 - x coordinate of the ending point
        y2 - 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 point
        y0 - y coordinate of the starting point
        x1 - x coordinate of the control point
        y1 - y coordinate of the control point
        x2 - x coordinate of the ending point
        y2 - y coordinate of the ending point
        Returns:
        array of theta values corresponding to extreme points
      • addTValueToList

        private static void addTValueToList​(double t,
                                            java.util.List<java.lang.Double> tValuesList)
        Check that t is in the range [0, 1] and add it to list
        Parameters:
        t - value of t
        tValuesList - list storing t values
      • getTValue

        private static double getTValue​(double p0,
                                        double p1,
                                        double p2)
      • calculateExtremeCoordinate

        private static double calculateExtremeCoordinate​(double t,
                                                         double p0,
                                                         double p1,
                                                         double p2)