| Constructor and Description |
|---|
GPolygon()
Constructs a new empty polygon at the origin.
|
GPolygon(float x,
float y)
Constructs a new empty polygon at (
x, y). |
GPolygon(GPoint[] points)
Constructs a new polygon from the specified array of
GPoint
objects. |
| Modifier and Type | Method and Description |
|---|---|
void |
addArc(float arcWidth,
float arcHeight,
float start,
float sweep)
Adds a series of edges to the polygon that simulates the arc specified by
the parameters.
|
void |
addEdge(float dx,
float dy)
Adds an edge to the polygon whose components are given by the displacements
dx and dy from the last vertex. |
void |
addPolarEdge(float r,
float theta)
Adds an edge to the polygon specified in polar coordinates.
|
void |
addVertex(float x,
float y)
Adds a vertex at (
x, y) relative to the polygon origin. |
protected void |
clear()
Calling this method deletes all vertices from the polygon and resets the
scale and rotation factors to the their default values.
|
Object |
clone()
Overrides
clone in Object to make sure
that the vertex list is copied rather than shared. |
boolean |
contains(float x,
float y)
Checks to see whether a point is inside the object.
|
GRectangle |
getBounds()
Returns the bounding box of this object, which is defined to be the
smallest rectangle that covers everything drawn by the figure.
|
GPoint |
getCurrentPoint()
Returns the coordinates of the last vertex added to the polygon, or
null
if the polygon is empty. |
Paint |
getFillColor()
Returns the color used to display the filled region of this object.
|
boolean |
isFilled()
Returns whether this object is filled.
|
protected void |
markAsComplete()
Calling this method makes it illegal to add or remove vertices from the
polygon.
|
void |
paint(Canvas canvas)
Implements the
paint operation for this graphical object. |
void |
recenter()
Recalculates the vertices of the polygon so that they are positioned
relative to the geometric center of the object.
|
void |
repaint()
Overrides
repaint in GObject to invalidate the
cached polygon. |
void |
rotate(float theta)
Rotates the polygon around its origin by the angle theta, measured in degrees.
|
void |
scale(float sf)
Scales the object on the screen by the scale factor
sf, which applies
in both dimensions. |
void |
scale(float sx,
float sy)
Scales the polygon by the scale factors
sx and sy. |
void |
setFillColor(Paint color)
Sets the color used to display the filled region of this object.
|
void |
setFilled(boolean fill)
Sets whether this object is filled.
|
contains, getBottomY, getCenterX, getCenterY, getColor, getGCanvas, getHeight, getLocation, getPaint, getRightX, getSize, getWidth, getX, getY, intersects, isVisible, moveBy, moveByPolar, moveTo, moveTo, moveToPolar, sendBackward, sendForward, sendToBack, sendToFront, setBottomY, setCanvas, setColor, setGCanvas, setLocation, setLocation, setPaint, setRightX, setVisible, setX, setY, toString, translatepublic GPolygon()
public GPolygon(float x,
float y)
x, y).x - The x-coordinate of the origin of the polygony - The y-coordinate of the origin of the polygonpublic GPolygon(GPoint[] points)
GPoint
objects. The polygon is automatically marked as complete.points - An array of GPoint objects specifying the verticespublic void addVertex(float x,
float y)
x, y) relative to the polygon origin.x - The x-coordinate of the vertex relative to the polygon originy - The y-coordinate of the vertex relative to the polygon originpublic void addEdge(float dx,
float dy)
dx and dy from the last vertex.dx - The x displacement through which the edge movesdy - The y displacement through which the edge movespublic final void addPolarEdge(float r,
float theta)
r, and the edge extends in direction theta,
measured in degrees counterclockwise from the +x axis.r - The length of the edgetheta - The angle at which the edge extends measured in degreespublic void addArc(float arcWidth,
float arcHeight,
float start,
float sweep)
arcWidth - The width of the oval from which the arc is takenarcHeight - The height of the oval from which the arc is takenstart - The angle at which the arc beginssweep - The extent of the arcpublic GPoint getCurrentPoint()
null
if the polygon is empty.null if emptypublic void scale(float sx,
float sy)
sx and sy.public final void scale(float sf)
sf, which applies
in both dimensions.public void rotate(float theta)
theta - The angle of rotation in degrees counterclockwisepublic void setFilled(boolean fill)
public boolean isFilled()
public void setFillColor(Paint color)
setFillColor in interface GFillablecolor - The color used to display the filled region of this objectpublic Paint getFillColor()
getFillColor returns the color of the
object.getFillColor in interface GFillablepublic GRectangle getBounds()
public boolean contains(float x,
float y)
public void paint(Canvas canvas)
paint operation for this graphical object. This method
is not called directly by clients.public void recenter()
public Object clone()
clone in Object to make sure
that the vertex list is copied rather than shared.public void repaint()
repaint in GObject to invalidate the
cached polygon.protected void markAsComplete()
protected void clear()