TopBlend:
Here is the
first difference.
There are 68 differences.
is old.
is new.
java.awt.geom
Class GeneralPath
java.lang.Object![extended by](../../../resources/inherit.gif)
java.awt.geom.Path2D![extended by](../../../resources/inherit.gif)
java.awt.geom.Path2D.Float
java.awt.geom.GeneralPath
-
All Implemented Interfaces:
-
Shape
,
Serializable
,
Cloneable
-
public final class GeneralPath
- extends
Path2D.Float![](../../../diffpics/oold.gif)
Object![](../../../diffpics/oold.gif)
implements ![](../../../diffpics/oold.gif)
Shape![](../../../diffpics/oold.gif)
, ![](../../../diffpics/oold.gif)
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.
The winding rule specifies how the interior of a path is determined. There are two types of winding rules: EVEN_ODD and NON_ZERO.
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.
An EVEN_ODD winding rule means that enclosed regions of the path alternate between interior and exterior areas as traversed from the outside of the path towards a point inside the region.
A NON_ZERO winding rule means that if a ray is drawn in any direction from a given point to infinity and the places where the path intersects the ray are examined, the point is inside of the path if and only if the number of times that the path crosses the ray from left to right does not equal the number of times that the path crosses the ray from right to left.
-
Since:
-
1.2
-
See Also:
-
Serialized Form
Nested Class
Field
Summary
|
static int
|
WIND_EVEN_ODD
An even-odd winding rule for determining the interior of a path.
|
static int
|
WIND_NON_ZERO
A non-zero winding rule for determining the interior of a path.
|
Nested classes/interfaces inherited from class java.awt.geom.
Path2D
Constructor Summary
|
Path2D.Double
,
Path2D.Float
|
GeneralPath
()
Constructs a new GeneralPath object.
|
GeneralPath
(int rule)
Constructs a new GeneralPath object 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 new GeneralPath object with the specified winding rule and the specified initial capacity to store path coordinates.
|
GeneralPath
(
Shape
Constructs a new GeneralPath object from an arbitrary
Shape
|
Field
Method
Summary
|
void
|
append
(
PathIterator
Appends the geometry of the specified
PathIterator
|
void
|
append
(
Shape
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.
|
Object
|
clone
()
Creates a new object of the same class as this object.
|
void
|
closePath
()
Closes the current subpath by drawing a straight line back to the coordinates of the last moveTo.
|
boolean
|
contains
(double x, double y)
Tests if the specified coordinates are inside the boundary of this Shape.
|
boolean
|
contains
(double x, double y, double w, double h)
Tests if the specified rectangular area is inside the boundary of this Shape.
|
boolean
|
contains
(
Point2D
Tests if the specified Point2D is inside the boundary of this Shape.
|
boolean
|
contains
(
Rectangle2D
Tests if the specified Rectangle2D is inside the boundary of this Shape.
|
Shape
|
createTransformedShape
(
AffineTransform
Returns a new transformed Shape.
|
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 coordinates (x3, y3), using the specified points (x1, y1) and (x2, y2) as Bézier control points.
|
Rectangle
|
getBounds
()
Return the bounding box of the path.
|
Rectangle2D
|
getBounds2D
()
Returns the bounding box of the path.
|
Point2D
|
getCurrentPoint
()
Returns the coordinates most recently added to the end of the path as a
Point2D
|
PathIterator
|
getPathIterator
(
AffineTransform
Returns a PathIterator object that iterates along the boundary of this Shape and provides access to the geometry of the outline of this Shape.
|
PathIterator
|
getPathIterator
(
AffineTransform
Returns a PathIterator object that iterates along the boundary of the flattened Shape and provides access to the geometry of the outline of the Shape.
|
int
|
getWindingRule
()
Returns the fill style winding rule.
|
boolean
|
intersects
(double x, double y, double w, double h)
Tests if the interior of this Shape intersects the interior of a specified set of rectangular coordinates.
|
boolean
|
intersects
(
Rectangle2D
Tests if the interior of this Shape intersects the interior of a specified Rectangle2D.
|
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.
|
void
|
moveTo
(float x, float y)
Adds a point to the path by moving to the specified coordinates.
|
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 coordinates (x2, y2), using the specified point (x1, y1) as a quadratic parametric control point.
|
void
|
reset
()
Resets the path to empty.
|
void
|
setWindingRule
(int rule)
Sets the winding rule for this path to the specified value.
|
void
|
transform
(
AffineTransform
Transforms the geometry of this path using the specified
AffineTransform
|
Fields
Methods
inherited from class
java.awt.geom.
Path2D
java.lang.
Object
|
WIND_EVEN_ODD
,
WIND_NON_ZERO
|
equals
,
finalize
,
getClass
,
hashCode
,
notify
,
notifyAll
,
toString
,
wait
,
wait
,
wait
|
Constructor Summary
Field Detail
|
GeneralPath
()
Constructs a new empty single precision GeneralPath object with a default winding rule of
Path2D.WIND_NON_ZERO
|
GeneralPath
(int rule)
Constructs a new GeneralPath object 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 new GeneralPath object with the specified winding rule and the specified initial capacity to store path coordinates.
|
GeneralPath
(
Shape
Constructs a new GeneralPath object from an arbitrary
Shape
|
WIND_EVEN_ODD
![](../../../diffpics/oold.gif)
public static final int ![](../../../diffpics/oold.gif)
WIND_EVEN_ODD
-
An even-odd winding rule for determining the interior of a path.
-
See Also:
-
Constant Field Values
WIND_NON_ZERO
![](../../../diffpics/oold.gif)
public static final int ![](../../../diffpics/oold.gif)
WIND_NON_ZERO
-
A non-zero winding rule for determining the interior of a path.
-
See Also:
-
Constant Field Values
Method Summary
Constructor Detail
|
Methods inherited from class java.awt.geom.
Path2D.Float
|
append
,
clone
,
curveTo
,
curveTo
,
getBounds2D
,
getPathIterator
,
lineTo
,
lineTo
,
moveTo
,
moveTo
,
quadTo
,
quadTo
,
transform
|
GeneralPath
![](../../../diffpics/oold.gif)
public ![](../../../diffpics/oold.gif)
GeneralPath ![](../../../diffpics/oold.gif)
()
-
Constructs a new GeneralPath object. If an operation performed on this path requires the interior of the path to be defined then the default NON_ZERO winding rule is used.
-
See Also:
-
WIND_NON_ZERO
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
|
GeneralPath
![](../../../diffpics/oold.gif)
public ![](../../../diffpics/oold.gif)
GeneralPath ![](../../../diffpics/oold.gif)
(int rule)
-
Constructs a new GeneralPath object with the specified winding rule to control operations that require the interior of the path to be defined.
-
Parameters:
-
rule - the winding rule
-
See Also:
-
WIND_EVEN_ODD
,
WIND_NON_ZERO
GeneralPath
![](../../../diffpics/oold.gif)
public ![](../../../diffpics/oold.gif)
GeneralPath ![](../../../diffpics/oold.gif)
(int rule,
int initialCapacity)
-
Constructs a new GeneralPath object 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 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
-
See Also:
-
WIND_EVEN_ODD
,
WIND_NON_ZERO
GeneralPath
![](../../../diffpics/oold.gif)
public ![](../../../diffpics/oold.gif)
GeneralPath ![](../../../diffpics/oold.gif)
( ![](../../../diffpics/oold.gif)
Shape![](../../../diffpics/oold.gif)
s)
-
Constructs a new GeneralPath 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 specified Shape object
Constructor
Method
Detail
|
GeneralPath
moveTo
public ![](../../../diffpics/oold.gif)
void
GeneralPath ![](../../../diffpics/oold.gif)
moveTo
() ![](../../../diffpics/oold.gif)
(float x,
float y)
-
Constructs a new empty single precision GeneralPath object with a default winding rule of
Path2D.WIND_NON_ZERO
.
Adds a point to the path by moving to the specified coordinates.
-
-
-
Since:
Parameters:
-
1.2
x, y - the specified coordinates
GeneralPath
lineTo
public ![](../../../diffpics/oold.gif)
void
GeneralPath ![](../../../diffpics/oold.gif)
lineTo
(int rule) ![](../../../diffpics/oold.gif)
(float x,
float y)
-
Constructs a new GeneralPath object with the specified winding rule to control operations that require the interior of the path to be defined.
Adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates.
-
-
-
Parameters:
-
rule - the winding rule
-
Since:
-
1.2
x, y - the specified coordinates
-
See Also:
-
Path2D.WIND_EVEN_ODD
,
Path2D.WIND_NON_ZERO
GeneralPath
quadTo
public ![](../../../diffpics/oold.gif)
void
GeneralPath ![](../../../diffpics/oold.gif)
quadTo
(int rule,
int initialCapacity) ![](../../../diffpics/oold.gif)
(float x1,
float y1,
float x2,
float y2)
-
Constructs a new GeneralPath object 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.
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 coordinates (x2, y2), using the specified point (x1, y1) as a quadratic parametric control point.
-
-
-
Parameters:
-
rule - the winding rule
x1, y1 - the coordinates of the first quadratic control point
-
initialCapacity - the estimate for the number of path segments in the path
-
Since:
-
1.2
x2, y2 - the coordinates of the final endpoint
-
See Also:
-
Path2D.WIND_EVEN_ODD
,
Path2D.WIND_NON_ZERO
GeneralPath
curveTo
public ![](../../../diffpics/oold.gif)
void
GeneralPath ![](../../../diffpics/oold.gif)
curveTo
(
Shape
s) ![](../../../diffpics/oold.gif)
(float x1,
float y1,
float x2,
float y2,
float x3,
float y3)
-
Constructs a new GeneralPath 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.
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 coordinates (x3, y3), using the specified points (x1, y1) and (x2, y2) as Bézier control points.
-
-
-
Parameters:
-
s - the specified Shape object
-
Since:
x1, y1 - the coordinates of the first Béezier control point
-
1.2
x2, y2 - the coordinates of the second Bézier control point
-
x3, y3 - the coordinates of the final endpoint
closePath
![](../../../diffpics/oold.gif)
public void ![](../../../diffpics/oold.gif)
closePath ![](../../../diffpics/oold.gif)
()
-
Closes the current subpath by drawing a straight line back to the coordinates of the last moveTo. If the path is already closed then this method has no effect.
-
-
append
![](../../../diffpics/oold.gif)
public void ![](../../../diffpics/oold.gif)
append ![](../../../diffpics/oold.gif)
( ![](../../../diffpics/oold.gif)
Shape![](../../../diffpics/oold.gif)
s,
boolean connect)
-
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. 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.
-
-
-
Parameters:
-
s - the Shape 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
append
![](../../../diffpics/oold.gif)
public void ![](../../../diffpics/oold.gif)
append ![](../../../diffpics/oold.gif)
( ![](../../../diffpics/oold.gif)
PathIterator![](../../../diffpics/oold.gif)
pi,
boolean connect)
-
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. 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.
-
-
-
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
getWindingRule
![](../../../diffpics/oold.gif)
public int ![](../../../diffpics/oold.gif)
getWindingRule ![](../../../diffpics/oold.gif)
()
-
Returns the fill style winding rule.
-
-
-
Returns:
-
an integer representing the current winding rule.
-
See Also:
-
WIND_EVEN_ODD
,
WIND_NON_ZERO
,
setWindingRule(int)
setWindingRule
![](../../../diffpics/oold.gif)
public void ![](../../../diffpics/oold.gif)
setWindingRule ![](../../../diffpics/oold.gif)
(int rule)
-
Sets the winding rule for this path to the specified value.
-
-
-
Parameters:
-
rule - an integer representing the specified winding rule
-
Throws:
-
IllegalArgumentException - if rule is not either WIND_EVEN_ODD or WIND_NON_ZERO
-
See Also:
-
WIND_EVEN_ODD
,
WIND_NON_ZERO
,
getWindingRule()
getCurrentPoint
![](../../../diffpics/oold.gif)
public ![](../../../diffpics/oold.gif)
Point2D![](../../../diffpics/oold.gif)
getCurrentPoint ![](../../../diffpics/oold.gif)
()
-
Returns the coordinates most recently added to the end of the path as a
Point2D
object.
-
-
-
Returns:
-
a Point2D object containing the ending coordinates of the path or null if there are no points in the path.
reset
![](../../../diffpics/oold.gif)
public void ![](../../../diffpics/oold.gif)
reset ![](../../../diffpics/oold.gif)
()
-
Resets the path to empty. The append position is set back to the beginning of the path and all coordinates and point types are forgotten.
-
-
transform
![](../../../diffpics/oold.gif)
public void ![](../../../diffpics/oold.gif)
transform ![](../../../diffpics/oold.gif)
( ![](../../../diffpics/oold.gif)
AffineTransform![](../../../diffpics/oold.gif)
at)
-
Transforms the geometry of this path using the specified
AffineTransform
. The geometry is transformed in place, which permanently changes the boundary defined by this object.
-
-
-
Parameters:
-
at - the AffineTransform used to transform the area
createTransformedShape
![](../../../diffpics/oold.gif)
public ![](../../../diffpics/oold.gif)
Shape![](../../../diffpics/oold.gif)
createTransformedShape ![](../../../diffpics/oold.gif)
( ![](../../../diffpics/oold.gif)
AffineTransform![](../../../diffpics/oold.gif)
at)
-
Returns a new transformed Shape.
-
-
-
Parameters:
-
at - the AffineTransform used to transform a new Shape.
-
Returns:
-
a new Shape, transformed with the specified AffineTransform.
getBounds
![](../../../diffpics/oold.gif)
public ![](../../../diffpics/oold.gif)
Rectangle![](../../../diffpics/oold.gif)
getBounds ![](../../../diffpics/oold.gif)
()
-
Return the bounding box of the path.
-
-
Specified by:
-
getBounds
in interface
Shape
-
-
Returns:
-
a
Rectangle
object that bounds the current path.
-
See Also:
-
Shape.getBounds2D()
getBounds2D
![](../../../diffpics/oold.gif)
public ![](../../../diffpics/oold.gif)
Rectangle2D![](../../../diffpics/oold.gif)
getBounds2D ![](../../../diffpics/oold.gif)
()
-
Returns the bounding box of the path.
-
-
Specified by:
-
getBounds2D
in interface
Shape
-
-
Returns:
-
a
Rectangle2D
object that bounds the current path.
-
See Also:
-
Shape.getBounds()
contains
![](../../../diffpics/oold.gif)
public boolean ![](../../../diffpics/oold.gif)
contains ![](../../../diffpics/oold.gif)
(double x,
double y)
-
Tests if the specified coordinates are inside the boundary of this Shape.
-
-
Specified by:
-
contains
in interface
Shape
-
-
Parameters:
-
x, y - the specified coordinates
-
Returns:
-
true if the specified coordinates are inside this Shape; false otherwise
contains
![](../../../diffpics/oold.gif)
public boolean ![](../../../diffpics/oold.gif)
contains ![](../../../diffpics/oold.gif)
( ![](../../../diffpics/oold.gif)
Point2D![](../../../diffpics/oold.gif)
p)
-
Tests if the specified Point2D is inside the boundary of this Shape.
-
-
Specified by:
-
contains
in interface
Shape
-
-
Parameters:
-
p - the specified Point2D
-
Returns:
-
true if this Shape contains the specified Point2D, false otherwise.
contains
![](../../../diffpics/oold.gif)
public boolean ![](../../../diffpics/oold.gif)
contains ![](../../../diffpics/oold.gif)
(double x,
double y,
double w,
double h)
-
Tests if the specified rectangular area is inside the boundary of this Shape.
-
-
Specified by:
-
contains
in interface
Shape
-
-
Parameters:
-
x, y - the specified coordinates
-
w - the width of the specified rectangular area
-
h - the height of the specified rectangular area
-
Returns:
-
true if this Shape contains the specified rectangluar area; false otherwise.
-
See Also:
-
Area
,
Shape.intersects(double, double, double, double)
contains
![](../../../diffpics/oold.gif)
public boolean ![](../../../diffpics/oold.gif)
contains ![](../../../diffpics/oold.gif)
( ![](../../../diffpics/oold.gif)
Rectangle2D![](../../../diffpics/oold.gif)
r)
-
Tests if the specified Rectangle2D is inside the boundary of this Shape.
-
-
Specified by:
-
contains
in interface
Shape
-
-
Parameters:
-
r - a specified Rectangle2D
-
Returns:
-
true if this Shape bounds the specified Rectangle2D; false otherwise.
-
See Also:
-
Shape.contains(double, double, double, double)
intersects
![](../../../diffpics/oold.gif)
public boolean ![](../../../diffpics/oold.gif)
intersects ![](../../../diffpics/oold.gif)
(double x,
double y,
double w,
double h)
-
Tests if the interior of this Shape intersects the interior of a specified set of rectangular coordinates.
-
-
Specified by:
-
intersects
in interface
Shape
-
-
Parameters:
-
x, y - the specified coordinates
-
w - the width of the specified rectangular coordinates
-
h - the height of the specified rectangular coordinates
-
Returns:
-
true if this Shape and the interior of the specified set of rectangular coordinates intersect each other; false otherwise.
-
See Also:
-
Area
intersects
![](../../../diffpics/oold.gif)
public boolean ![](../../../diffpics/oold.gif)
intersects ![](../../../diffpics/oold.gif)
( ![](../../../diffpics/oold.gif)
Rectangle2D![](../../../diffpics/oold.gif)
r)
-
Tests if the interior of this Shape intersects the interior of a specified Rectangle2D.
-
-
Specified by:
-
intersects
in interface
Shape
-
-
Parameters:
-
r - the specified Rectangle2D
-
Returns:
-
true if this Shape and the interior of the specified Rectangle2D intersect each other; false otherwise.
-
See Also:
-
Shape.intersects(double, double, double, double)
getPathIterator
![](../../../diffpics/oold.gif)
public ![](../../../diffpics/oold.gif)
PathIterator![](../../../diffpics/oold.gif)
getPathIterator ![](../../../diffpics/oold.gif)
( ![](../../../diffpics/oold.gif)
AffineTransform![](../../../diffpics/oold.gif)
at)
-
Returns a PathIterator object that iterates along the boundary of this Shape and provides access to the geometry of the outline of this Shape. The iterator for this class is not multi-threaded safe, which means that this GeneralPath class does not guarantee that modifications to the geometry of this GeneralPath object do not affect any iterations of that geometry that are already in process.
-
-
Specified by:
-
getPathIterator
in interface
Shape
-
-
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
getPathIterator
![](../../../diffpics/oold.gif)
public ![](../../../diffpics/oold.gif)
PathIterator![](../../../diffpics/oold.gif)
getPathIterator ![](../../../diffpics/oold.gif)
( ![](../../../diffpics/oold.gif)
AffineTransform![](../../../diffpics/oold.gif)
at,
double flatness)
-
Returns a PathIterator object that iterates along the boundary of the flattened Shape and provides access to the geometry of the outline of the Shape. The iterator for this class is not multi-threaded safe, which means that this GeneralPath class does not guarantee that modifications to the geometry of this GeneralPath object do not affect any iterations of that geometry that are already in process.
-
-
Specified by:
-
getPathIterator
in interface
Shape
-
-
Parameters:
-
at - an AffineTransform
-
flatness - the maximum distance that the line segments used to approximate the curved segments are allowed to deviate from any point on the original curve
-
Returns:
-
a new PathIterator that iterates along the flattened Shape boundary.
clone
![](../../../diffpics/oold.gif)
public ![](../../../diffpics/oold.gif)
Object![](../../../diffpics/oold.gif)
clone ![](../../../diffpics/oold.gif)
()
-
Creates a new object of the same class as this object.
-
-
Overrides:
-
clone
in class
Object
-
-
Returns:
-
a clone of this instance.
-
Throws:
-
OutOfMemoryError
- if there is not enough memory.
-
Since:
-
1.2
-
See Also:
-
Cloneable