Package snap.geom

Class Path2D

All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
Path2DX

public class Path2D extends ShapeBuilder implements Cloneable
A standard path shape that can be built/modified by standard moveTo/lineTo/curveTo methods.
  • Field Details

    • _segs

      protected Seg[] _segs
    • _segCount

      protected int _segCount
    • _points

      protected double[] _points
    • _pointCount

      protected int _pointCount
    • _segPointIndexes

      protected int[] _segPointIndexes
  • Constructor Details

    • Path2D

      public Path2D()
      Constructor.
    • Path2D

      public Path2D(Shape aShape)
      Constructor with given shape.
    • Path2D

      public Path2D(PathIter aPathIter)
      Constructor with given PathIter.
  • Method Details

    • getSegCount

      public int getSegCount()
      Returns the number of segments.
    • getSeg

      public Seg getSeg(int anIndex)
      Returns the individual segment at given index.
    • addSeg

      protected void addSeg(Seg aSeg)
      Adds a segment.
    • getPointCount

      public int getPointCount()
      Returns the number of points.
    • getPoint

      public Point getPoint(int anIndex)
      Returns individual point at given index.
    • setPoint

      public void setPoint(int anIndex, double aX, double aY)
      Sets the individual point at given index.
    • addPoint

      protected void addPoint(double aX, double aY)
      Adds a point.
    • moveTo

      public void moveTo(double aX, double aY)
      Moveto.
      Specified by:
      moveTo in class ShapeBuilder
    • lineTo

      public void lineTo(double aX, double aY)
      LineTo.
      Specified by:
      lineTo in class ShapeBuilder
    • quadTo

      public void quadTo(double cpX, double cpY, double endX, double endY)
      QuadTo.
      Specified by:
      quadTo in class ShapeBuilder
    • curveTo

      public void curveTo(double cp1x, double cp1y, double cp2x, double cp2y, double endX, double endY)
      CubicTo.
      Specified by:
      curveTo in class ShapeBuilder
    • close

      public void close()
      Close.
      Specified by:
      close in class ShapeBuilder
    • clear

      public void clear()
      Clears all segments from path.
    • getLastSeg

      public Seg getLastSeg()
      Returns the last seg.
    • getLastPoint

      public Point getLastPoint()
      Returns the last point.
    • getLastPointX

      public double getLastPointX()
      Returns the last point X.
      Specified by:
      getLastPointX in class ShapeBuilder
    • getLastPointY

      public double getLastPointY()
      Returns the last point Y.
      Specified by:
      getLastPointY in class ShapeBuilder
    • getSegPointIndex

      public int getSegPointIndex(int anIndex)
      Returns the array of point-indexes for given seg index.
    • getSegAndPointsForIndex

      public Seg getSegAndPointsForIndex(int anIndex, double[] theCoords, Transform aTrans)
      Returns the control points and end point for a given seg index, by copying to given array (should be length of 6).
    • getSegIndexForPointIndex

      public int getSegIndexForPointIndex(int anIndex)
      Returns the seg index for given point index.
    • removeLastSeg

      public void removeLastSeg()
      Removes the last segment.
    • getWinding

      public int getWinding()
      Returns the winding - how a path determines what to fill when segments intersect.
    • setWinding

      public void setWinding(int aValue)
      Sets the winding - how a path determines what to fill when segments intersect.
    • fitToCurveFromPointIndex

      public void fitToCurveFromPointIndex(int pointIndex)
      Fits the path points to a curve starting at the given point index.
    • copyFor

      public Path2D copyFor(Rect aRect)
      Override to return as path.
      Overrides:
      copyFor in class Shape
    • clone

      public Path2D clone()
      Standard clone implementation.
      Overrides:
      clone in class Object
    • equals

      public boolean equals(Object anObj)
      Standard equals implementation.
      Overrides:
      equals in class Object
    • getPathIter

      public PathIter getPathIter(Transform aTrans)
      Returns a path iterator.
      Specified by:
      getPathIter in class Shape