All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object

+java.awt.Polygon
Polygon
class encapsulates a description of a
closed, twodimensional region within a coordinate space. This
region is bounded by an arbitrary number of line segments, each of
which is one side of the polygon. Internally, a polygon
comprises of a list of (x, y) coordinate pairs,
where each pair defines a vertex of the polygon, and two
successive pairs are the endpoints of a line that is a side of the
polygon. The first and final pairs of (x, y)
points are joined by a line segment that closes the polygon.
deltaX
along the
x axis and by deltaY
along the
y axis.
public int npoints
public int xpoints[]
public int ypoints[]
protected Rectangle bounds
public Polygon()
public Polygon(int xpoints[],
int ypoints[],
int npoints)
npoints
is negative.
public void translate(int deltaX,
int deltaY)
deltaX
along the
x axis and by deltaY
along the
y axis.
public void addPoint(int x,
int y)
If an operation that calculates the bounding box of this polygon
has already been performed, such as getBounds
or contains
, then this method updates the bounding box.
public Rectangle getBounds()
public Rectangle getBoundingBox()
getBounds()
.
public boolean contains(Point p)
public boolean contains(int x,
int y)
(The contains
method is based on code by
Hanpeter van Vliet [hvvliet@inter.nl.net].)
true
if the point (x, y)
is contained by this polygon;
false
otherwise.
public boolean inside(int x,
int y)
contains(int, int)
.
All Packages Class Hierarchy This Package Previous Next Index