Interface Path2D<ST extends Shape2D<?,​?,​I,​P,​V,​B>,​IT extends Path2D<?,​?,​I,​P,​V,​B>,​I extends PathIterator2D<?>,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Shape2D<?,​?,​I,​P,​V,​B>>

  • Type Parameters:
    ST - is the type of the general implementation.
    IT - is the type of the implementation of this shape.
    I - is the type of the iterator used to obtain the elements of the path.
    P - is the type of the points.
    V - is the type of the vectors.
    B - is the type of the bounding boxes.
    All Superinterfaces:
    Cloneable, JsonableObject, Serializable, Shape2D<ST,​IT,​I,​P,​V,​B>
    All Known Subinterfaces:
    Path2afp<ST,​IT,​IE,​P,​V,​B>, Path2ai<ST,​IT,​IE,​P,​V,​B>
    All Known Implementing Classes:
    Path2d, Path2dfx, Path2i, Path2ifx

    public interface Path2D<ST extends Shape2D<?,​?,​I,​P,​V,​B>,​IT extends Path2D<?,​?,​I,​P,​V,​B>,​I extends PathIterator2D<?>,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Shape2D<?,​?,​I,​P,​V,​B>>
    extends Shape2D<ST,​IT,​I,​P,​V,​B>
    2D Path.
    Since:
    13.0
    Version:
    17.0 2020-01-04 14:41:43
    Author:
    Stéphane GALLAND
    Maven Group Id:
    org.arakhne.afc.core
    Maven Artifact Id:
    mathgeom
    • Method Detail

      • getWindingRule

        @Pure
        PathWindingRule getWindingRule()
        Replies the winding rule for the path.
        Returns:
        the winding rule for the path.
      • setWindingRule

        void setWindingRule​(PathWindingRule rule)
        Set the winding rule for the path.
        Parameters:
        rule - is the winding rule for the path.
      • isPolyline

        @Pure
        boolean isPolyline()
        Replies the path is composed only by one MOVE_TO, and a sequence of LINE_TO primitives.
        Returns:
        true if the path does not contain curve primitives, false otherwise.
      • isCurved

        @Pure
        boolean isCurved()
        Replies the path contains a curve..
        Returns:
        true if the path does not contain curve primitives, false otherwise.
      • isMultiParts

        @Pure
        boolean isMultiParts()
        Replies the path has multiple parts, i.e. multiple MOVE_TO are inside. primitives.
        Returns:
        true if the path has multiple move-to primitive, false otherwise.
      • isPolygon

        @Pure
        boolean isPolygon()
        Replies the path is composed only by one MOVE_TO, a sequence of LINE_TO or QUAD_TO or CURVE_TO, or ARC_TO, and a single CLOSE primitives.
        Returns:
        true if the path does not contain curve primitives, false otherwise.
      • getPathIterator

        @Pure
        I getPathIterator​(double flatness)
        Replies an iterator on the path elements.

        Only PathElementType.MOVE_TO, PathElementType.LINE_TO, and PathElementType.CLOSE types are returned by the iterator.

        The amount of subdivision of the curved segments is controlled by the flatness parameter, which specifies the maximum distance that any point on the unflattened transformed curve can deviate from the returned flattened path segments. Note that a limit on the accuracy of the flattened path might be silently imposed, causing very small flattening parameters to be treated as larger values. This limit, if there is one, is defined by the particular implementation that is used.

        The iterator for this class is not multi-threaded safe.

        Parameters:
        flatness - is the maximum distance that the line segments used to approximate the curved segments are allowed to deviate from any point on the original curve.
        Returns:
        an iterator on the path elements.
      • moveTo

        void moveTo​(Point2D<?,​?> position)
        Adds a point to the path by moving to the specified coordinates specified in double precision.
        Parameters:
        position - the new position.
      • moveToIfFar

        void moveToIfFar​(Point2D<?,​?> position)
        Adds a point to the path by moving to the specified coordinates specified in double precision.
        Parameters:
        position - the new position.
      • lineTo

        void lineTo​(Point2D<?,​?> to)
        Adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates specified in double precision.
        Parameters:
        to - the end point
      • quadTo

        void quadTo​(Point2D<?,​?> ctrl,
                    Point2D<?,​?> to)
        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 specified coordinates (x2, y2), using the specified point (x1, y1) as a quadratic parametric control point. All coordinates are specified in double precision.
        Parameters:
        ctrl - the quadratic control point
        to - the final end point
      • curveTo

        void curveTo​(Point2D<?,​?> ctrl1,
                     Point2D<?,​?> ctrl2,
                     Point2D<?,​?> to)
        Adds a curved segment, defined by three new points, to the path by drawing a Bézier curve that intersects both the current coordinates and the specified coordinates (x3, y3), using the specified points (x1, y1) and (x2, y2) as Bézier control points. All coordinates are specified in double precision.
        Parameters:
        ctrl1 - the first Bézier control point
        ctrl2 - the second Bézier control point
        to - the final end point
      • arcTo

        void arcTo​(Point2D<?,​?> ctrl,
                   Point2D<?,​?> to,
                   double tfrom,
                   double tto,
                   Path2D.ArcType type)
        Adds a section of an shallow ellipse to the current path. The ellipse from which a quadrant is taken is the ellipse that would be inscribed in a parallelogram defined by 3 points, The current point which is considered to be the midpoint of the edge leading into the corner of the ellipse where the ellipse grazes it, (ctrlx, ctrly) which is considered to be the location of the corner of the parallelogram in which the ellipse is inscribed, and (tox, toy) which is considered to be the midpoint of the edge leading away from the corner of the oval where the oval grazes it.

        Only the portion of the ellipse from tfrom to tto will be included where 0f represents the point where the ellipse grazes the leading edge, 1f represents the point where the oval grazes the trailing edge, and 0.5f represents the point on the oval closest to the control point. The two values must satisfy the relation (0 <= tfrom <= tto <= 1).

        If tfrom is not 0f then the caller would most likely want to use one of the arc type values that inserts a segment leading to the initial point. An initial moveTo(Point2D) or lineTo(Point2D) can be added to direct the path to the starting point of the ellipse section if Path2D.ArcType.MOVE_THEN_ARC or Path2D.ArcType.LINE_THEN_ARC are specified by the type argument. The lineTo path segment will only be added if the current point is not already at the indicated location to avoid spurious empty line segments. The type can be specified as Path2D.ArcType.ARC_ONLY if the current point on the path is known to be at the starting point of the ellipse section.

        Parameters:
        ctrl - the control point, i.e. the corner of the parallelogram in which the ellipse is inscribed.
        to - the target point.
        tfrom - the fraction of the ellipse section where the curve should start.
        tto - the fraction of the ellipse section where the curve should end
        type - the specification of what additional path segments should be appended to lead the current path to the starting point.
      • arcTo

        default void arcTo​(Point2D<?,​?> ctrl,
                           Point2D<?,​?> to)
        Adds a section of an shallow ellipse to the current path.

        This function is equivalent to:

        
         this.arcTo(ctrl, to, 0.0, 1.0, ArcType.ARCONLY);
         
        Parameters:
        ctrl - the control point, i.e. the corner of the parallelogram in which the ellipse is inscribed.
        to - the target point.
      • arcTo

        void arcTo​(Point2D<?,​?> to,
                   Vector2D<?,​?> radii,
                   double xAxisRotation,
                   boolean largeArcFlag,
                   boolean sweepFlag)
        Adds a section of an shallow ellipse to the current path. The ellipse from which the portions are extracted follows the rules:
        • The ellipse will have its X axis tilted from horizontal by the angle xAxisRotation specified in radians.
        • The ellipse will have the X and Y radii (viewed from its tilted coordinate system) specified by radiusx and radiusy unless that ellipse is too small to bridge the gap from the current point to the specified destination point in which case a larger ellipse with the same ratio of dimensions will be substituted instead.
        • The ellipse may slide perpendicular to the direction from the current point to the specified destination point so that it just touches the two points. The direction it slides (to the "left" or to the "right") will be chosen to meet the criteria specified by the two boolean flags as described below. Only one direction will allow the method to meet both criteria.
        • If the largeArcFlag is true, then the ellipse will sweep the longer way around the ellipse that meets these criteria.
        • If the sweepFlag is true, then the ellipse will sweep clockwise around the ellipse that meets these criteria.

        The method will do nothing if the destination point is the same as the current point. The method will draw a simple line segment to the destination point if either of the two radii are zero.

        Parameters:
        to - the target point.
        radii - the X and Y radii of the tilted ellipse.
        xAxisRotation - the angle of tilt of the ellipse.
        largeArcFlag - true iff the path will sweep the long way around the ellipse.
        sweepFlag - true iff the path will sweep clockwise around the ellipse.
        See Also:
        "http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands"
      • closePath

        void closePath()
        Closes the current subpath by drawing a straight line back to the coordinates of the last moveTo. If the path is already closed or if the previous coordinates are for a moveTo then this method has no effect.
      • toBoundingBoxWithCtrlPoints

        B toBoundingBoxWithCtrlPoints()
        Replies the bounding box of all the points added in this path.

        The replied bounding box includes the (invisible) control points.

        Returns:
        the bounding box with the control points.
        See Also:
        Shape2D.toBoundingBox()
      • toBoundingBoxWithCtrlPoints

        void toBoundingBoxWithCtrlPoints​(B box)
        Compute the bounding box of all the points added in this path.

        The replied bounding box includes the (invisible) control points.

        Parameters:
        box - is the rectangle to set with the bounds.
        See Also:
        Shape2D.toBoundingBox()
      • toIntArray

        @Pure
        default int[] toIntArray()
        Replies the coordinates of this path in an array of integer numbers.
        Returns:
        the coordinates.
      • toIntArray

        @Pure
        int[] toIntArray​(Transform2D transform)
        Replies the coordinates of this path in an array of integer numbers.
        Parameters:
        transform - is the transformation to apply to all the coordinates.
        Returns:
        the coordinates.
      • toFloatArray

        @Pure
        default float[] toFloatArray()
        Replies the coordinates of this path in an array of single precision floating-point numbers.
        Returns:
        the coordinates.
      • toFloatArray

        @Pure
        float[] toFloatArray​(Transform2D transform)
        Replies the coordinates of this path in an array of single precision floating-point numbers.
        Parameters:
        transform - is the transformation to apply to all the coordinates.
        Returns:
        the coordinates.
      • toDoubleArray

        @Pure
        default double[] toDoubleArray()
        Replies the coordinates of this path in an array of double precision floating-point numbers.
        Returns:
        the coordinates.
      • toDoubleArray

        @Pure
        double[] toDoubleArray​(Transform2D transform)
        Replies the coordinates of this path in an array of double precision floating-point numbers.
        Parameters:
        transform - is the transformation to apply to all the coordinates.
        Returns:
        the coordinates.
      • toPointArray

        @Pure
        default P[] toPointArray()
        Replies the points of this path in an array.
        Returns:
        the points.
      • toPointArray

        @Pure
        P[] toPointArray​(Transform2D transform)
        Replies the points of this path in an array.
        Parameters:
        transform - is the transformation to apply to all the points.
        Returns:
        the points.
      • toCollection

        @Pure
        Collection<P> toCollection()
        Replies the collection that is contains all the points of the path.
        Returns:
        the point collection.
      • getPointAt

        @Pure
        P getPointAt​(int index)
        Replies the point at the given index. The index is in [0;size()).
        Parameters:
        index - the index.
        Returns:
        the point at the given index.
      • getCurrentPoint

        @Pure
        P getCurrentPoint()
        Replies the last point in the path.
        Returns:
        the last point.
      • size

        @Pure
        int size()
        Replies the number of points in the path.
        Returns:
        the number of points in the path.
      • getPathElementCount

        @Pure
        int getPathElementCount()
        Replies the number of path elements in this path.
        Returns:
        the number of path elements.
        See Also:
        getPathElementTypeAt(int)
      • getPathElementTypeAt

        @Pure
        PathElementType getPathElementTypeAt​(int index)
        Replies the type of the path element at the given position in this path.
        Parameters:
        index - the index of the path element.
        Returns:
        the type of the path element.
        See Also:
        getPathElementCount()
      • getLength

        @Pure
        default double getLength()
        Replies the total length of the path.
        Returns:
        the length of the path.
      • getLengthSquared

        @Pure
        double getLengthSquared()
        Replies the total squared length of the path.
        Returns:
        the length of the path.
      • removeLast

        void removeLast()
        Remove the last action.
      • setLastPoint

        void setLastPoint​(Point2D<?,​?> point)
        Change the coordinates of the last inserted point.
        Parameters:
        point - the point.
      • containsControlPoint

        @Pure
        boolean containsControlPoint​(Point2D<?,​?> point)
        Replies if the given points exists in the coordinates of this path.
        Parameters:
        point - the point.
        Returns:
        true if the point is a control point of the path.