| |
|
| java.lang.Object java.awt.geom.Path2D
All known Subclasses: java.awt.geom.GeneralPath,
Path2D | abstract public class Path2D implements Shape,Cloneable(Code) | | 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.Float when dealing with data that can be represented
and used with floating point precision. Use
Path2D.Double for data that requires the accuracy or range of double 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 author: Jim Graham since: 1.6 |
Inner Class :abstract static class Iterator implements PathIterator | |
Constructor Summary | |
| Path2D() Constructs a new empty
Path2D object. | | Path2D(int rule, int initialTypes) Constructs a new
Path2D object from the given
specified initial values. |
Method Summary | |
abstract void | append(float x, float y) | abstract void | append(double x, double y) | final public void | append(Shape s, boolean 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. | abstract public void | append(PathIterator pi, boolean connect) Appends the geometry of the specified
PathIterator object
to the path, possibly connecting the new geometry to the existing
path segments with a line segment. | abstract public Object | clone() Creates a new object of the same class as this object. | abstract double[] | cloneCoordsDouble(AffineTransform at) | abstract float[] | cloneCoordsFloat(AffineTransform at) | final public synchronized void | closePath() Closes the current subpath by drawing a straight line back to
the coordinates of the last
moveTo . | public static boolean | contains(PathIterator pi, double x, double y) Tests if the specified coordinates are inside the closed
boundary of the specified
PathIterator . | public static boolean | contains(PathIterator pi, Point2D p) Tests if the specified
Point2D is inside the closed
boundary of the specified
PathIterator . | final public boolean | contains(double x, double y) | final public boolean | contains(Point2D p) | public static boolean | contains(PathIterator pi, double x, double y, double w, double h) Tests if the specified rectangular area is entirely inside the
closed boundary of the specified
PathIterator . | public static boolean | contains(PathIterator pi, Rectangle2D r) Tests if the specified
Rectangle2D is entirely inside the
closed boundary of the specified
PathIterator . | final public boolean | contains(double x, double y, double w, double h)
This method object may conservatively return false in
cases where the specified rectangular area intersects a
segment of the path, but that segment does not represent a
boundary between the interior and exterior of the path. | final public boolean | contains(Rectangle2D r)
This method object may conservatively return false in
cases where the specified rectangular area intersects a
segment of the path, but that segment does not represent a
boundary between the interior and exterior of the path. | final public synchronized Shape | createTransformedShape(AffineTransform at) Returns a new
Shape representing a transformed version
of this
Path2D .
Note that the exact type and coordinate precision of the return
value is not specified for this method.
The method will return a Shape that contains no less precision
for the transformed geometry than this
Path2D currently
maintains, but it may contain no more precision either.
If the tradeoff of precision vs. | abstract public void | curveTo(double x1, double y1, double x2, double y2, double x3, double y3) 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. | final public Rectangle | getBounds() | final public synchronized Point2D | getCurrentPoint() Returns the coordinates most recently added to the end of the path
as a
Point2D object. | public PathIterator | getPathIterator(AffineTransform at, double flatness)
The iterator for this class is not multi-threaded safe,
which means that this
Path2D class does not
guarantee that modifications to the geometry of this
Path2D object do not affect any iterations of
that geometry that are already in process. | abstract Point2D | getPoint(int coordindex) | final public synchronized int | getWindingRule() Returns the fill style winding rule. | public static boolean | intersects(PathIterator pi, double x, double y, double w, double h) Tests if the interior of the specified
PathIterator intersects the interior of a specified set of rectangular
coordinates. | public static boolean | intersects(PathIterator pi, Rectangle2D r) Tests if the interior of the specified
PathIterator intersects the interior of a specified
Rectangle2D . | final public boolean | intersects(double x, double y, double w, double h)
This method object may conservatively return true in
cases where the specified rectangular area intersects a
segment of the path, but that segment does not represent a
boundary between the interior and exterior of the path. | final public boolean | intersects(Rectangle2D r)
This method object may conservatively return true in
cases where the specified rectangular area intersects a
segment of the path, but that segment does not represent a
boundary between the interior and exterior of the path. | abstract public void | lineTo(double x, double y) Adds a point to the path by drawing a straight line from the
current coordinates to the new specified coordinates
specified in double precision. | abstract public void | moveTo(double x, double y) Adds a point to the path by moving to the specified
coordinates specified in double precision. | abstract void | needRoom(boolean needMove, int newCoords) | abstract int | pointCrossings(double px, double py) | abstract public void | quadTo(double x1, double y1, double x2, double y2) 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. | final void | readObject(java.io.ObjectInputStream s, boolean storedbl) | abstract int | rectCrossings(double rxmin, double rymin, double rxmax, double rymax) | final public synchronized void | reset() Resets the path to empty. | final public void | setWindingRule(int rule) Sets the winding rule for this path to the specified value. | abstract public void | transform(AffineTransform at) Transforms the geometry of this path using the specified
AffineTransform . | final void | writeObject(java.io.ObjectOutputStream s, boolean isdbl) |
EXPAND_MAX | final static int EXPAND_MAX(Code) | | |
INIT_SIZE | final static int INIT_SIZE(Code) | | |
WIND_EVEN_ODD | final public static int WIND_EVEN_ODD(Code) | | An even-odd winding rule for determining the interior of
a path.
See Also: PathIterator.WIND_EVEN_ODD since: 1.6 |
WIND_NON_ZERO | final public static int WIND_NON_ZERO(Code) | | A non-zero winding rule for determining the interior of a
path.
See Also: PathIterator.WIND_NON_ZERO since: 1.6 |
numCoords | transient int numCoords(Code) | | |
numTypes | transient int numTypes(Code) | | |
pointTypes | transient byte[] pointTypes(Code) | | |
windingRule | transient int windingRule(Code) | | |
Path2D | Path2D()(Code) | | Constructs a new empty
Path2D object.
It is assumed that the package sibling subclass that is
defaulting to this constructor will fill in all values.
since: 1.6 |
Path2D | Path2D(int rule, int initialTypes)(Code) | | Constructs a new
Path2D object from the given
specified initial values.
This method is only intended for internal use and should
not be made public if the other constructors for this class
are ever exposed.
Parameters: rule - the winding rule Parameters: initialTypes - the size to make the initial array tostore the path segment types since: 1.6 |
append | abstract void append(float x, float y)(Code) | | |
append | abstract void append(double x, double y)(Code) | | |
append | final public void append(Shape s, boolean connect)(Code) | | 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.
If the
connect parameter is
true and the
path is not empty then any initial
moveTo in the
geometry of the appended
Shape is turned into a
lineTo segment.
If the destination coordinates of such a connecting
lineTo segment match the ending coordinates of a currently open
subpath then the segment is omitted as superfluous.
The winding rule of the specified
Shape is ignored
and the appended geometry is governed by the winding
rule specified for this path.
Parameters: s - the Shape whose geometry is appended to this path Parameters: connect - a boolean to control whether or not to turn an initial moveTo segment into a lineTo segmentto connect the new geometry to the existing path since: 1.6 |
append | abstract public void append(PathIterator pi, boolean connect)(Code) | | Appends the geometry of the specified
PathIterator object
to the path, possibly connecting the new geometry to the existing
path segments with a line segment.
If the
connect parameter is
true and the
path is not empty then any initial
moveTo in the
geometry of the appended
Shape is turned into a
lineTo segment.
If the destination coordinates of such a connecting
lineTo segment match the ending coordinates of a currently open
subpath then the segment is omitted as superfluous.
The winding rule of the specified
Shape is ignored
and the appended geometry is governed by the winding
rule specified for this path.
Parameters: pi - the PathIterator whose geometry is appended to this path Parameters: connect - a boolean to control whether or not to turn an initial moveTo segment into a lineTo segmentto connect the new geometry to the existing path since: 1.6 |
closePath | final public synchronized void closePath()(Code) | | Closes the current subpath by drawing a straight line back to
the coordinates of the last
moveTo . If the path is already
closed then this method has no effect.
since: 1.6 |
contains | public static boolean contains(PathIterator pi, double x, double y)(Code) | | Tests if the specified coordinates are inside the closed
boundary of the specified
PathIterator .
This method provides a basic facility for implementors of
the
Shape interface to implement support for the
Shape.contains(doubledouble) method.
Parameters: pi - the specified PathIterator Parameters: x - the specified X coordinate Parameters: y - the specified Y coordinate true if the specified coordinates are inside thespecified PathIterator ; false otherwise since: 1.6 |
contains | public static boolean contains(PathIterator pi, Point2D p)(Code) | | Tests if the specified
Point2D is inside the closed
boundary of the specified
PathIterator .
This method provides a basic facility for implementors of
the
Shape interface to implement support for the
Shape.contains(Point2D) method.
Parameters: pi - the specified PathIterator Parameters: p - the specified Point2D true if the specified coordinates are inside thespecified PathIterator ; false otherwise since: 1.6 |
contains | final public boolean contains(double x, double y)(Code) | | since: 1.6 |
contains | public static boolean contains(PathIterator pi, double x, double y, double w, double h)(Code) | | Tests if the specified rectangular area is entirely inside the
closed boundary of the specified
PathIterator .
This method provides a basic facility for implementors of
the
Shape interface to implement support for the
Shape.contains(doubledoubledoubledouble) method.
This method object may conservatively return false in
cases where the specified rectangular area intersects a
segment of the path, but that segment does not represent a
boundary between the interior and exterior of the path.
Such segments could lie entirely within the interior of the
path if they are part of a path with a
Path2D.WIND_NON_ZERO winding rule or if the segments are retraced in the reverse
direction such that the two sets of segments cancel each
other out without any exterior area falling between them.
To determine whether segments represent true boundaries of
the interior of the path would require extensive calculations
involving all of the segments of the path and the winding
rule and are thus beyond the scope of this implementation.
Parameters: pi - the specified PathIterator Parameters: x - the specified X coordinate Parameters: y - the specified Y coordinate Parameters: w - the width of the specified rectangular area Parameters: h - the height of the specified rectangular area true if the specified PathIterator containsthe specified rectangluar area; false otherwise. since: 1.6 |
contains | public static boolean contains(PathIterator pi, Rectangle2D r)(Code) | | Tests if the specified
Rectangle2D is entirely inside the
closed boundary of the specified
PathIterator .
This method provides a basic facility for implementors of
the
Shape interface to implement support for the
Shape.contains(Rectangle2D) method.
This method object may conservatively return false in
cases where the specified rectangular area intersects a
segment of the path, but that segment does not represent a
boundary between the interior and exterior of the path.
Such segments could lie entirely within the interior of the
path if they are part of a path with a
Path2D.WIND_NON_ZERO winding rule or if the segments are retraced in the reverse
direction such that the two sets of segments cancel each
other out without any exterior area falling between them.
To determine whether segments represent true boundaries of
the interior of the path would require extensive calculations
involving all of the segments of the path and the winding
rule and are thus beyond the scope of this implementation.
Parameters: pi - the specified PathIterator Parameters: r - a specified Rectangle2D true if the specified PathIterator containsthe specified Rectangle2D ; false otherwise. since: 1.6 |
contains | final public boolean contains(double x, double y, double w, double h)(Code) | |
This method object may conservatively return false in
cases where the specified rectangular area intersects a
segment of the path, but that segment does not represent a
boundary between the interior and exterior of the path.
Such segments could lie entirely within the interior of the
path if they are part of a path with a
Path2D.WIND_NON_ZERO winding rule or if the segments are retraced in the reverse
direction such that the two sets of segments cancel each
other out without any exterior area falling between them.
To determine whether segments represent true boundaries of
the interior of the path would require extensive calculations
involving all of the segments of the path and the winding
rule and are thus beyond the scope of this implementation.
since: 1.6 |
contains | final public boolean contains(Rectangle2D r)(Code) | |
This method object may conservatively return false in
cases where the specified rectangular area intersects a
segment of the path, but that segment does not represent a
boundary between the interior and exterior of the path.
Such segments could lie entirely within the interior of the
path if they are part of a path with a
Path2D.WIND_NON_ZERO winding rule or if the segments are retraced in the reverse
direction such that the two sets of segments cancel each
other out without any exterior area falling between them.
To determine whether segments represent true boundaries of
the interior of the path would require extensive calculations
involving all of the segments of the path and the winding
rule and are thus beyond the scope of this implementation.
since: 1.6 |
createTransformedShape | final public synchronized Shape createTransformedShape(AffineTransform at)(Code) | | Returns a new
Shape representing a transformed version
of this
Path2D .
Note that the exact type and coordinate precision of the return
value is not specified for this method.
The method will return a Shape that contains no less precision
for the transformed geometry than this
Path2D currently
maintains, but it may contain no more precision either.
If the tradeoff of precision vs. storage size in the result is
important then the convenience constructors in the
Path2D.Float.Float(ShapeAffineTransform) Path2D.Float and
Path2D.Double.Double(ShapeAffineTransform) Path2D.Double subclasses should be used to make the choice explicit.
Parameters: at - the AffineTransform used to transform a new Shape . a new Shape , transformed with the specified AffineTransform . since: 1.6 |
curveTo | abstract public void curveTo(double x1, double y1, double x2, double y2, double x3, double y3)(Code) | | 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: x1 - the X coordinate of the first Bézier control point Parameters: y1 - the Y coordinate of the first Bézier control point Parameters: x2 - the X coordinate of the second Bézier control point Parameters: y2 - the Y coordinate of the second Bézier control point Parameters: x3 - the X coordinate of the final end point Parameters: y3 - the Y coordinate of the final end point since: 1.6 |
getCurrentPoint | final public synchronized Point2D getCurrentPoint()(Code) | | Returns the coordinates most recently added to the end of the path
as a
Point2D object.
a Point2D object containing the ending coordinates ofthe path or null if there are no points in the path. since: 1.6 |
getPathIterator | public PathIterator getPathIterator(AffineTransform at, double flatness)(Code) | |
The iterator for this class is not multi-threaded safe,
which means that this
Path2D class does not
guarantee that modifications to the geometry of this
Path2D object do not affect any iterations of
that geometry that are already in process.
since: 1.6 |
intersects | public static boolean intersects(PathIterator pi, double x, double y, double w, double h)(Code) | | Tests if the interior of the specified
PathIterator intersects the interior of a specified set of rectangular
coordinates.
This method provides a basic facility for implementors of
the
Shape interface to implement support for the
Shape.intersects(doubledoubledoubledouble) method.
This method object may conservatively return true in
cases where the specified rectangular area intersects a
segment of the path, but that segment does not represent a
boundary between the interior and exterior of the path.
Such a case may occur if some set of segments of the
path are retraced in the reverse direction such that the
two sets of segments cancel each other out without any
interior area between them.
To determine whether segments represent true boundaries of
the interior of the path would require extensive calculations
involving all of the segments of the path and the winding
rule and are thus beyond the scope of this implementation.
Parameters: pi - the specified PathIterator Parameters: x - the specified X coordinate Parameters: y - the specified Y coordinate Parameters: w - the width of the specified rectangular coordinates Parameters: h - the height of the specified rectangular coordinates true if the specified PathIterator andthe interior of the specified set of rectangularcoordinates intersect each other; false otherwise. since: 1.6 |
intersects | public static boolean intersects(PathIterator pi, Rectangle2D r)(Code) | | Tests if the interior of the specified
PathIterator intersects the interior of a specified
Rectangle2D .
This method provides a basic facility for implementors of
the
Shape interface to implement support for the
Shape.intersects(Rectangle2D) method.
This method object may conservatively return true in
cases where the specified rectangular area intersects a
segment of the path, but that segment does not represent a
boundary between the interior and exterior of the path.
Such a case may occur if some set of segments of the
path are retraced in the reverse direction such that the
two sets of segments cancel each other out without any
interior area between them.
To determine whether segments represent true boundaries of
the interior of the path would require extensive calculations
involving all of the segments of the path and the winding
rule and are thus beyond the scope of this implementation.
Parameters: pi - the specified PathIterator Parameters: r - the specified Rectangle2D true if the specified PathIterator andthe interior of the specified Rectangle2D intersect each other; false otherwise. since: 1.6 |
intersects | final public boolean intersects(double x, double y, double w, double h)(Code) | |
This method object may conservatively return true in
cases where the specified rectangular area intersects a
segment of the path, but that segment does not represent a
boundary between the interior and exterior of the path.
Such a case may occur if some set of segments of the
path are retraced in the reverse direction such that the
two sets of segments cancel each other out without any
interior area between them.
To determine whether segments represent true boundaries of
the interior of the path would require extensive calculations
involving all of the segments of the path and the winding
rule and are thus beyond the scope of this implementation.
since: 1.6 |
intersects | final public boolean intersects(Rectangle2D r)(Code) | |
This method object may conservatively return true in
cases where the specified rectangular area intersects a
segment of the path, but that segment does not represent a
boundary between the interior and exterior of the path.
Such a case may occur if some set of segments of the
path are retraced in the reverse direction such that the
two sets of segments cancel each other out without any
interior area between them.
To determine whether segments represent true boundaries of
the interior of the path would require extensive calculations
involving all of the segments of the path and the winding
rule and are thus beyond the scope of this implementation.
since: 1.6 |
lineTo | abstract public void lineTo(double x, double y)(Code) | | 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: x - the specified X coordinate Parameters: y - the specified Y coordinate since: 1.6 |
moveTo | abstract public void moveTo(double x, double y)(Code) | | Adds a point to the path by moving to the specified
coordinates specified in double precision.
Parameters: x - the specified X coordinate Parameters: y - the specified Y coordinate since: 1.6 |
needRoom | abstract void needRoom(boolean needMove, int newCoords)(Code) | | |
pointCrossings | abstract int pointCrossings(double px, double py)(Code) | | |
quadTo | abstract public void quadTo(double x1, double y1, double x2, double y2)(Code) | | 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: x1 - the X coordinate of the quadratic control point Parameters: y1 - the Y coordinate of the quadratic control point Parameters: x2 - the X coordinate of the final end point Parameters: y2 - the Y coordinate of the final end point since: 1.6 |
rectCrossings | abstract int rectCrossings(double rxmin, double rymin, double rxmax, double rymax)(Code) | | |
reset | final public synchronized void reset()(Code) | | Resets the path to empty. The append position is set back to the
beginning of the path and all coordinates and point types are
forgotten.
since: 1.6 |
transform | abstract public void transform(AffineTransform at)(Code) | | Transforms the geometry of this path using the specified
AffineTransform .
The geometry is transformed in place, which permanently changes the
boundary defined by this object.
Parameters: at - the AffineTransform used to transform the area since: 1.6 |
|
|
|