Path2D class provides a simple, yet flexible
shape which represents an arbitrary geometric path.
It can fully represent any path which can be iterated by the
PathIterator interface including all of its segment
types and winding rules and it implements all of the
basic hit testing methods of the Shape interface.
Use Path2D when dealing with data that can be represented
and used with floating point precision.
Path2D provides exactly those facilities required for
basic construction and management of a geometric path and
implementation of the above interfaces with little added
interpretation.
If it is useful to manipulate the interiors of closed
geometric shapes beyond simple hit testing then the
Area class provides additional capabilities
specifically targeted at closed figures.
While both classes nominally implement the Shape
interface, they differ in purpose and together they provide
two useful views of a geometric shape where Path2D
deals primarily with a trajectory formed by path segments
and Area deals more with interpretation and manipulation
of enclosed regions of 2D geometric space.
The PathIterator interface has more detailed descriptions
of the types of segments that make up a path and the winding rules
that control how to determine which regions are inside or outside
the path.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | |
| public static enum | |
| pack-priv abstract static class | |
| pack-priv static class | |
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv float | |
| pack-priv float | |
| pack-priv static final int[] | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv float[] | |
| pack-priv static final int | |
| pack-priv float | |
| pack-priv float | |
| pack-priv int | |
| pack-priv int | |
| pack-priv byte[] | |
| pack-priv float | |
| pack-priv float | |
| private static final byte | |
| private static final byte | |
| private static final byte | |
| private static final byte | |
| private static final byte | |
| public static final int | WIND_EVEN_ODD
An even-odd winding rule for determining the interior of a path. |
| public static final int | WIND_NON_ZERO
A non-zero winding rule for determining the interior of a path. |
| pack-priv int |
| Access | Constructor and Description |
|---|---|
| public | Path2D()
Constructs a new empty single precision |
| public | Path2D(int
the winding rule rule)Constructs a new empty single precision |
| public | Path2D(int
the winding rule rule, int the estimate for the number of path segments
in the path initialCapacity)Constructs a new empty single precision |
| public | |
| public | Path2D(Shape
the specified s, BaseTransform Shape objectthe specified tx)BaseTransform objectConstructs a new single precision |
| public | Path2D(int windingRule, byte[] pointTypes, int numTypes, float[] pointCoords, int numCoords)
Construct a Path2D from pre-composed data. |
| Modifier and Type | Method and Description |
|---|---|
| public final void | |
| public final void | append(Shape
the s, boolean Shape whose geometry is appended
to this patha boolean to control whether or not to turn an initial
connect)moveTo segment into a lineTo segment
to connect the new geometry to the existing pathAppends the geometry of the specified |
| public final void | appendOvalQuadrant(float
the X coordinate of the midpoint of the leading edge
interpolated by the oval sx, float the Y coordinate of the midpoint of the leading edge
interpolated by the oval sy, float the X coordinate of the corner cx, float the Y coordinate of the corner cy, float the X coordinate of the midpoint of the trailing edge
interpolated by the oval ex, float the Y coordinate of the midpoint of the trailing edge
interpolated by the oval ey, float the fraction of the oval section where the curve should start tfrom, float the fraction of the oval section where the curve should end tto, Path2D.the specification of what additional path segments should
be appended to lead the current path to the starting point prefixAppend a section of a quadrant of an oval to the current path. |
| public final void | appendSVGPath(String
the svgpath)String object containing the SVG style
definition of the geometry to be apppendedAppends the geometry of the path in the specified |
| public void | arcTo(float
the X radius of the tilted ellipse radiusx, float the Y radius of the tilted ellipse radiusy, float the angle of tilt of the ellipse xAxisRotation, boolean true iff the path will sweep the long way around
the ellipse largeArcFlag, boolean true iff the path will sweep clockwise around
the ellipse sweepFlag, float the destination X coordinate x, float the destination Y coordinate y)Append a portion of an ellipse to the path. |
| public void | arcToRel(float
the X radius of the tilted ellipse radiusx, float the Y radius of the tilted ellipse radiusy, float the angle of tilt of the ellipse xAxisRotation, boolean true iff the path will sweep the long way around
the ellipse largeArcFlag, boolean true iff the path will sweep clockwise around
the ellipse sweepFlag, float the relative destination relative X coordinate relx, float the relative destination relative Y coordinate rely)Append a portion of an ellipse to the path using relative coordinates. |
| public boolean | Returns: true iff the path is a simple rectanglethe retrect, float Rectangle to return the rectangular area,
or nullthe maximum difference from an integer allowed
for any edge of the rectangle tolerance)Check and return if the fillable interior of the path is a simple
rectangle on nearly integer bounds and initialize the indicated
|
| private boolean | |
| public final void | closePath()
Implements com. Closes the current subpath by drawing a straight line back to
the coordinates of the last |
| public static boolean | Returns: true if the specified coordinates are inside the
specified PathIterator; false otherwisethe specified pi, float PathIteratorthe specified X coordinate x, float the specified Y coordinate y)Tests if the specified coordinates are inside the closed
boundary of the specified |
| public static boolean | Returns: true if the specified coordinates are inside the
specified PathIterator; false otherwisethe specified pi, Point2D PathIteratorthe specified p)Point2DTests if the specified |
| public final boolean | contains(float x, float y)
Implements abstract com. Tests if the specified coordinates are inside the boundary of the
|
| public final boolean | contains(Point2D p)
Overrides com. Tests if a specified |
| public static boolean | Returns: true if the specified PathIterator contains
the specified rectangluar area; false otherwise.the specified pi, float PathIteratorthe specified X coordinate x, float the specified Y coordinate y, float the width of the specified rectangular area w, float the height of the specified rectangular area h)Tests if the specified rectangular area is entirely inside the
closed boundary of the specified |
| public final boolean | contains(float x, float y, float w, float h)
Implements abstract com. Tests if the interior of the |
| public Path2D | copy()
Implements abstract com. Returns a new copy of this |
| public final Shape | Returns: a newShape, transformed with the specified
BaseTransform.the tx)BaseTransform used to transform a
new Shape.Returns a new |
| public final void | curveTo(float
the X coordinate of the first Bézier control point x1, float the Y coordinate of the first Bézier control point y1, float the X coordinate of the second Bézier control point x2, float the Y coordinate of the second Bézier control point y2, float the X coordinate of the final end point x3, float the Y coordinate of the final end point y3)Implements com. Adds a curved segment to the path, defined by three new points, by
drawing a Bézier curve that intersects both the current
coordinates and the specified coordinates |
| public final void | curveToRel(float
the relative X coordinate of the first Bézier control point relx1, float the relative Y coordinate of the first Bézier control point rely1, float the relative X coordinate of the second Bézier control point relx2, float the relative Y coordinate of the second Bézier control point rely2, float the relative X coordinate of the final end point relx3, float the relative Y coordinate of the final end point rely3)Adds a curved segment to the path, defined by three new points
relative to the current point, by
drawing a Bézier curve that intersects both the current
coordinates and the specified coordinates |
| public final void | curveToSmooth(float
the X coordinate of the second Bézier control point x2, float the Y coordinate of the second Bézier control point y2, float the X coordinate of the final end point x3, float the Y coordinate of the final end point y3)Adds a curved segment to the path, defined by two new points and
a third point inferred from the previous curve, by
drawing a Bézier curve that intersects both the current
coordinates and the specified coordinates |
| public final void | curveToSmoothRel(float
the relative X coordinate of the second Bézier control point relx2, float the relative Y coordinate of the second Bézier control point rely2, float the relative X coordinate of the final end point relx3, float the relative Y coordinate of the final end point rely3)Adds a curved segment to the path, defined by two new points relative
to the current point and
a third point inferred from the previous curve, by
drawing a Bézier curve that intersects both the current
coordinates and the specified relative coordinates |
| public boolean | equals(Object obj)
Overrides java. Indicates whether some other object is "equal to" this one. |
| pack-priv static float[] | |
| pack-priv static byte[] | |
| public final RectBounds | getBounds()
Implements abstract com. Note that there is no guarantee that the returned
|
| public final byte[] | |
| public final Point2D | Returns: aPoint2D object containing the ending coordinates of
the path or null if there are no points in the path.Returns the coordinates most recently added to the end of the path
as a |
| public final float | |
| public final float | |
| public final float[] | |
| public final int | |
| public PathIterator | getPathIterator(BaseTransform tx)
Implements abstract com. Returns an iterator object that iterates along the
|
| public PathIterator | getPathIterator(BaseTransform tx, float flatness)
Implements abstract com. Returns an iterator object that iterates along the |
| pack-priv Point2D | |
| public final int | Returns: an integer representing the current winding rule.Returns the fill style winding rule. |
| public int | |
| public static boolean | Returns: true if the specified PathIterator and
the interior of the specified set of rectangular
coordinates intersect each other; false otherwise.the specified pi, float PathIteratorthe specified X coordinate x, float the specified Y coordinate y, float the width of the specified rectangular coordinates w, float the height of the specified rectangular coordinates h)Tests if the interior of the specified |
| public final boolean | intersects(float x, float y, float w, float h)
Implements abstract com. Tests if the interior of the |
| public final void | lineTo(float
the specified X coordinate x, float the specified Y coordinate y)Implements com. Adds a point to the path by drawing a straight line from the current coordinates to the new coordinates. |
| public final void | lineToRel(float
the specified relative X coordinate relx, float the specified relative Y coordinate rely)Adds a point to the path by drawing a straight line from the current coordinates to the new coordinates relative to the current point. |
| public final void | moveTo(float
the specified X coordinate x, float the specified Y coordinate y)Implements com. Adds a point to the path by moving to the specified coordinates specified in float precision. |
| public final void | moveToRel(float
the specified relative X coordinate relx, float the specified relative Y coordinate rely)Adds a point to the path by moving to the specified coordinates relative to the current point, specified in float precision. |
| pack-priv void | |
| public final void | ovalQuadrantTo(float
the X coordinate of the corner cx, float the Y coordinate of the corner cy, float the X coordinate of the midpoint of the trailing edge
interpolated by the oval ex, float the Y coordinate of the midpoint of the trailing edge
interpolated by the oval ey, float the fraction of the oval section where the curve should start tfrom, float the fraction of the oval section where the curve should end tto)Append a section of a quadrant of an oval to the current path, relative to the current point. |
| public void | |
| pack-priv int | |
| public final void | quadTo(float
the X coordinate of the quadratic control point x1, float the Y coordinate of the quadratic control point y1, float the X coordinate of the final end point x2, float the Y coordinate of the final end point y2)Implements com. Adds a curved segment to the path, defined by two new points, by
drawing a Quadratic curve that intersects both the current
coordinates and the specified coordinates |
| public final void | quadToRel(float
the relative X coordinate of the quadratic control point relx1, float the relative Y coordinate of the quadratic control point rely1, float the relative X coordinate of the final end point relx2, float the relative Y coordinate of the final end point rely2)Adds a curved segment to the path, defined by two new points
relative to the current point, by
drawing a Quadratic curve that intersects both the current
coordinates and the specified relative coordinates |
| public final void | quadToSmooth(float
the X coordinate of the final end point x2, float the Y coordinate of the final end point y2)Adds a curved segment to the path, defined by a new point, by
drawing a Quadratic curve that intersects both the current
coordinates and the specified coordinates |
| public final void | quadToSmoothRel(float
the relative X coordinate of the final end point relx2, float the relative Y coordinate of the final end point rely2)Adds a curved segment to the path, defined by a new point
relative to the current point, by
drawing a Quadratic curve that intersects both the current
coordinates and the specified relative coordinates |
| pack-priv int | |
| public final void | |
| public void | |
| public final void | setWindingRule(int
an integer representing the specified
winding rule rule)Sets the winding rule for this path to the specified value. |
| public final void |