- java.lang.Object
-
- java.awt.geom.Path2D
-
- java.awt.geom.Path2D.Float
-
- All Implemented Interfaces:
- Shape, Serializable, Cloneable
- Direct Known Subclasses:
- GeneralPath
- Enclosing class:
- Path2D
public static class Path2D.Float extends Path2D implements Serializable
TheFloat
class defines a geometric path with coordinates stored in single precision floating point.- Since:
- 1.6
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.awt.geom.Path2D
Path2D.Double, Path2D.Float
-
-
Field Summary
-
Fields inherited from class java.awt.geom.Path2D
WIND_EVEN_ODD, WIND_NON_ZERO
-
-
Constructor Summary
Constructors Constructor and Description Path2D.Float()
Constructs a new empty single precisionPath2D
object with a default winding rule ofPath2D.WIND_NON_ZERO
.Path2D.Float(int rule)
Constructs a new empty single precisionPath2D
object with the specified winding rule to control operations that require the interior of the path to be defined.Path2D.Float(int rule, int initialCapacity)
Constructs a new empty single precisionPath2D
object with the specified winding rule and the specified initial capacity to store path segments.Path2D.Float(Shape s)
Constructs a new single precisionPath2D
object from an arbitraryShape
object.Path2D.Float(Shape s, AffineTransform at)
Constructs a new single precisionPath2D
object from an arbitraryShape
object, transformed by anAffineTransform
object.
-
Method Summary
Methods Modifier and Type Method and 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.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.Rectangle2D
getBounds2D()
Returns a high precision and more accurate bounding box of theShape
than thegetBounds
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
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.void
moveTo(double x, double y)
Adds a point to the path by moving to the specified coordinates specified in double precision.void
moveTo(float x, float y)
Adds a point to the path by moving to the specified coordinates specified in float 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
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.void
transform(AffineTransform at)
Transforms the geometry of this path using the specifiedAffineTransform
.-
Methods inherited from class java.awt.geom.Path2D
append, closePath, contains, contains, contains, contains, contains, contains, contains, contains, createTransformedShape, getBounds, getCurrentPoint, getPathIterator, getWindingRule, intersects, intersects, intersects, intersects, reset, setWindingRule
-
-
-
-
Constructor Detail
-
Path2D.Float
public Path2D.Float()
Constructs a new empty single precisionPath2D
object with a default winding rule ofPath2D.WIND_NON_ZERO
.- Since:
- 1.6
-
Path2D.Float
public Path2D.Float(int rule)
Constructs a new empty single precisionPath2D
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
,Path2D.WIND_NON_ZERO
-
Path2D.Float
public Path2D.Float(int rule, int initialCapacity)
Constructs a new empty single precisionPath2D
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 ruleinitialCapacity
- the estimate for the number of path segments in the path- Since:
- 1.6
- See Also:
Path2D.WIND_EVEN_ODD
,Path2D.WIND_NON_ZERO
-
Path2D.Float
public Path2D.Float(Shape s)
Constructs a new single precisionPath2D
object from an arbitraryShape
object. All of the initial geometry and the winding rule for this path are taken from the specifiedShape
object.- Parameters:
s
- the specifiedShape
object- Since:
- 1.6
-
Path2D.Float
public Path2D.Float(Shape s, AffineTransform at)
Constructs a new single precisionPath2D
object from an arbitraryShape
object, transformed by anAffineTransform
object. All of the initial geometry and the winding rule for this path are taken from the specifiedShape
object and transformed by the specifiedAffineTransform
object.- Parameters:
s
- the specifiedShape
objectat
- the specifiedAffineTransform
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.
-
moveTo
public 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 basePath2D
class.- Parameters:
x
- the specified X coordinatey
- the specified Y coordinate- Since:
- 1.6
- See Also:
Path2D.moveTo(double, double)
-
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.
-
lineTo
public 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 basePath2D
class.- Parameters:
x
- the specified X coordinatey
- the specified Y coordinate- Since:
- 1.6
- See Also:
Path2D.lineTo(double, double)
-
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.
-
quadTo
public 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 basePath2D
class.- Parameters:
x1
- the X coordinate of the quadratic control pointy1
- the Y coordinate of the quadratic control pointx2
- the X coordinate of the final end pointy2
- the Y coordinate of the final end point- Since:
- 1.6
- See Also:
Path2D.quadTo(double, double, double, double)
-
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
in classPath2D
- Parameters:
x1
- the X coordinate of the first Bézier control pointy1
- the Y coordinate of the first Bézier control pointx2
- the X coordinate of the second Bézier control pointy2
- the Y coordinate of the second Bézier control pointx3
- the X coordinate of the final end pointy3
- 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)
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 basePath2D
class.- Parameters:
x1
- the X coordinate of the first Bézier control pointy1
- the Y coordinate of the first Bézier control pointx2
- the X coordinate of the second Bézier control pointy2
- the Y coordinate of the second Bézier control pointx3
- the X coordinate of the final end pointy3
- the Y coordinate of the final end point- Since:
- 1.6
- See Also:
Path2D.curveTo(double, double, double, double, double, double)
-
append
public final 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. If theconnect
parameter istrue
and the path is not empty then any initialmoveTo
in the geometry of the appendedShape
is turned into alineTo
segment. If the destination coordinates of such a connectinglineTo
segment match the ending coordinates of a currently open subpath then the segment is omitted as superfluous. The winding rule of the specifiedShape
is ignored and the appended geometry is governed by the winding rule specified for this path.
-
transform
public final void transform(AffineTransform at)
Transforms the geometry of this path using the specifiedAffineTransform
. The geometry is transformed in place, which permanently changes the boundary defined by this object.
-
getBounds2D
public final Rectangle2D getBounds2D()
Returns a high precision and more accurate bounding box of theShape
than thegetBounds
method. Note that there is no guarantee that the returnedRectangle2D
is the smallest bounding box that encloses theShape
, only that theShape
lies entirely within the indicatedRectangle2D
. The bounding box returned by this method is usually tighter than that returned by thegetBounds
method and never fails due to overflow problems since the return value can be an instance of theRectangle2D
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 returnedbounds
object, but only in cases where those points are also not considered contained in the originalshape
.If a
point
is inside theshape
according to thecontains(point)
method, then it must be inside the returnedRectangle2D
bounds object according to thecontains(point)
method of thebounds
. Specifically:shape.contains(p)
requiresbounds.contains(p)
If a
point
is not inside theshape
, then it might still be contained in thebounds
object:bounds.contains(p)
does not implyshape.contains(p)
- Specified by:
getBounds2D
in interfaceShape
- Returns:
- an instance of
Rectangle2D
that is a high-precision bounding box of theShape
. - Since:
- 1.6
- See Also:
Shape.getBounds()
-
getPathIterator
public final PathIterator getPathIterator(AffineTransform at)
Returns an iterator object that iterates along theShape
boundary and provides access to the geometry of theShape
outline. If an optionalAffineTransform
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 theShape
object independently from any otherPathIterator
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 thisPath2D
object do not affect any iterations of that geometry that are already in process.- Specified by:
getPathIterator
in interfaceShape
- Parameters:
at
- an optionalAffineTransform
to be applied to the coordinates as they are returned in the iteration, ornull
if untransformed coordinates are desired- Returns:
- a new
PathIterator
object, which independently traverses the geometry of theShape
. - Since:
- 1.6
-
clone
public final Object clone()
Creates a new object of the same class as this object.- Specified by:
clone
in classPath2D
- Returns:
- a clone of this instance.
- Throws:
OutOfMemoryError
- if there is not enough memory.- Since:
- 1.6
- See Also:
Cloneable
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-java/awt/geom/path2d.float.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.