java.awt.geom
Class GeneralPath
- Cloneable, Shape
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)
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.
|
void | append(Shape s, boolean connect) - Appends the segments of a Shape to the path.
|
void | append(PathIterator iter, boolean connect) - Appends the segments of a PathIterator to this GeneralPath.
|
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.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
GeneralPath
public GeneralPath()
Constructs a GeneralPath with the default (NON_ZERO)
winding rule and initial capacity (20).
GeneralPath
public GeneralPath(int rule)
Constructs a GeneralPath with a specific winding rule
and the default initial capacity (20).
GeneralPath
public GeneralPath(int rule,
int capacity)
Constructs a GeneralPath with a specific winding rule
and the initial capacity. The initial capacity should be
the approximate number of path segments to be used.
GeneralPath
public GeneralPath(Shape s)
Constructs a GeneralPath from an arbitrary shape object.
The Shapes PathIterator path and winding rule will be used.
s
- the shape (null
not permitted).
append
public void append(Shape s,
boolean connect)
Appends the segments of a Shape to the path. If 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.
clone
public Object clone()
Creates a new shape of the same run-time type with the same contents
as this one.
- clone in interface Object
closePath
public void closePath()
Closes the current subpath by drawing a line
back to the point of the last moveTo, unless the path is already closed.
contains
public 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.
- contains in interface Shape
x
- x coordinate of the point to evaluatey
- y coordinate of the point to evaluate
- true if the point is within the path, false otherwise
contains
public boolean contains(double x,
double y,
double w,
double h)
Evaluates if a rectangle is completely contained within the path.
This method will return false in the cases when the box
intersects an inner segment of the path.
(i.e.: The method is accurate for the EVEN_ODD winding rule)
- contains in interface Shape
contains
public 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.
- contains in interface Shape
p
- The Point2D to evaluate
- true if the point is within the path, false otherwise
contains
public boolean contains(Rectangle2D r)
Evaluates if a rectangle is completely contained within the path.
This method will return false in the cases when the box
intersects an inner segment of the path.
(i.e.: The method is accurate for the EVEN_ODD winding rule)
- contains in interface Shape
true
if the rectangle is completely contained
within the path, false
otherwise
curveTo
public void curveTo(float x1,
float y1,
float x2,
float y2,
float x3,
float y3)
Appends a cubic Bezier curve to the current path.
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.
getPathIterator
public PathIterator getPathIterator(AffineTransform at)
Creates a PathIterator for iterating along the segments of the path.
- getPathIterator in interface Shape
at
- an affine transformation for projecting the returned
points, or null
to let the created iterator return
the original points without any mapping.
getWindingRule
public int getWindingRule()
Returns the path’s current winding rule.
intersects
public boolean intersects(double x,
double y,
double w,
double h)
Evaluates if a rectangle intersects the path.
- intersects in interface Shape
x
- 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
otherwise
intersects
public boolean intersects(Rectangle2D r)
Evaluates if a Rectangle2D intersects the path.
- intersects in interface Shape
true
if the rectangle intersects the path,
false
otherwise
lineTo
public void lineTo(float x,
float y)
Appends a straight line to the current path.
x
- x coordinate of the line endpoint.y
- y coordinate of the line endpoint.
moveTo
public void moveTo(float x,
float y)
Adds a new point to a path.
x
- the x-coordinate.y
- the y-coordinate.
quadTo
public void quadTo(float x1,
float y1,
float x2,
float y2)
Appends a quadratic Bezier curve to the current path.
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.
reset
public void reset()
Resets the path. All points and segments are destroyed.
setWindingRule
public void setWindingRule(int rule)
Sets the path’s winding rule, which controls which areas are
considered ’inside’ or ’outside’ the path
on drawing. Valid rules are WIND_EVEN_ODD for an even-odd winding rule,
or WIND_NON_ZERO for a non-zero winding rule.
transform
public void transform(AffineTransform xform)
Applies a transform to the path.
xform
- the transform (null
not permitted).
GeneralPath.java -- represents a shape built from subpaths
Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.