All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.geom.GeneralPath
java.lang.Object
|
+----java.awt.geom.GeneralPath
- public final class GeneralPath
- extends Object
- implements Shape
This class represents a geometric path constructed from straight
lines, quadratic and cubic (Bezier) curves. It can contain multiple
subpaths.
The winding rule specifies how the interior of a path will be
determined. There are two types of winding rules: EVEN_ODD and
NON_ZERO. 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. For a NON_ZERO winding rule, we start by conceptually
drawing a ray from a given point to infinity in any direction
and then by examining all of the places where the path intersects
the ray. We now traverse the path in one direction and keep
track of the number of times that the path crosses the ray from
left to right, and the number of times that the path crosses the
ray from right to left. If these numbers are equal, the point
is outside of the path. If they are not equal, the point is
inside.
EVEN_ODD- An even-odd winding rule for determining the interior of
a path.
NON_ZERO- A non-zero winding rule for determining the interior of a
path.
GeneralPath()
- Constructs a new GeneralPath object.
GeneralPath(int)
- 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, int)
- Constructs a new GeneralPath object with the specified winding
rule and the specified initial capacity to store path coordinates.
append(PathIterator, boolean)
- Appends the geometry of the specified PathIterator object to the
path, possibly connecting the geometry to the existing path
segments with a line segment.
append(Shape, boolean)
- Appends the geometry of the specified Shape object to the
path, possibly connecting the geometry to the existing path
segments with a line segment.
closePath()
- Closes the current subpath by drawing a straight line back to
the coordinates of the last moveTo.
contains(double, double)
- Test if a given coordinate is inside the boundary of the shape.
contains(double, double, double, double)
- Test if a given coordinate is inside the boundary of the shape.
contains(Point2D)
- Test if a given Point is inside the boundary of the shape.
contains(Rectangle2D)
- Test if a given Point is inside the boundary of the shape.
createTransformedShape(AffineTransform)
- Returns a new transformed Path.
curveTo(float, float, float, float, float, float)
- Adds 3 points to the path by drawing a Bezier curve from the
current coordinates through the third set of specified
coordinates, using the first and second sets of specified
coordinates as Bezier control points.
getBounds()
- Return the bounding box of the shape.
getBounds2D()
- Returns the bounding box of the path.
getCurrentPoint()
- Returns the most recent point added to the end of the path.
getPathIterator(AffineTransform)
- Return an iterator object that iterates along the boundary of
the shape and provides access to the geometry of the outline
of the shape.
getPathIterator(AffineTransform, double)
- Return an iterator object that iterates along the boundary of
the flattened shape and provides access to the geometry of the
outline of the shape.
getWindingRule()
- Returns the fill style winding rule.
intersects(double, double, double, double)
- Test if the interior of the Shape intersects the interior of a given
set of rectangular coordinates.
intersects(Rectangle2D)
- Test if the interior of the Shape intersects the interior of a given
Rectangle.
lineTo(float, float)
- Adds a point to the path by drawing a straight line from the
current coordinates to the new specified coordinates.
moveTo(float, float)
- Adds a point to the path by moving to the specified
coordinates.
quadTo(float, float, float, float)
- Adds 2 points to the path by drawing a Quadratic curve from
the current coordinates through the second set of specified
coordinates, using the first set of specified coordinates as
a quadratic parametric control point.
reset()
- Resets the path to empty.
setWindingRule(int)
- Sets the winding rule for this path to the specified value.
EVEN_ODD
public static final byte EVEN_ODD
- An even-odd winding rule for determining the interior of
a path.
NON_ZERO
public static final byte NON_ZERO
- A non-zero winding rule for determining the interior of a
path.
GeneralPath
public GeneralPath()
- Constructs a new GeneralPath object.
If an operation is performed on this path which requires the
interior of the path to be defined, then the default NON_ZERO
winding rule is used.
- See Also:
- NON_ZERO
GeneralPath
public 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.
- Parameters:
- rule - The winding rule.
- See Also:
- EVEN_ODD, NON_ZERO
GeneralPath
public GeneralPath(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 coordinates will
be in the path, but the storage will be 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 coordinates
in the path.
- See Also:
- EVEN_ODD, NON_ZERO
moveTo
public void moveTo(float x,
float y)
- Adds a point to the path by moving to the specified
coordinates.
lineTo
public 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.
quadTo
public void quadTo(float x1,
float y1,
float x2,
float y2)
- Adds 2 points to the path by drawing a Quadratic curve from
the current coordinates through the second set of specified
coordinates, using the first set of specified coordinates as
a quadratic parametric control point.
- Parameters:
- x1 - the X coordinate of the first quadratic control point
- y1 - the Y coordinate of the first quadratic control point
- x2 - the X coordinate of the final endpoint
- y2 - the Y coordinate of the final endpoint
curveTo
public void curveTo(float x1,
float y1,
float x2,
float y2,
float x3,
float y3)
- Adds 3 points to the path by drawing a Bezier curve from the
current coordinates through the third set of specified
coordinates, using the first and second sets of specified
coordinates as Bezier control points.
- Parameters:
- x1 - the X coordinate of the first Bezier control point
- y1 - the Y coordinate of the first Bezier control point
- x2 - the X coordinate of the second Bezier control point
- y2 - the Y coordinate of the second Bezier control point
- x3 - the X coordinate of the final endpoint
- y3 - the Y coordinate of the final endpoint
closePath
public void closePath()
- 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
public void append(Shape s,
boolean connect)
- Appends the geometry of the specified Shape object to the
path, possibly connecting the 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
will be 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 will be omitted as superfluous.
The winding rule of the specified Shape will be ignored
and the appended geometry will be governed by the winding
rule specified for this path.
- Parameters:
- s - the shape whose geometry will be 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
public void append(PathIterator pi,
boolean connect)
- Appends the geometry of the specified PathIterator object to the
path, possibly connecting the 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
will be 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 will be omitted as superfluous.
The winding rule of the specified Shape will be ignored
and the appended geometry will be governed by the winding
rule specified for this path.
- Parameters:
- s - the shape whose geometry will be 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
public int getWindingRule()
- Returns the fill style winding rule.
setWindingRule
public void setWindingRule(int rule)
- Sets the winding rule for this path to the specified value.
getCurrentPoint
public Point2D getCurrentPoint()
- Returns the most recent point added to the end of the path.
- Returns:
- a Point object containing the ending coordinate of the
path or null if there are no points in the path.
reset
public void reset()
- 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.
createTransformedShape
public Shape createTransformedShape(AffineTransform t)
- Returns a new transformed Path.
getBounds
public Rectangle getBounds()
- Return the bounding box of the shape.
getBounds2D
public Rectangle2D getBounds2D()
- Returns the bounding box of the path.
contains
public boolean contains(double x,
double y)
- Test if a given coordinate is inside the boundary of the shape.
contains
public boolean contains(Point2D p)
- Test if a given Point is inside the boundary of the shape.
contains
public boolean contains(double x,
double y,
double w,
double h)
- Test if a given coordinate is inside the boundary of the shape.
contains
public boolean contains(Rectangle2D r)
- Test if a given Point is inside the boundary of the shape.
intersects
public boolean intersects(double x,
double y,
double w,
double h)
- Test if the interior of the Shape intersects the interior of a given
set of rectangular coordinates.
intersects
public boolean intersects(Rectangle2D r)
- Test if the interior of the Shape intersects the interior of a given
Rectangle.
getPathIterator
public PathIterator getPathIterator(AffineTransform at)
- Return an iterator object that iterates along the boundary of
the shape and provides access to the geometry of the outline
of the shape.
getPathIterator
public PathIterator getPathIterator(AffineTransform at,
double flatness)
- Return an iterator object that iterates along the boundary of
the flattened shape and provides access to the geometry of the
outline of the shape.
All Packages Class Hierarchy This Package Previous Next Index
Submit a bug or feature