Class Path2D.Float
- All Implemented Interfaces:
Shape, Serializable, Cloneable
- Direct Known Subclasses:
GeneralPath
- Enclosing class:
Path2D
public static non-sealed class Path2D.Float extends Path2D implements Serializable
Float class defines a geometric path with coordinates stored in single precision floating point.- Since:
- 1.6
- See Also:
Nested Class Summary
Nested classes/interfaces declared in class Path2D
Path2D.Double, Path2D.Float | Modifier and Type | Class | Description |
|---|---|---|
static class |
Path2D.Double |
The Double class defines a geometric path with coordinates stored in double precision floating point. |
static class |
Path2D.Float |
The Float class defines a geometric path with coordinates stored in single precision floating point. |
Field Summary
Fields declared in class Path2D
WIND_EVEN_ODD, WIND_NON_ZERO | Modifier and Type | Field | Description |
|---|---|---|
static final int |
WIND_EVEN_ODD |
An even-odd winding rule for determining the interior of a path. |
static final int |
WIND_NON_ZERO |
A non-zero winding rule for determining the interior of a path. |
Constructor Summary
| Constructor | Description |
|---|---|
Float() |
Constructs a new empty single precision Path2D object with a default winding rule of Path2D.WIND_NON_ZERO. |
Float |
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. |
Float |
Constructs a new empty single precision Path2D object with the specified winding rule and the specified initial capacity to store path segments. |
Float |
Constructs a new single precision Path2D object from an arbitrary Shape object. |
Float |
Constructs a new single precision Path2D object from an arbitrary Shape object, transformed by an AffineTransform object. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
final void |
append |
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. |
final Object |
clone() |
Creates a new object of the same class as this object. |
final void |
curveTo |
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 void |
curveTo |
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 Rectangle2D |
getBounds2D() |
Returns a high precision and more accurate bounding box of the Shape than the getBounds method. |
final PathIterator |
getPathIterator |
Returns an iterator object that iterates along the Shape boundary and provides access to the geometry of the Shape outline. |
final void |
lineTo |
Adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates specified in double precision. |
final void |
lineTo |
Adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates specified in float precision. |
final void |
moveTo |
Adds a point to the path by moving to the specified coordinates specified in double precision. |
final void |
moveTo |
Adds a point to the path by moving to the specified coordinates specified in float precision. |
final void |
quadTo |
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 |
quadTo |
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 |
transform |
Transforms the geometry of this path using the specified AffineTransform. |
final void |
trimToSize() |
Trims the capacity of this Path2D instance to its current size. |
Methods declared in class Path2D
append, closePath, contains, contains, contains, contains, contains, contains, contains, contains, createTransformedShape, getBounds, getCurrentPoint, getPathIterator, getWindingRule, intersects, intersects, intersects, intersects, reset, setWindingRule | Modifier and Type | Method | Description |
|---|---|---|
final void |
append |
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. |
final void |
closePath() |
Closes the current subpath by drawing a straight line back to the coordinates of the last moveTo. |
final boolean |
contains |
Tests if the specified coordinates are inside the boundary of the Shape, as described by the definition of insideness. |
final boolean |
contains |
Tests if the interior of the Shape entirely contains the specified rectangular area. |
static boolean |
contains |
Tests if the specified coordinates are inside the closed boundary of the specified PathIterator. |
static boolean |
contains |
Tests if the specified rectangular area is entirely inside the closed boundary of the specified PathIterator. |
static boolean |
contains |
Tests if the specified Point2D is inside the closed boundary of the specified PathIterator. |
static boolean |
contains |
Tests if the specified Rectangle2D is entirely inside the closed boundary of the specified PathIterator. |
final boolean |
contains |
Tests if a specified Point2D is inside the boundary of the Shape, as described by the definition of insideness. |
final boolean |
contains |
Tests if the interior of the Shape entirely contains the specified Rectangle2D. |
final Shape |
createTransformedShape |
Returns a new Shape representing a transformed version of this Path2D. |
final Rectangle |
getBounds() |
Returns an integer Rectangle that completely encloses the Shape. |
final Point2D |
getCurrentPoint() |
Returns the coordinates most recently added to the end of the path as a Point2D object. |
final PathIterator |
getPathIterator |
Returns an iterator object that iterates along the Shape boundary and provides access to a flattened view of the Shape outline geometry. |
final int |
getWindingRule() |
Returns the fill style winding rule. |
final boolean |
intersects |
Tests if the interior of the Shape intersects the interior of a specified rectangular area. |
static boolean |
intersects |
Tests if the interior of the specified PathIterator intersects the interior of a specified set of rectangular coordinates. |
static boolean |
intersects |
Tests if the interior of the specified PathIterator intersects the interior of a specified Rectangle2D. |
final boolean |
intersects |
Tests if the interior of the Shape intersects the interior of a specified Rectangle2D. |
final void |
reset() |
Resets the path to empty. |
final void |
setWindingRule |
Sets the winding rule for this path to the specified value. |
Methods declared in class Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | Modifier and Type | Method | Description |
|---|---|---|
boolean |
equals |
Indicates whether some other object is "equal to" this one. |
protected void |
finalize() |
Deprecated, for removal: This API element is subject to removal in a future version. Finalization is deprecated and subject to removal in a future release. |
final Class |
getClass() |
Returns the runtime class of this Object. |
int |
hashCode() |
Returns a hash code value for this object. |
final void |
notify() |
Wakes up a single thread that is waiting on this object's monitor. |
final void |
notifyAll() |
Wakes up all threads that are waiting on this object's monitor. |
String |
toString() |
Returns a string representation of the object. |
final void |
wait() |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
Constructor Details
Float
public Float()
Path2D object with a default winding rule of Path2D.WIND_NON_ZERO.- Since:
- 1.6
Float
public Float(int rule)
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 - Throws:
-
IllegalArgumentException- ifruleis not eitherPath2D.WIND_EVEN_ODDorPath2D.WIND_NON_ZERO - Since:
- 1.6
- See Also:
Float
public Float(int rule, int initialCapacity)
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 will be added to the path, but the storage is expanded as needed to store whatever path segments are added.- Parameters:
-
rule- the winding rule -
initialCapacity- the estimate for the number of path segments in the path - Throws:
-
IllegalArgumentException- ifruleis not eitherPath2D.WIND_EVEN_ODDorPath2D.WIND_NON_ZERO -
NegativeArraySizeException- ifinitialCapacityis negative - Since:
- 1.6
- See Also:
Float
public Float(Shape s)
Path2D object from an arbitrary Shape object. All of the initial geometry and the winding rule for this path are taken from the specified Shape object.- Parameters:
-
s- the specifiedShapeobject - Throws:
-
NullPointerException- ifsisnull - Since:
- 1.6
Float
public Float(Shape s, AffineTransform at)
Path2D object from an arbitrary Shape object, transformed by an AffineTransform 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 specifiedShapeobject -
at- the specifiedAffineTransformobject - Throws:
-
NullPointerException- ifsisnull - Since:
- 1.6
Method Details
trimToSize
public final void trimToSize()
Path2D- Specified by:
-
trimToSizein classPath2D - Since:
- 10
moveTo
moveTo
public final void moveTo(float x, float y)
This method provides a single precision variant of the double precision moveTo() method on the base Path2D class.
- Parameters:
-
x- the specified X coordinate -
y- the specified Y coordinate - Since:
- 1.6
- See Also:
lineTo
public final void lineTo(double x, double y)
lineTo
public final void lineTo(float x, float y)
This method provides a single precision variant of the double precision lineTo() method on the base Path2D class.
- Parameters:
-
x- the specified X coordinate -
y- the specified Y coordinate - Since:
- 1.6
- See Also:
quadTo
public final void quadTo(double x1, double y1, double x2, double y2)
(x2,y2), using the specified point (x1,y1) as a quadratic parametric control point. All coordinates are specified in double precision.quadTo
public final void quadTo(float x1, float y1, float x2, float y2)
(x2,y2), using the specified point (x1,y1) as a quadratic parametric control point. All coordinates are specified in float precision. This method provides a single precision variant of the double precision quadTo() method on the base Path2D class.
- 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
- See Also:
curveTo
public final void curveTo(double x1, double y1, double x2, double y2, double x3, double y3)
(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:
-
curveToin classPath2D - 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
curveTo
public final void curveTo(float x1, float y1, float x2, float y2, float x3, float y3)
(x3,y3), using the specified points (x1,y1) and (x2,y2) as Bézier control points. All coordinates are specified in float precision. This method provides a single precision variant of the double precision curveTo() method on the base Path2D class.
- 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
- See Also:
append
public final void append(PathIterator pi, boolean connect)
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.transform
public final void transform(AffineTransform at)
AffineTransform. The geometry is transformed in place, which permanently changes the boundary defined by this object.getBounds2D
public final Rectangle2D getBounds2D()
Shape than the getBounds method. Note that there is no guarantee that the returned Rectangle2D 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 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) method, then it must be inside the returned Rectangle2D bounds object according to the contains(point) 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:
-
getBounds2Din interfaceShape - Returns:
- an instance of
Rectangle2Dthat is a high-precision bounding box of theShape. - Since:
- 1.6
- See Also:
getPathIterator
public final PathIterator getPathIterator(AffineTransform at)
Shape boundary and provides access to the geometry of the Shape outline. If an optional AffineTransform 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:
-
getPathIteratorin interfaceShape - Parameters:
-
at- an optionalAffineTransformto be applied to the coordinates as they are returned in the iteration, ornullif untransformed coordinates are desired - Returns:
- a new
PathIteratorobject, which independently traverses the geometry of theShape. - Since:
- 1.6
clone
public final Object clone()
- Specified by:
-
clonein classPath2D - Returns:
- a clone of this instance.
- Throws:
-
OutOfMemoryError- if there is not enough memory. - Since:
- 1.6
- See Also:
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.