Class GeneralPathWriter



  • public class GeneralPathWriter
    extends PathWriter
    This writes path data to an underlying GeneralPath.

    This also omits redundant path information, such as two consecutive calls to lineTo() that go to the same point.

    Also this is safe to make several consecutive calls to closePath() (the GeneralPath will only be closed once, unless data has been written in the meantime.)

    • Method Summary

      Modifier and Type Method and Description
      void closePath()
      Closes the current subpath by drawing a straight line back to the coordinates of the last moveTo.
      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.
      void flush()
      This guarantees that this writer has flushed all currently written information.
      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.
      void moveTo(float x, float y)
      Adds a point to the path by moving to the specified coordinates.
      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.
      void reset()
      This resets the underlying GeneralPath.
      void setDebug(boolean b)
      If this is activated, output to the console will appear when shape instructions are written.
      void setEliminateRedundantLines(boolean eliminateRedundantLines)
       
      String toString()
       
    • Constructor Detail

      • GeneralPathWriter

        public GeneralPathWriter(GeneralPath p)
    • Method Detail

      • setEliminateRedundantLines

        public void setEliminateRedundantLines(boolean eliminateRedundantLines)
        Parameters:
        eliminateRedundantLines - if true then calls to lineTo() that only repeat the current pen position are ignored.
      • toString

        public String toString()
      • setDebug

        public void setDebug(boolean b)
        If this is activated, output to the console will appear when shape instructions are written.
      • flush

        public void flush()
        Description copied from class: PathWriter
        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.

      • reset

        public void reset()
        This resets the underlying GeneralPath.
      • curveTo

        public void curveTo(float cx1,
                            float cy1,
                            float cx2,
                            float cy2,
                            float x,
                            float y)
        Description copied from class: PathWriter
        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.
        Specified by:
        curveTo in class  PathWriter
        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.
      • lineTo

        public void lineTo(float x,
                           float y)
        Description copied from class: PathWriter
        Adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates.
        Specified by:
        lineTo in class  PathWriter
        Parameters:
        x - the x-coordinate of the end point.
        y - the y-coordinate of the end point.
      • moveTo

        public void moveTo(float x,
                           float y)
        Description copied from class: PathWriter
        Adds a point to the path by moving to the specified coordinates.
        Specified by:
        moveTo in class  PathWriter
        Parameters:
        x - the x-coordinate to move to
        y - the y-coordinate to move to
      • quadTo

        public void quadTo(float cx,
                           float cy,
                           float x,
                           float y)
        Description copied from class: PathWriter
        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.
        Specified by:
        quadTo in class  PathWriter
        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.
      • closePath

        public void closePath()
        Description copied from class: PathWriter
        Closes the current subpath by drawing a straight line back to the coordinates of the last moveTo.