java.awt.geom
Class GeneralPath

The GeneralPath class represents a geometric path
constructed from straight lines, and quadratic and cubic
(Bézier) curves. It can contain multiple subpaths.

The winding rule specifies how the interior of a path is
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.

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.

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.

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.

getPathIterator(AffineTransform 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.

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 r)
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.

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 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

GeneralPath

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

Method Detail

moveTo

public void moveTo(float x,
float y)

Adds a point to the path by moving to the specified
coordinates.

Parameters:

x, y - 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.

Parameters:

x, y - the specified coordinates

quadTo

public 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.

Parameters:

x1, y1 - the coordinates of the first quadratic control
point

x2, y2 - the coordinates of the final endpoint

curveTo

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:

x1, y1 - the coordinates of the first Béezier
control point

x2, y2 - the coordinates of the second Bézier
control point

x3, y3 - the coordinates 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

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

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

getPathIterator

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.

getPathIterator

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.

Submit a bug or featureJava, Java 2D, and JDBC are a trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.Copyright 1993-1999 Sun Microsystems, Inc. 901 San Antonio Road,Palo Alto, California, 94303, U.S.A. All Rights Reserved.