- All Implemented Interfaces:
- Shape,- Serializable,- Cloneable
- Direct Known Subclasses:
- GeneralPath
- Enclosing class:
- Path2D
public static 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:
- Serialized Form
- 
Nested Class Summary
- 
Field Summary
- 
Constructor SummaryConstructors Constructor Description Float()Constructs a new empty single precisionPath2Dobject with a default winding rule ofPath2D.WIND_NON_ZERO.Float(int rule)Constructs a new empty single precisionPath2Dobject with the specified winding rule to control operations that require the interior of the path to be defined.Float(int rule, int initialCapacity)Constructs a new empty single precisionPath2Dobject with the specified winding rule and the specified initial capacity to store path segments.Float(Shape s)Constructs a new single precisionPath2Dobject from an arbitraryShapeobject.Float(Shape s, AffineTransform at)Constructs a new single precisionPath2Dobject from an arbitraryShapeobject, transformed by anAffineTransformobject.
- 
Method SummaryModifier and Type Method Description voidappend(PathIterator pi, boolean connect)Appends the geometry of the specifiedPathIteratorobject to the path, possibly connecting the new geometry to the existing path segments with a line segment.Objectclone()Creates a new object of the same class as this object.voidcurveTo(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.voidcurveTo(float x1, float y1, float x2, float y2, float x3, float 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.Rectangle2DgetBounds2D()Returns a high precision and more accurate bounding box of theShapethan thegetBoundsmethod.PathIteratorgetPathIterator(AffineTransform at)Returns an iterator object that iterates along theShapeboundary and provides access to the geometry of theShapeoutline.voidlineTo(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.voidlineTo(float x, float y)Adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates specified in float precision.voidmoveTo(double x, double y)Adds a point to the path by moving to the specified coordinates specified in double precision.voidmoveTo(float x, float y)Adds a point to the path by moving to the specified coordinates specified in float precision.voidquadTo(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.voidquadTo(float x1, float y1, float x2, float 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.voidtransform(AffineTransform at)Transforms the geometry of this path using the specifiedAffineTransform.Methods declared in class java.awt.geom.Path2Dappend, closePath, contains, contains, contains, contains, contains, contains, contains, contains, createTransformedShape, getBounds, getCurrentPoint, getPathIterator, getWindingRule, intersects, intersects, intersects, intersects, reset, setWindingRule, trimToSize
- 
Constructor Details- 
Floatpublic Float()Constructs a new empty single precisionPath2Dobject with a default winding rule ofPath2D.WIND_NON_ZERO.- Since:
- 1.6
 
- 
Floatpublic Float(int rule)Constructs a new empty single precisionPath2Dobject 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,- Path2D.WIND_NON_ZERO
 
- 
Floatpublic Float(int rule, int initialCapacity)Constructs a new empty single precisionPath2Dobject 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
- Since:
- 1.6
- See Also:
- Path2D.WIND_EVEN_ODD,- Path2D.WIND_NON_ZERO
 
- 
FloatConstructs a new single precisionPath2Dobject from an arbitraryShapeobject. All of the initial geometry and the winding rule for this path are taken from the specifiedShapeobject.- Parameters:
- s- the specified- Shapeobject
- Since:
- 1.6
 
- 
FloatConstructs a new single precisionPath2Dobject from an arbitraryShapeobject, transformed by anAffineTransformobject. All of the initial geometry and the winding rule for this path are taken from the specifiedShapeobject and transformed by the specifiedAffineTransformobject.- Parameters:
- s- the specified- Shapeobject
- at- the specified- AffineTransformobject
- Since:
- 1.6
 
 
- 
- 
Method Details- 
moveTopublic final void moveTo(double x, double y)Adds a point to the path by moving to the specified coordinates specified in double precision.
- 
moveTopublic final void moveTo(float x, float y)Adds a point to the path by moving to the specified coordinates specified in float precision.This method provides a single precision variant of the double precision moveTo()method on the basePath2Dclass.- Parameters:
- x- the specified X coordinate
- y- the specified Y coordinate
- Since:
- 1.6
- See Also:
- Path2D.moveTo(double, double)
 
- 
lineTopublic 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.
- 
lineTopublic final void lineTo(float x, float y)Adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates specified in float precision.This method provides a single precision variant of the double precision lineTo()method on the basePath2Dclass.- Parameters:
- x- the specified X coordinate
- y- the specified Y coordinate
- Since:
- 1.6
- See Also:
- Path2D.lineTo(double, double)
 
- 
quadTopublic 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.
- 
quadTopublic final void quadTo(float x1, float y1, float x2, float 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 float precision.This method provides a single precision variant of the double precision quadTo()method on the basePath2Dclass.- 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:
- Path2D.quadTo(double, double, double, double)
 
- 
curveTopublic 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:
- curveToin class- Path2D
- 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
 
- 
curveTopublic final void curveTo(float x1, float y1, float x2, float y2, float x3, float 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 float precision.This method provides a single precision variant of the double precision curveTo()method on the basePath2Dclass.- 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:
- Path2D.curveTo(double, double, double, double, double, double)
 
- 
appendAppends the geometry of the specifiedPathIteratorobject to the path, possibly connecting the new geometry to the existing path segments with a line segment. If theconnectparameter istrueand the path is not empty then any initialmoveToin the geometry of the appendedShapeis turned into alineTosegment. If the destination coordinates of such a connectinglineTosegment match the ending coordinates of a currently open subpath then the segment is omitted as superfluous. The winding rule of the specifiedShapeis ignored and the appended geometry is governed by the winding rule specified for this path.
- 
transformTransforms the geometry of this path using the specifiedAffineTransform. The geometry is transformed in place, which permanently changes the boundary defined by this object.
- 
getBounds2DReturns a high precision and more accurate bounding box of theShapethan thegetBoundsmethod. Note that there is no guarantee that the returnedRectangle2Dis the smallest bounding box that encloses theShape, only that theShapelies entirely within the indicatedRectangle2D. The bounding box returned by this method is usually tighter than that returned by thegetBoundsmethod and never fails due to overflow problems since the return value can be an instance of theRectangle2Dthat 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 shapemay not be considered contained in the returnedboundsobject, but only in cases where those points are also not considered contained in the originalshape.If a pointis inside theshapeaccording to thecontains(point)method, then it must be inside the returnedRectangle2Dbounds object according to thecontains(point)method of thebounds. Specifically:shape.contains(p)requiresbounds.contains(p)If a pointis not inside theshape, then it might still be contained in theboundsobject:bounds.contains(p)does not implyshape.contains(p)- Specified by:
- getBounds2Din interface- Shape
- Returns:
- an instance of Rectangle2Dthat is a high-precision bounding box of theShape.
- Since:
- 1.6
- See Also:
- Shape.getBounds()
 
- 
getPathIteratorReturns an iterator object that iterates along theShapeboundary and provides access to the geometry of theShapeoutline. If an optionalAffineTransformis specified, the coordinates returned in the iteration are transformed accordingly.Each call to this method returns a fresh PathIteratorobject that traverses the geometry of theShapeobject independently from any otherPathIteratorobjects in use at the same time.It is recommended, but not guaranteed, that objects implementing the Shapeinterface 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 Path2Dclass does not guarantee that modifications to the geometry of thisPath2Dobject do not affect any iterations of that geometry that are already in process.- Specified by:
- getPathIteratorin interface- Shape
- Parameters:
- at- an optional- AffineTransformto be applied to the coordinates as they are returned in the iteration, or- nullif untransformed coordinates are desired
- Returns:
- a new PathIteratorobject, which independently traverses the geometry of theShape.
- Since:
- 1.6
 
- 
cloneCreates a new object of the same class as this object.- Specified by:
- clonein class- Path2D
- Returns:
- a clone of this instance.
- Throws:
- OutOfMemoryError- if there is not enough memory.
- Since:
- 1.6
- See Also:
- Cloneable
 
 
-