APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.javafx.geom

public Class Path2D

extends Shape
implements PathConsumer2D
Class Inheritance
All Implemented Interfaces
com.sun.javafx.geom.PathConsumer2D
Imports
com.sun.javafx.geom.transform.BaseTransform, java.util.Arrays

The 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.

Version
1.10, 05/05/07

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
public static enum
pack-priv abstract static class
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField 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
Inherited from com.sun.javafx.geom.Shape:
OUT_BOTTOMOUT_LEFTOUT_RIGHTOUT_TOPRECT_INTERSECTS

Constructor Summary

AccessConstructor and Description
public
Path2D()

Constructs a new empty single precision Path2D object with a default winding rule of WIND_NON_ZERO.

public
Path2D(int
the winding rule
rule
)

Constructs a new empty single precision Path2D object with the specified winding rule to control operations that require the interior of the path to be defined.

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 Path2D object with the specified winding rule and the specified initial capacity to store path segments.

public
Path2D(Shape
the specified Shape object
s
)

Constructs a new single precision Path2D object from an arbitrary Shape object.

public
Path2D(Shape
the specified Shape object
s
,
BaseTransform
the specified BaseTransform object
tx
)

Constructs a new single precision Path2D object from an arbitrary Shape object, transformed by an BaseTransform object.

public
Path2D(int windingRule, byte[] pointTypes, int numTypes, float[] pointCoords, int numCoords)

Construct a Path2D from pre-composed data.

Method Summary

Modifier and TypeMethod and Description
public final void
append(PathIterator pi, boolean connect)

public final void
append(Shape
the Shape whose geometry is appended to this path
s
,
boolean
a boolean to control whether or not to turn an initial moveTo segment into a lineTo segment to connect the new geometry to the existing path
connect
)

Appends the geometry of the specified Shape object to the path, possibly connecting the new geometry to the existing path segments with a line segment.

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.CornerPrefix
the specification of what additional path segments should be appended to lead the current path to the starting point
prefix
)

Append a section of a quadrant of an oval to the current path.

public final void
appendSVGPath(String
the String object containing the SVG style definition of the geometry to be apppended
svgpath
)

Appends the geometry of the path in the specified String argument in the format of an SVG path.

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 rectangle
checkAndGetIntRect
(Rectangle
the Rectangle to return the rectangular area, or null
retrect
,
float
the 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 Rectangle with the integer representation of the rectangle if it is.

private boolean
close(int ix, float fx, float tolerance)

public final void
closePath()

Implements com.sun.javafx.geom.PathConsumer2D.closePath.

Closes the current subpath by drawing a straight line back to the coordinates of the last moveTo.

public static boolean

Returns:

true if the specified coordinates are inside the specified PathIterator; false otherwise
contains
(PathIterator
the specified PathIterator
pi
,
float
the specified X coordinate
x
,
float
the specified Y coordinate
y
)

Tests if the specified coordinates are inside the closed boundary of the specified PathIterator.

public static boolean

Returns:

true if the specified coordinates are inside the specified PathIterator; false otherwise
contains
(PathIterator
the specified PathIterator
pi
,
Point2D
the specified Point2D
p
)

Tests if the specified Point2D is inside the closed boundary of the specified PathIterator.

public final boolean
contains(float x, float y)

Implements abstract com.sun.javafx.geom.Shape.contains.

Tests if the specified coordinates are inside the boundary of the Shape.

public final boolean
contains(Point2D p)

Overrides com.sun.javafx.geom.Shape.contains.

Tests if a specified Point2D is inside the boundary of the Shape.

public static boolean

Returns:

true if the specified PathIterator contains the specified rectangluar area; false otherwise.
contains
(PathIterator
the specified PathIterator
pi
,
float
the 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 PathIterator.

public final boolean
contains(float x, float y, float w, float h)

Implements abstract com.sun.javafx.geom.Shape.contains.

Tests if the interior of the Shape entirely contains the specified rectangular area.

public Path2D
copy()

Implements abstract com.sun.javafx.geom.Shape.copy.

Returns a new copy of this Shape instance.

public final Shape

Returns:

a new Shape, transformed with the specified BaseTransform.
createTransformedShape
(BaseTransform
the BaseTransform used to transform a new Shape.
tx
)

Returns a new Shape representing a transformed version of this Path2D.

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.sun.javafx.geom.PathConsumer2D.curveTo.

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 (x3,y3), using the specified points (x1,y1) and (x2,y2) as Bézier control points.

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 (x3,y3), using the specified points (x1,y1) and (x2,y2) as Bézier control points.

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 (x3,y3), using the specified point (x2,y2) as the second Bézier control point and a first Bézier control point that is positioned symmetrically across the current point from the previous curve control point.

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 (rx3,ry3), using the specified relative point (rx2,ry2) as the second Bézier control point and a first Bézier control point that is positioned symmetrically across the current point from the previous curve control point.

public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

pack-priv static float[]
expandCoords(float[] oldCoords, int needed)

pack-priv static byte[]
expandPointTypes(byte[] oldPointTypes, int needed)

public final RectBounds
getBounds()

Implements abstract com.sun.javafx.geom.Shape.getBounds.

Note that there is no guarantee that the returned RectBounds is the smallest bounding box that encloses the Shape, only that the Shape lies entirely within the indicated RectBounds.

public final byte[]
public final Point2D

Returns:

a Point2D object containing the ending coordinates of the path or null if there are no points in the path.
getCurrentPoint
()

Returns the coordinates most recently added to the end of the path as a Point2D object.

public final float
public final float
public final float[]
public final int
public PathIterator
getPathIterator(BaseTransform tx)

Implements abstract com.sun.javafx.geom.Shape.getPathIterator.

Returns an iterator object that iterates along the Shape boundary and provides access to the geometry of the Shape outline.

public PathIterator
getPathIterator(BaseTransform tx, float flatness)

Implements abstract com.sun.javafx.geom.Shape.getPathIterator.

Returns an iterator object that iterates along the Shape boundary and provides access to a flattened view of the Shape outline geometry.

pack-priv Point2D
getPoint(int coordindex)

public final int

Returns:

an integer representing the current winding rule.
getWindingRule
()

Returns the fill style winding rule.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public static boolean

Returns:

true if the specified PathIterator and the interior of the specified set of rectangular coordinates intersect each other; false otherwise.
intersects
(PathIterator
the specified PathIterator
pi
,
float
the 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 PathIterator intersects the interior of a specified set of rectangular coordinates.

public final boolean
intersects(float x, float y, float w, float h)

Implements abstract com.sun.javafx.geom.Shape.intersects.

Tests if the interior of the Shape intersects the interior of a specified rectangular area.

public final void
lineTo(float
the specified X coordinate
x
,
float
the specified Y coordinate
y
)

Implements com.sun.javafx.geom.PathConsumer2D.lineTo.

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.sun.javafx.geom.PathConsumer2D.moveTo.

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
needRoom(boolean needMove, int newCoords)

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
pointCrossings(float px, float py)

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.sun.javafx.geom.PathConsumer2D.quadTo.

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 (x2,y2), using the specified point (x1,y1) as a quadratic parametric control point.

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 (rx2,ry2), using the specified relative point (rx1,ry1) as a quadratic parametric control point.

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 (x,y), using a quadratic parametric control point that is positioned symmetrically across the current point from the previous curve control point.

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 (x,y), using a quadratic parametric control point that is positioned symmetrically across the current point from the previous curve control point.

pack-priv int
rectCrossings(float rxmin, float rymin, float rxmax, float rymax)

public final void
reset()

Resets the path to empty.

public void
setTo(Path2D otherPath)

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
Inherited from com.sun.javafx.geom.Shape:
accumulateaccumulateCubicaccumulateCubicaccumulateQuadcontainsintersectsintersectsLineoutcodepointCrossingsForCubicpointCrossingsForLinepointCrossingsForPathpointCrossingsForQuadrectCrossingsForCubicrectCrossingsForLinerectCrossingsForPathrectCrossingsForQuad