Class GPolygon

GObject
  extended by GFillableObject
      extended by GPolygon

The GPolygon class is a graphical object whose appearance consists of a polygon.


Constructor Summary
GPolygon()
Constructs a new empty polygon at the origin.
 
Method Summary
addEdge(dx, dy)
Adds an edge to the polygon whose components are given by the displacements dx and dy from the last vertex.
addPolarEdge(r, theta)
Adds an edge to the polygon specified in polar coordinates.
addVertex(x, y)
Adds a vertex at (x, y) relative to the polygon origin.
 
Inherited Method Summary
contains(x, y)
Checks to see whether a point is inside the object.
getBounds()
Returns the bounding box for this object.
getColor()
Returns the color used to display this object.
getFillColor()
Returns the color used to display the filled region of this object.
getHeight()
Returns the height of this object, which is defined to be the height of the bounding box.
getLocation()
Returns the location of this object as a GPoint.
getSize()
Returns the size of the bounding box for this object.
getWidth()
Returns the width of this object, which is defined to be the width of the bounding box.
getX()
Returns the x-coordinate of the object.
getY()
Returns the y-coordinate of the object.
isVisible()
Checks to see whether this object is visible.
isFilled()
Returns whether this object is filled.
move(dx, dy)
Moves the object on the screen using the displacements dx and dy.
movePolar(r, theta)
Moves the object using displacements given in polar coordinates.
scale(sf)
Scales the object on the screen by the scale factor sf, which applies in both dimensions.
sendBackward()
Moves this object one step toward the back in the z dimension.
sendForward()
Moves this object one step toward the front in the z dimension.
sendToBack()
Moves this object to the back of the display in the z dimension.
sendToFront()
Moves this object to the front of the display in the z dimension.
setColor(color)
Sets the color used to display this object.
setFillColor(color)
Sets the color used to display the filled region of this object.
setFilled(flag)
Sets whether this object is filled.
setLocation(x, y)
Sets the location of this object to the point (x, y).
setVisible(flag)
Sets whether this object is visible.
 

Constructor Detail

GPolygon()

Constructs a new empty polygon at the origin.
Usage: gpoly = GPolygon() 
 


Method Detail

addArc(arcWidth, arcHeight, start, sweep)

Adds a series of edges to the polygon that simulates the arc specified by the parameters. The x and y parameters for the arc bounding box are computed implicitly by figuring out what values would place the current vertex at the starting position.
Usage: gpoly.addArc(arcWidth, arcHeight, start, sweep) 
Parameters: 
arcWidth  The width of the oval from which the arc is taken
arcHeight  The height of the oval from which the arc is taken
start  The angle at which the arc begins
sweep  The extent of the arc
 


addEdge(dx, dy)

Adds an edge to the polygon whose components are given by the displacements dx and dy from the last vertex.
Usage: gpoly.addEdge(dx, dy) 
Parameters: 
dx  The x displacement through which the edge moves
dy  The y displacement through which the edge moves
 


addPolarEdge(r, theta)

Adds an edge to the polygon specified in polar coordinates. The length of the edge is given by r, and the edge extends in direction theta, measured in degrees counterclockwise from the +x axis.
Usage: gpoly.addPolarEdge(r, theta) 
Parameters: 
 The length of the edge
theta  The angle at which the edge extends measured in degrees
 


addVertex(x, y)

Adds a vertex at (x, y) relative to the polygon origin.
Usage: gpoly.addVertex(x, y) 
Parameters: 
 The x-coordinate of the vertex relative to the polygon origin
 The y-coordinate of the vertex relative to the polygon origin
 


getBounds()

Returns the bounding box of this object, which is defined to be the smallest rectangle that covers everything drawn by the figure.
Usage: bounds = gpoly.getBounds() 
Returns: The bounding box for this object