All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.Polygon
java.lang.Object
|
+----java.awt.Polygon
- public class Polygon
- extends Object
- implements Shape, Serializable
A polygon consists of a list of x and y coordinates.
-
bounds
-
-
npoints
- The total number of points.
-
xpoints
- The array of x coordinates.
-
ypoints
- The array of y coordinates.
-
Polygon()
- Creates an empty polygon.
-
Polygon(int[], int[], int)
- Constructs and initializes a Polygon from the specified parameters.
-
addPoint(int, int)
- Appends a point to a polygon.
-
contains(int, int)
- Determines whether the point (x,y) is inside the Polygon.
-
contains(Point)
- Determines whether the specified point is inside the Polygon.
-
getBoundingBox()
-
Deprecated.
-
getBounds()
- Returns the bounding box of the shape.
-
inside(int, int)
-
Deprecated.
-
translate(int, int)
- Translates the vertices by deltaX, deltaY.
npoints
Properties Public
npoints=int
- The total number of points.
xpoints
Properties Public
xpoints[]=int
- The array of x coordinates.
ypoints
Properties Public
ypoints[]=int
- The array of y coordinates.
bounds
Properties Inheritable
bounds=Rectangle
Polygon
method Polygon() public
- Creates an empty polygon.
Polygon
method Polygon(xpoints=int[], -
ypoints=int[], -
npoints=int) public
- Constructs and initializes a Polygon from the specified parameters.
- Parameters:
- xpoints - the array of x coordinates
- ypoints - the array of y coordinates
- npoints - the total number of points in the Polygon
translate
method translate(deltaX=int, -
deltaY=int) public
- Translates the vertices by deltaX, deltaY.
- Parameters:
- deltaX - the amount to move the X coords
- deltaY - the amount to move the Y coords
addPoint
method addPoint(x=int, -
y=int) public
- Appends a point to a polygon. If inside(x, y) or another
operation that calculates the bounding box has already been
performed, this method updates the bounds accordingly.
- Parameters:
- x - the x coordinate of the point
- y - the y coordinate of the point
getBounds
method getBounds() returns Rectangle public
- Returns the bounding box of the shape.
- Returns:
- a Rectangle defining the bounds of the Polygon.
getBoundingBox
method getBoundingBox() returns Rectangle public
- Note: getBoundingBox() is deprecated.
As of JDK version 1.1,
replaced by getBounds().
contains
method contains(p=Point) returns boolean public
- Determines whether the specified point is inside the Polygon.
Uses an even-odd insideness rule (also known as an alternating
rule).
- Parameters:
- p - the point to be tested
contains
method contains(x=int, -
y=int) returns boolean public
- Determines whether the point (x,y) is inside the Polygon. Uses
an even-odd insideness rule (also known as an alternating
rule).
- Parameters:
- x - the X coordinate of the point to be tested
- y - the Y coordinate of the point to be tested
Kindly donated by Hanpeter van Vliet .
inside
method inside(x=int, -
y=int) returns boolean public
- Note: inside() is deprecated.
As of JDK version 1.1,
replaced by contains(int, int).
All Packages Class Hierarchy This Package Previous Next Index