|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.geom.GeneralPath
public final class GeneralPath
A general geometric path, consisting of any number of subpaths constructed out of straight lines and cubic or quadratic Bezier curves.
The inside of the curve is defined for drawing purposes by a winding rule. Either the WIND_EVEN_ODD or WIND_NON_ZERO winding rule can be chosen.
The EVEN_ODD winding rule defines a point as inside a path if: A ray from the point towards infinity in an arbitrary direction intersects the path an odd number of times. Points A and C in the image are considered to be outside the path. (both intersect twice) Point B intersects once, and is inside.
The NON_ZERO winding rule defines a point as inside a path if: The path intersects the ray in an equal number of opposite directions. Point A in the image is outside (one intersection in the ’up’ direction, one in the ’down’ direction) Point B in the image is inside (one intersection ’down’) Point C in the image is inside (two intersections in the ’down’ direction)
Line2D,
CubicCurve2D,
QuadCurve2D| Field Summary | |
|---|---|
static int |
WIND_EVEN_ODD
Same constant as PathIterator.WIND_EVEN_ODD. |
static int |
WIND_NON_ZERO
Same constant as PathIterator.WIND_NON_ZERO. |
| Constructor Summary | |
|---|---|
GeneralPath()
Constructs a GeneralPath with the default (NON_ZERO) winding rule and initial capacity (20). |
|
GeneralPath(int rule)
Constructs a GeneralPath with a specific winding rule and the default initial capacity (20). |
|
GeneralPath(int rule,
int capacity)
Constructs a GeneralPath with a specific winding rule and the initial capacity. |
|
GeneralPath(Shape s)
Constructs a GeneralPath from an arbitrary shape object. |
|
| Method Summary | |
|---|---|
void |
append(PathIterator iter,
boolean connect)
Appends the segments of a PathIterator to this GeneralPath. |
void |
append(Shape s,
boolean connect)
Appends the segments of a Shape to the path. |
Object |
clone()
Creates a new shape of the same run-time type with the same contents as this one. |
void |
closePath()
Closes the current subpath by drawing a line back to the point of the last moveTo, unless the path is already closed. |
boolean |
contains(double x,
double y)
Evaluates if a point is within the GeneralPath, The NON_ZERO winding rule is used, regardless of the set winding rule. |
boolean |
contains(double x,
double y,
double w,
double h)
Evaluates if a rectangle is completely contained within the path. |
boolean |
contains(Point2D p)
Evaluates if a Point2D is within the GeneralPath, The NON_ZERO winding rule is used, regardless of the set winding rule. |
boolean |
contains(Rectangle2D r)
Evaluates if a rectangle is completely contained within the path. |
Shape |
createTransformedShape(AffineTransform xform)
Creates a transformed version of the path. |
void |
curveTo(float x1,
float y1,
float x2,
float y2,
float x3,
float y3)
Appends a cubic Bezier curve to the current path. |
Rectangle |
getBounds()
Returns the path’s bounding box. |
Rectangle2D |
getBounds2D()
Returns the path’s bounding box, in float precision |
Point2D |
getCurrentPoint()
Returns the current appending point of the path. |
PathIterator |
getPathIterator(AffineTransform at)
Creates a PathIterator for iterating along the segments of the path. |
PathIterator |
getPathIterator(AffineTransform at,
double flatness)
Creates a new FlatteningPathIterator for the path |
int |
getWindingRule()
Returns the path’s current winding rule. |
boolean |
intersects(double x,
double y,
double w,
double h)
Evaluates if a rectangle intersects the path. |
boolean |
intersects(Rectangle2D r)
Evaluates if a Rectangle2D intersects the path. |
void |
lineTo(float x,
float y)
Appends a straight line to the current path. |
void |
moveTo(float x,
float y)
Adds a new point to a path. |
void |
quadTo(float x1,
float y1,
float x2,
float y2)
Appends a quadratic Bezier curve to the current path. |
void |
reset()
Resets the path. |
void |
setWindingRule(int rule)
Sets the path’s winding rule, which controls which areas are considered ’inside’ or ’outside’ the path on drawing. |
void |
transform(AffineTransform xform)
Applies a transform to the path. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int WIND_EVEN_ODD
PathIterator.WIND_EVEN_ODD.
public static final int WIND_NON_ZERO
PathIterator.WIND_NON_ZERO.
| Constructor Detail |
|---|
public GeneralPath()
public GeneralPath(int rule)
rule - the winding rule (WIND_NON_ZERO or
WIND_EVEN_ODD)
IllegalArgumentException - if rule is not one of the
listed values.
public GeneralPath(int rule,
int capacity)
rule - the winding rule (WIND_NON_ZERO or
WIND_EVEN_ODD)capacity - the inital capacity, in path segments
IllegalArgumentException - if rule is not one of the
listed values.public GeneralPath(Shape s)
s - the shape (null not permitted).
NullPointerException - if shape is null.| Method Detail |
|---|
public void moveTo(float x,
float y)
x - the x-coordinate.y - the y-coordinate.
public void lineTo(float x,
float y)
x - x coordinate of the line endpoint.y - y coordinate of the line endpoint.
public void quadTo(float x1,
float y1,
float x2,
float y2)
x1 - x coordinate of the control pointy1 - y coordinate of the control pointx2 - x coordinate of the curve endpoint.y2 - y coordinate of the curve endpoint.
public void curveTo(float x1,
float y1,
float x2,
float y2,
float x3,
float y3)
x1 - x coordinate of the first control pointy1 - y coordinate of the first control pointx2 - x coordinate of the second control pointy2 - y coordinate of the second control pointx3 - x coordinate of the curve endpoint.y3 - y coordinate of the curve endpoint.public void closePath()
public void append(Shape s,
boolean connect)
connect is
true, the new path segments are connected to the existing one with a line.
The winding rule of the Shape is ignored.
s - the shape (null not permitted).connect - whether to connect the new shape to the existing path.
NullPointerException - if s is null.
public void append(PathIterator iter,
boolean connect)
PathIterator.SEG_MOVETO segment
of the appended path is changed into a PathIterator.SEG_LINETO segment.
iter - the PathIterator specifying which segments shall be
appended (null not permitted).connect - true for substituting the initial
PathIterator.SEG_MOVETO segment by a PathIterator.SEG_LINETO, or false for not
performing any substitution. If this GeneralPath is currently
empty, connect is assumed to be false,
thus leaving the initial PathIterator.SEG_MOVETO
unchanged.public int getWindingRule()
WIND_EVEN_ODD or WIND_NON_ZERO.public void setWindingRule(int rule)
rule - the rule (WIND_EVEN_ODD or WIND_NON_ZERO).public Point2D getCurrentPoint()
public void reset()
public void transform(AffineTransform xform)
xform - the transform (null not permitted).public Shape createTransformedShape(AffineTransform xform)
xform - the transform to apply
public Rectangle getBounds()
getBounds in interface ShapeShape.getBounds2D()public Rectangle2D getBounds2D()
float precision
getBounds2D in interface ShapeShape.getBounds()
public boolean contains(double x,
double y)
contains in interface Shapex - x coordinate of the point to evaluatey - y coordinate of the point to evaluate
public boolean contains(Point2D p)
contains in interface Shapep - The Point2D to evaluate
public boolean contains(double x,
double y,
double w,
double h)
contains in interface Shapex - the x coordinate of the rectangley - the y coordinate of the rectanglew - the width of the rectangle, undefined results if negativeh - the height of the rectangle, undefined results if negative
Areapublic boolean contains(Rectangle2D r)
contains in interface Shaper - the rectangle
true if the rectangle is completely contained
within the path, false otherwiseShape.contains(double, double, double, double)
public boolean intersects(double x,
double y,
double w,
double h)
intersects in interface Shapex - x coordinate of the rectangley - y coordinate of the rectanglew - width of the rectangleh - height of the rectangle
true if the rectangle intersects the path,
false otherwiseAreapublic boolean intersects(Rectangle2D r)
intersects in interface Shaper - The rectangle
true if the rectangle intersects the path,
false otherwiseShape.intersects(double, double, double, double)public PathIterator getPathIterator(AffineTransform at)
getPathIterator in interface Shapeat - an affine transformation for projecting the returned
points, or null to let the created iterator return
the original points without any mapping.
public PathIterator getPathIterator(AffineTransform at,
double flatness)
getPathIterator in interface Shapeat - an optional transform to apply to the
iterator (null permitted).flatness - the maximum distance for deviation from the real boundary
public Object clone()
clone in class ObjectOutOfMemoryError - If there is not enough memory available.Cloneable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||