Class PathWriter

    • Constructor Summary

      Constructors

      Constructor and Description
      PathWriter()
       
    • Method Summary

      Modifier and Type Method and Description
      abstract void closePath()
      Closes the current subpath by drawing a straight line back to the coordinates of the last moveTo.
      static void cubicTo(GeneralPath path, double t0, double t1, double ax, double bx, double cx, double dx, double ay, double by, double cy, double dy)
      This appends a cubic curve to the GeneralPath provided that ranges from t = t0 to t = t1.
      static void cubicTo(PathWriter path, double t0, double t1, double ax, double bx, double cx, double dx, double ay, double by, double cy, double dy)
      This appends a cubic curve to the PathWriter provided that ranges from t = t0 to t = t1.
      abstract void curveTo(float cx1, float cy1, float cx2, float cy2, float x, float y)
      Adds a curved segment, defined by three new points, to the path by drawing a Bezier curve that intersects both the current coordinates and the coordinates (x3, y3), using the specified points (x1, y1) and (x2, y2) as Bezier control points.
      abstract void flush()
      This guarantees that this writer has flushed all currently written information.
      abstract void lineTo(float x, float y)
      Adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates.
      abstract void moveTo(float x, float y)
      Adds a point to the path by moving to the specified coordinates.
      abstract void quadTo(float cx, float cy, float x, float y)
      Adds a curved segment, defined by two new points, to the path by drawing a Quadratic curve that intersects both the current coordinates and the coordinates (x2, y2), using the specified point (x1, y1) as a quadratic parametric control point.
      static void quadTo(GeneralPath path, double t0, double t1, double ax, double bx, double cx, double ay, double by, double cy)
      This appends a quadratic curve to the GeneralPath provided that ranges from t = t0 to t = t1.
      static void quadTo(PathWriter path, double t0, double t1, double ax, double bx, double cx, double ay, double by, double cy)
      This appends a quadratic curve to the PathWriter provided that ranges from t = t0 to t = t1.
      void write(PathIterator i)
      Writes a path.
      void write(Shape s)
      Writes a shape.
    • Constructor Detail

      • PathWriter

        public PathWriter()
    • Method Detail

      • moveTo

        public abstract void moveTo(float x,
                                    float y)
        Adds a point to the path by moving to the specified coordinates.
        Parameters:
        x - the x-coordinate to move to
        y - the y-coordinate to move to
      • lineTo

        public abstract void lineTo(float x,
                                    float y)
        Adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates.
        Parameters:
        x - the x-coordinate of the end point.
        y - the y-coordinate of the end point.
      • quadTo

        public abstract void quadTo(float cx,
                                    float cy,
                                    float x,
                                    float y)
        Adds a curved segment, defined by two new points, to the path by drawing a Quadratic curve that intersects both the current coordinates and the coordinates (x2, y2), using the specified point (x1, y1) as a quadratic parametric control point.
        Parameters:
        cx - the x-coordinate of the control point.
        cy - the y-coordinate of the control point.
        x - the x-coordinate of the end point.
        y - the y-coordinate of the end point.
      • curveTo

        public abstract void curveTo(float cx1,
                                     float cy1,
                                     float cx2,
                                     float cy2,
                                     float x,
                                     float y)
        Adds a curved segment, defined by three new points, to the path by drawing a Bezier curve that intersects both the current coordinates and the coordinates (x3, y3), using the specified points (x1, y1) and (x2, y2) as Bezier control points.
        Parameters:
        cx1 - the x-coordinate of the first control point.
        cy1 - the y-coordinate of the first control point.
        cx2 - the x-coordinate of the second control point.
        cy2 - the y-coordinate of the second control point.
        x - the x-coordinate of the end point.
        y - the y-coordinate of the end point.
      • closePath

        public abstract void closePath()
        Closes the current subpath by drawing a straight line back to the coordinates of the last moveTo.
      • flush

        public abstract void flush()
        This guarantees that this writer has flushed all currently written information.

        For example, some writers may need to perform complex calculations and re-organize shapes. Or some writers may simply be buffering path instructions to better manage memory. Calling this method guarantees that all path instructions be immediately processed.

        Because some writers may be manipulating path data you should not call this method until all shape data has been written.

      • write

        public void write(Shape s)
        Writes a shape.

        This iterates through the shape and makes the appropriate calls to moveTo(), curveTo(), etc.

        Parameters:
        s - the shape to write.
      • write

        public void write(PathIterator i)
        Writes a path.

        This iterates through the path and makes the appropriate calls to moveTo(), curveTo(), etc.

        Parameters:
        i - the path to write.
      • cubicTo

        public static void cubicTo(GeneralPath path,
                                   double t0,
                                   double t1,
                                   double ax,
                                   double bx,
                                   double cx,
                                   double dx,
                                   double ay,
                                   double by,
                                   double cy,
                                   double dy)
        This appends a cubic curve to the GeneralPath provided that ranges from t = t0 to t = t1. This assumes that the path already ends at the point (ax*t0*t0*t0+bx*t0*t0+cx*t0+dx, ay*t0*t0*t0+by*t0*t0+cy*t0+dx).
        Parameters:
        path - the path to append data to.
        t0 - the t-value for the beginning of this curve
        t1 - the t-value for the end of this curve
        ax - the coefficient for the (t^3) term of the x parametric equation
        bx - the coefficient for the (t^2) term of the x parametric equation
        cx - the coefficient for the t term of the x parametric equation
        dx - the constant for the x parametric equation.
        ay - the coefficient for the (t^3) term of the y parametric equation
        by - the coefficient for the (t^2) term of the y parametric equation
        cy - the coefficient for the t term of the y parametric equation
        dy - the constant for the y parametric equation.
      • cubicTo

        public static void cubicTo(PathWriter path,
                                   double t0,
                                   double t1,
                                   double ax,
                                   double bx,
                                   double cx,
                                   double dx,
                                   double ay,
                                   double by,
                                   double cy,
                                   double dy)
        This appends a cubic curve to the PathWriter provided that ranges from t = t0 to t = t1. This assumes that the path already ends at the point (ax*t0*t0*t0+bx*t0*t0+cx*t0+dx, ay*t0*t0*t0+by*t0*t0+cy*t0+dx).
        Parameters:
        path - the path to append data to.
        t0 - the t-value for the beginning of this curve
        t1 - the t-value for the end of this curve
        ax - the coefficient for the (t^3) term of the x parametric equation
        bx - the coefficient for the (t^2) term of the x parametric equation
        cx - the coefficient for the t term of the x parametric equation
        dx - the constant for the x parametric equation.
        ay - the coefficient for the (t^3) term of the y parametric equation
        by - the coefficient for the (t^2) term of the y parametric equation
        cy - the coefficient for the t term of the y parametric equation
        dy - the constant for the y parametric equation.
      • quadTo

        public static void quadTo(GeneralPath path,
                                  double t0,
                                  double t1,
                                  double ax,
                                  double bx,
                                  double cx,
                                  double ay,
                                  double by,
                                  double cy)
        This appends a quadratic curve to the GeneralPath provided that ranges from t = t0 to t = t1. This assumes that the path already ends at the point (ax*t0*t0+bx*t0+cx, ay*t0*t0+by*t0+cy).
        Parameters:
        path - the path to append data to.
        t0 - the t-value for the beginning of this curve
        t1 - the t-value for the end of this curve
        ax - the coefficient for the (t^2) term of the x parametric equation
        bx - the coefficient for the t term of the x parametric equation
        cx - the constant for the x parametric equation.
        ay - the coefficient for the (t^2) term of the y parametric equation
        by - the coefficient for the t term of the y parametric equation
        cy - the constant for the y parametric equation.
      • quadTo

        public static void quadTo(PathWriter path,
                                  double t0,
                                  double t1,
                                  double ax,
                                  double bx,
                                  double cx,
                                  double ay,
                                  double by,
                                  double cy)
        This appends a quadratic curve to the PathWriter provided that ranges from t = t0 to t = t1. This assumes that the path already ends at the point (ax*t0*t0+bx*t0+cx, ay*t0*t0+by*t0+cy).
        Parameters:
        path - the path to append data to.
        t0 - the t-value for the beginning of this curve
        t1 - the t-value for the end of this curve
        ax - the coefficient for the (t^2) term of the x parametric equation
        bx - the coefficient for the t term of the x parametric equation
        cx - the constant for the x parametric equation.
        ay - the coefficient for the (t^2) term of the y parametric equation
        by - the coefficient for the t term of the y parametric equation
        cy - the constant for the y parametric equation.