Package ro.sync.exml.view.graphics
Class Polygon
java.lang.Object
ro.sync.exml.view.graphics.BaseShape
ro.sync.exml.view.graphics.Polygon
- All Implemented Interfaces:
Shape
,ro.sync.exml.view.graphics.ShapePointContributor
@API(type=EXTENDABLE,
src=PRIVATE)
public class Polygon
extends BaseShape
implements ro.sync.exml.view.graphics.ShapePointContributor
The
Polygon
class encapsulates a description of a
closed, two-dimensional region within a coordinate space.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
npoints
public int npointsThe total number of points. The value ofnpoints
represents the number of valid points in thisPolygon
and might be less than the number of elements inxpoints
orypoints
. This value can be NULL.- See Also:
-
xpoints
public int[] xpointsThe array of x coordinates. The number of elements in this array might be more than the number of x coordinates in thisPolygon
. The extra elements allow new points to be added to thisPolygon
without re-creating this array. The value ofnpoints
is equal to the number of valid points in thisPolygon
.- See Also:
-
ypoints
public int[] ypointsThe array of y coordinates. The number of elements in this array might be more than the number of y coordinates in thisPolygon
. The extra elements allow new points to be added to thisPolygon
without re-creating this array. The value ofnpoints
is equal to the number of valid points in thisPolygon
.- See Also:
-
-
Constructor Details
-
Polygon
public Polygon()Creates an empty polygon. -
Polygon
public Polygon(int[] xpoints, int[] ypoints, int npoints) Constructs and initializes aPolygon
from the specified parameters.- Parameters:
xpoints
- an array of x coordinatesypoints
- an array of y coordinatesnpoints
- the total number of points in thePolygon
- Throws:
NegativeArraySizeException
- if the value ofnpoints
is negative.IndexOutOfBoundsException
- ifnpoints
is greater than the length ofxpoints
or the length ofypoints
.NullPointerException
- ifxpoints
orypoints
isnull
.
-
-
Method Details
-
addPoint
public void addPoint(int x, int y) Appends the specified coordinates to thisPolygon
.If an operation that calculates the bounding box of this
Polygon
has already been performed, such asgetBounds
orcontains
, then this method updates the bounding box.- Specified by:
addPoint
in interfacero.sync.exml.view.graphics.ShapePointContributor
- Parameters:
x
- the specified x coordinatey
- the specified y coordinate- See Also:
-
getBounds
-
translate
Description copied from interface:Shape
Translate the shape into another one. -
contains
public boolean contains(int x, int y) Check if this complicated shape contains the requested point.
-