Class GeneralPath
java.lang.Object
java.awt.geom.Path2D
java.awt.geom.Path2D.Float
java.awt.geom.GeneralPath
- All Implemented Interfaces:
Shape, Serializable, Cloneable
The
GeneralPath class represents a geometric path
constructed from straight lines, and quadratic and cubic
(Bézier) curves. It can contain multiple subpaths.
GeneralPath is a legacy final class which exactly
implements the behavior of its superclass Path2D.Float.
Together with Path2D.Double, the Path2D classes
provide full implementations of a general geometric path that
support all of the functionality of the Shape and
PathIterator interfaces with the ability to explicitly
select different levels of internal coordinate precision.
Use Path2D.Float (or this legacy GeneralPath
subclass) 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.
- Since:
- 1.2
- See Also:
-
Nested Class Summary
Nested classes/interfaces declared in class Path2D
Path2D.Double, Path2D.FloatModifier and TypeClassDescriptionstatic classTheDoubleclass defines a geometric path with coordinates stored in double precision floating point.static classTheFloatclass defines a geometric path with coordinates stored in single precision floating point. -
Field Summary
Fields declared in class Path2D
WIND_EVEN_ODD, WIND_NON_ZEROModifier and TypeFieldDescriptionstatic final intAn even-odd winding rule for determining the interior of a path.static final intA non-zero winding rule for determining the interior of a path. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new empty single precisionGeneralPathobject with a default winding rule ofPath2D.WIND_NON_ZERO.GeneralPath(int rule) Constructs a newGeneralPathobject with the specified winding rule to control operations that require the interior of the path to be defined.GeneralPath(int rule, int initialCapacity) Constructs a newGeneralPathobject with the specified winding rule and the specified initial capacity to store path coordinates.GeneralPath(Shape s) Constructs a newGeneralPathobject from an arbitraryShapeobject. -
Method Summary
Methods declared in class Path2D.Float
append, clone, curveTo, curveTo, getBounds2D, getPathIterator, lineTo, lineTo, moveTo, moveTo, quadTo, quadTo, transform, trimToSizeModifier and TypeMethodDescriptionfinal 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.final Objectclone()Creates a new object of the same class as this object.final 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.final 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.final Rectangle2DReturns a high precision and more accurate bounding box of theShapethan thegetBoundsmethod.final PathIteratorReturns an iterator object that iterates along theShapeboundary and provides access to the geometry of theShapeoutline.final 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.final 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.final voidmoveTo(double x, double y) Adds a point to the path by moving to the specified coordinates specified in double precision.final voidmoveTo(float x, float y) Adds a point to the path by moving to the specified coordinates specified in float precision.final 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.final 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.final voidTransforms the geometry of this path using the specifiedAffineTransform.final voidTrims 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, setWindingRuleModifier and TypeMethodDescriptionfinal voidAppends the geometry of the specifiedShapeobject to the path, possibly connecting the new geometry to the existing path segments with a line segment.final voidCloses the current subpath by drawing a straight line back to the coordinates of the lastmoveTo.final booleancontains(double x, double y) Tests if the specified coordinates are inside the boundary of theShape, as described by the definition of insideness.final booleancontains(double x, double y, double w, double h) Tests if the interior of theShapeentirely contains the specified rectangular area.static booleancontains(PathIterator pi, double x, double y) Tests if the specified coordinates are inside the closed boundary of the specifiedPathIterator.static booleancontains(PathIterator pi, double x, double y, double w, double h) Tests if the specified rectangular area is entirely inside the closed boundary of the specifiedPathIterator.static booleancontains(PathIterator pi, Point2D p) Tests if the specifiedPoint2Dis inside the closed boundary of the specifiedPathIterator.static booleancontains(PathIterator pi, Rectangle2D r) Tests if the specifiedRectangle2Dis entirely inside the closed boundary of the specifiedPathIterator.final booleanTests if a specifiedPoint2Dis inside the boundary of theShape, as described by the definition of insideness.final booleanTests if the interior of theShapeentirely contains the specifiedRectangle2D.final ShapeReturns a newShaperepresenting a transformed version of thisPath2D.final RectangleReturns an integerRectanglethat completely encloses theShape.final Point2DReturns the coordinates most recently added to the end of the path as aPoint2Dobject.final PathIteratorgetPathIterator(AffineTransform at, double flatness) Returns an iterator object that iterates along theShapeboundary and provides access to a flattened view of theShapeoutline geometry.final intReturns the fill style winding rule.final booleanintersects(double x, double y, double w, double h) Tests if the interior of theShapeintersects the interior of a specified rectangular area.static booleanintersects(PathIterator pi, double x, double y, double w, double h) Tests if the interior of the specifiedPathIteratorintersects the interior of a specified set of rectangular coordinates.static booleanintersects(PathIterator pi, Rectangle2D r) Tests if the interior of the specifiedPathIteratorintersects the interior of a specifiedRectangle2D.final booleanTests if the interior of theShapeintersects the interior of a specifiedRectangle2D.final voidreset()Resets the path to empty.final voidsetWindingRule(int rule) 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, waitModifier and TypeMethodDescriptionbooleanIndicates whether some other object is "equal to" this one.protected voidfinalize()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 thisObject.inthashCode()Returns a hash code value for this object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final voidwait(long timeoutMillis) 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 voidwait(long timeoutMillis, int nanos) 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
-
GeneralPath
public GeneralPath()Constructs a new empty single precisionGeneralPathobject with a default winding rule ofPath2D.WIND_NON_ZERO.- Since:
- 1.2
-
GeneralPath
public GeneralPath(int rule) Constructs a newGeneralPathobject 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.2
- See Also:
-
GeneralPath
public GeneralPath(int rule, int initialCapacity) Constructs a newGeneralPathobject with the specified winding rule and the specified initial capacity to store path coordinates. 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- Throws:
IllegalArgumentException- ifruleis not eitherPath2D.WIND_EVEN_ODDorPath2D.WIND_NON_ZERONegativeArraySizeException- ifinitialCapacityis negative- Since:
- 1.2
- See Also:
-
GeneralPath
Constructs a newGeneralPathobject from an arbitraryShapeobject. All of the initial geometry and the winding rule for this path are taken from the specifiedShapeobject.- Parameters:
s- the specifiedShapeobject- Throws:
NullPointerException- ifsisnull- Since:
- 1.2
-