m865.shapepack
Class Ellipse

java.lang.Object
  extended by m865.shapepack.Shape
      extended by m865.shapepack.Ellipse

public class Ellipse
extends Shape

The concrete Shape subclass that defines ellipses.


Field Summary
 
Fields inherited from class m865.shapepack.Shape
color, defaultColor, defaultHeight, defaultWidth, height, width, x, y
 
Constructor Summary
Ellipse(int x, int y)
          Constructor for an ellipse at the specified location with the default width, height, and color.
Ellipse(int x, int y, int w, int h, java.awt.Color c)
          /** The generic Ellipse constructor
 
Method Summary
 float area()
          Calculates the area of the ellipse.
 void draw(java.awt.Graphics g)
          Draws the ellipse.
 float perimeter()
          Calculates an approximation to the perimeter of the ellipse.
 java.lang.String toString()
          Generates a string describing the parameters of the shape.
 
Methods inherited from class m865.shapepack.Shape
getColor, getHeight, getWidth, getX, getY, moveTo, setColor, setHeight, setWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Ellipse

public Ellipse(int x,
               int y,
               int w,
               int h,
               java.awt.Color c)
/** The generic Ellipse constructor

Parameters:
x - horizontal coordinate of the upper left corner of the bounding box.
y - vertical coordinate of the upper left corner of the bounding box.
w - the length of the horizontal axis of the ellipse.
h - the length of the vertical axis of the ellipse.
c - fill color for the ellipse.

Ellipse

public Ellipse(int x,
               int y)
Constructor for an ellipse at the specified location with the default width, height, and color.

Parameters:
x - horizontal coordinate of the upper left corner of the bounding box.
y - vertical coordinate of the upper left corner of the bounding box.
Method Detail

draw

public void draw(java.awt.Graphics g)
Draws the ellipse.

Specified by:
draw in class Shape
Parameters:
g - the graphics object on which the shape is to be drawn.

area

public float area()
Calculates the area of the ellipse.

Specified by:
area in class Shape
Returns:
the area of the ellipse.

perimeter

public float perimeter()
Calculates an approximation to the perimeter of the ellipse.

Specified by:
perimeter in class Shape
Returns:
the approximate perimeter of the ellipse.

toString

public java.lang.String toString()
Description copied from class: Shape
Generates a string describing the parameters of the shape.

Overrides:
toString in class Shape