Path2D.Double (Java Platform SE 8 ) (original) (raw)
- java.awt.geom.Path2D
- java.awt.geom.Path2D.Double
All Implemented Interfaces:
Shape, Serializable, Cloneable
Enclosing class:
Path2D
public static class Path2D.Double
extends Path2D
implements Serializable
The Double
class defines a geometric path with coordinates stored in double precision floating point.
Since:
1.6
See Also:
Serialized Form
Nested Class Summary
* ### Nested classes/interfaces inherited from class java.awt.geom.[Path2D](../../../java/awt/geom/Path2D.html "class in java.awt.geom") `[Path2D.Double](../../../java/awt/geom/Path2D.Double.html "class in java.awt.geom"), [Path2D.Float](../../../java/awt/geom/Path2D.Float.html "class in java.awt.geom")`
Field Summary
* ### Fields inherited from class java.awt.geom.[Path2D](../../../java/awt/geom/Path2D.html "class in java.awt.geom") `[WIND_EVEN_ODD](../../../java/awt/geom/Path2D.html#WIND%5FEVEN%5FODD), [WIND_NON_ZERO](../../../java/awt/geom/Path2D.html#WIND%5FNON%5FZERO)`
Constructor Summary
Constructors
Constructor Description Double() Constructs a new empty double precision Path2D object with a default winding rule of Path2D.WIND_NON_ZERO. Double(int rule) Constructs a new empty double precision Path2D object with the specified winding rule to control operations that require the interior of the path to be defined. Double(int rule, int initialCapacity) Constructs a new empty double precision Path2D object with the specified winding rule and the specified initial capacity to store path segments. Double(Shape s) Constructs a new double precision Path2D object from an arbitrary Shape object. Double(Shape s,AffineTransform at) Constructs a new double precision Path2D object from an arbitrary Shape object, transformed by anAffineTransform object. Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type Method Description void append(PathIterator pi, boolean connect) Appends the geometry of the specifiedPathIterator object to the path, possibly connecting the new geometry to the existing path segments with a line segment. Object clone() Creates a new object of the same class as this object. 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. Rectangle2D getBounds2D() Returns a high precision and more accurate bounding box of the Shape than the getBounds method. PathIterator getPathIterator(AffineTransform at) Returns an iterator object that iterates along theShape boundary and provides access to the geometry of theShape outline. 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. void moveTo(double x, double y) Adds a point to the path by moving to the specified coordinates specified in double precision. 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. void transform(AffineTransform at) Transforms the geometry of this path using the specifiedAffineTransform. * ### Methods inherited from class java.awt.geom.[Path2D](../../../java/awt/geom/Path2D.html "class in java.awt.geom") `[append](../../../java/awt/geom/Path2D.html#append-java.awt.Shape-boolean-), [closePath](../../../java/awt/geom/Path2D.html#closePath--), [contains](../../../java/awt/geom/Path2D.html#contains-double-double-), [contains](../../../java/awt/geom/Path2D.html#contains-double-double-double-double-), [contains](../../../java/awt/geom/Path2D.html#contains-java.awt.geom.PathIterator-double-double-), [contains](../../../java/awt/geom/Path2D.html#contains-java.awt.geom.PathIterator-double-double-double-double-), [contains](../../../java/awt/geom/Path2D.html#contains-java.awt.geom.PathIterator-java.awt.geom.Point2D-), [contains](../../../java/awt/geom/Path2D.html#contains-java.awt.geom.PathIterator-java.awt.geom.Rectangle2D-), [contains](../../../java/awt/geom/Path2D.html#contains-java.awt.geom.Point2D-), [contains](../../../java/awt/geom/Path2D.html#contains-java.awt.geom.Rectangle2D-), [createTransformedShape](../../../java/awt/geom/Path2D.html#createTransformedShape-java.awt.geom.AffineTransform-), [getBounds](../../../java/awt/geom/Path2D.html#getBounds--), [getCurrentPoint](../../../java/awt/geom/Path2D.html#getCurrentPoint--), [getPathIterator](../../../java/awt/geom/Path2D.html#getPathIterator-java.awt.geom.AffineTransform-double-), [getWindingRule](../../../java/awt/geom/Path2D.html#getWindingRule--), [intersects](../../../java/awt/geom/Path2D.html#intersects-double-double-double-double-), [intersects](../../../java/awt/geom/Path2D.html#intersects-java.awt.geom.PathIterator-double-double-double-double-), [intersects](../../../java/awt/geom/Path2D.html#intersects-java.awt.geom.PathIterator-java.awt.geom.Rectangle2D-), [intersects](../../../java/awt/geom/Path2D.html#intersects-java.awt.geom.Rectangle2D-), [reset](../../../java/awt/geom/Path2D.html#reset--), [setWindingRule](../../../java/awt/geom/Path2D.html#setWindingRule-int-)` * ### Methods inherited from class java.lang.[Object](../../../java/lang/Object.html "class in java.lang") `[equals](../../../java/lang/Object.html#equals-java.lang.Object-), [finalize](../../../java/lang/Object.html#finalize--), [getClass](../../../java/lang/Object.html#getClass--), [hashCode](../../../java/lang/Object.html#hashCode--), [notify](../../../java/lang/Object.html#notify--), [notifyAll](../../../java/lang/Object.html#notifyAll--), [toString](../../../java/lang/Object.html#toString--), [wait](../../../java/lang/Object.html#wait--), [wait](../../../java/lang/Object.html#wait-long-), [wait](../../../java/lang/Object.html#wait-long-int-)`
Constructor Detail
* #### Double public Double() Constructs a new empty double precision `Path2D` object with a default winding rule of [Path2D.WIND\_NON\_ZERO](../../../java/awt/geom/Path2D.html#WIND%5FNON%5FZERO). Since: 1.6 * #### Double public Double(int rule) Constructs a new empty double precision `Path2D` object with the specified winding rule to control operations that require the interior of the path to be defined. Parameters: `rule` \- the winding rule Since: 1.6 See Also: [Path2D.WIND\_EVEN\_ODD](../../../java/awt/geom/Path2D.html#WIND%5FEVEN%5FODD), [Path2D.WIND\_NON\_ZERO](../../../java/awt/geom/Path2D.html#WIND%5FNON%5FZERO) * #### Double public Double(int rule, int initialCapacity) Constructs a new empty double precision `Path2D` object with the specified winding rule and the specified initial capacity to store path segments. This number is an initial guess as to how many path segments are in the path, but the storage is expanded as needed to store whatever path segments are added to this path. Parameters: `rule` \- the winding rule `initialCapacity` \- the estimate for the number of path segments in the path Since: 1.6 See Also: [Path2D.WIND\_EVEN\_ODD](../../../java/awt/geom/Path2D.html#WIND%5FEVEN%5FODD), [Path2D.WIND\_NON\_ZERO](../../../java/awt/geom/Path2D.html#WIND%5FNON%5FZERO) * #### Double public Double([Shape](../../../java/awt/Shape.html "interface in java.awt") s) Constructs a new double precision `Path2D` object from an arbitrary [Shape](../../../java/awt/Shape.html "interface in java.awt") object. All of the initial geometry and the winding rule for this path are taken from the specified `Shape` object. Parameters: `s` \- the specified `Shape` object Since: 1.6 * #### Double public Double([Shape](../../../java/awt/Shape.html "interface in java.awt") s, [AffineTransform](../../../java/awt/geom/AffineTransform.html "class in java.awt.geom") at) Constructs a new double precision `Path2D` object from an arbitrary [Shape](../../../java/awt/Shape.html "interface in java.awt") object, transformed by an[AffineTransform](../../../java/awt/geom/AffineTransform.html "class in java.awt.geom") object. All of the initial geometry and the winding rule for this path are taken from the specified `Shape` object and transformed by the specified `AffineTransform` object. Parameters: `s` \- the specified `Shape` object `at` \- the specified `AffineTransform` object Since: 1.6
Method Detail
* #### moveTo public final void moveTo(double x, double y) Adds a point to the path by moving to the specified coordinates specified in double precision. Specified by: `[moveTo](../../../java/awt/geom/Path2D.html#moveTo-double-double-)` in class `[Path2D](../../../java/awt/geom/Path2D.html "class in java.awt.geom")` Parameters: `x` \- the specified X coordinate `y` \- the specified Y coordinate Since: 1.6 * #### lineTo public final 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. Specified by: `[lineTo](../../../java/awt/geom/Path2D.html#lineTo-double-double-)` in class `[Path2D](../../../java/awt/geom/Path2D.html "class in java.awt.geom")` Parameters: `x` \- the specified X coordinate `y` \- the specified Y coordinate Since: 1.6 * #### quadTo public final 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. All coordinates are specified in double precision. Specified by: `[quadTo](../../../java/awt/geom/Path2D.html#quadTo-double-double-double-double-)` in class `[Path2D](../../../java/awt/geom/Path2D.html "class in java.awt.geom")` Parameters: `x1` \- the X coordinate of the quadratic control point `y1` \- the Y coordinate of the quadratic control point `x2` \- the X coordinate of the final end point `y2` \- the Y coordinate of the final end point Since: 1.6 * #### curveTo public final 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. All coordinates are specified in double precision. Specified by: `[curveTo](../../../java/awt/geom/Path2D.html#curveTo-double-double-double-double-double-double-)` in class `[Path2D](../../../java/awt/geom/Path2D.html "class in java.awt.geom")` Parameters: `x1` \- the X coordinate of the first Bézier control point `y1` \- the Y coordinate of the first Bézier control point `x2` \- the X coordinate of the second Bézier control point `y2` \- the Y coordinate of the second Bézier control point `x3` \- the X coordinate of the final end point `y3` \- the Y coordinate of the final end point Since: 1.6 * #### append public final void append([PathIterator](../../../java/awt/geom/PathIterator.html "interface in java.awt.geom") pi, boolean connect) Appends the geometry of the specified[PathIterator](../../../java/awt/geom/PathIterator.html "interface in java.awt.geom") 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. Specified by: `[append](../../../java/awt/geom/Path2D.html#append-java.awt.geom.PathIterator-boolean-)` in class `[Path2D](../../../java/awt/geom/Path2D.html "class in java.awt.geom")` Parameters: `pi` \- the `PathIterator` whose geometry is appended to this path `connect` \- 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 Since: 1.6 * #### transform public final void transform([AffineTransform](../../../java/awt/geom/AffineTransform.html "class in java.awt.geom") at) Transforms the geometry of this path using the specified[AffineTransform](../../../java/awt/geom/AffineTransform.html "class in java.awt.geom"). The geometry is transformed in place, which permanently changes the boundary defined by this object. Specified by: `[transform](../../../java/awt/geom/Path2D.html#transform-java.awt.geom.AffineTransform-)` in class `[Path2D](../../../java/awt/geom/Path2D.html "class in java.awt.geom")` Parameters: `at` \- the `AffineTransform` used to transform the area Since: 1.6 * #### getBounds2D public final [Rectangle2D](../../../java/awt/geom/Rectangle2D.html "class in java.awt.geom") getBounds2D() Returns a high precision and more accurate bounding box of the `Shape` than the `getBounds` method. Note that there is no guarantee that the returned[Rectangle2D](../../../java/awt/geom/Rectangle2D.html "class in java.awt.geom") is the smallest bounding box that encloses the `Shape`, only that the `Shape` lies entirely within the indicated `Rectangle2D`. The bounding box returned by this method is usually tighter than that returned by the `getBounds` method and never fails due to overflow problems since the return value can be an instance of the `Rectangle2D` that uses double precision values to store the dimensions. Note that the [ definition of insideness](../../../java/awt/Shape.html#def%5Finsideness) can lead to situations where points on the defining outline of the `shape` may not be considered contained in the returned `bounds` object, but only in cases where those points are also not considered contained in the original`shape`. If a `point` is inside the `shape` according to the[contains(point)](../../../java/awt/Shape.html#contains-java.awt.geom.Point2D-) method, then it must be inside the returned `Rectangle2D` bounds object according to the [contains(point)](../../../java/awt/Shape.html#contains-java.awt.geom.Point2D-) method of the`bounds`. Specifically: `shape.contains(p)` requires `bounds.contains(p)` If a `point` is not inside the `shape`, then it might still be contained in the `bounds` object: `bounds.contains(p)` does not imply `shape.contains(p)` Specified by: `[getBounds2D](../../../java/awt/Shape.html#getBounds2D--)` in interface `[Shape](../../../java/awt/Shape.html "interface in java.awt")` Returns: an instance of `Rectangle2D` that is a high-precision bounding box of the `Shape`. Since: 1.6 See Also: [Shape.getBounds()](../../../java/awt/Shape.html#getBounds--) * #### getPathIterator public final [PathIterator](../../../java/awt/geom/PathIterator.html "interface in java.awt.geom") getPathIterator([AffineTransform](../../../java/awt/geom/AffineTransform.html "class in java.awt.geom") at) Returns an iterator object that iterates along the`Shape` boundary and provides access to the geometry of the`Shape` outline. If an optional [AffineTransform](../../../java/awt/geom/AffineTransform.html "class in java.awt.geom") is specified, the coordinates returned in the iteration are transformed accordingly. Each call to this method returns a fresh `PathIterator` object that traverses the geometry of the `Shape` object independently from any other `PathIterator` objects in use at the same time. It is recommended, but not guaranteed, that objects implementing the `Shape` interface isolate iterations that are in process from any changes that might occur to the original object's geometry during such iterations. The iterator for this class is not multi-threaded safe, which means that the `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. Specified by: `[getPathIterator](../../../java/awt/Shape.html#getPathIterator-java.awt.geom.AffineTransform-)` in interface `[Shape](../../../java/awt/Shape.html "interface in java.awt")` Parameters: `at` \- an `AffineTransform` Returns: a new `PathIterator` that iterates along the boundary of this `Shape` and provides access to the geometry of this `Shape`'s outline Since: 1.6 * #### clone public final [Object](../../../java/lang/Object.html "class in java.lang") clone() Creates a new object of the same class as this object. Specified by: `[clone](../../../java/awt/geom/Path2D.html#clone--)` in class `[Path2D](../../../java/awt/geom/Path2D.html "class in java.awt.geom")` Returns: a clone of this instance. Throws: `[OutOfMemoryError](../../../java/lang/OutOfMemoryError.html "class in java.lang")` \- if there is not enough memory. Since: 1.6 See Also: [Cloneable](../../../java/lang/Cloneable.html "interface in java.lang")
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.