
import wheels.users.CoordinateFrame;
import wheels.users.Ellipse;

import java.awt.Color;

/**
 * Models a circle.  The circle is centered at an (x,y) position,
 * with a given radius.  It also has a color, used when drawing
 * on a CoordinatePlane.
 * 
 * @author Zach Tomaszewski
 * @version 28 Sept 2007
 */
public class Circle {

  protected static CoordinateFrame display = new CoordinateFrame();
  
  private double xPos;
  private double yPos;
  private double radius;
  private Color color;
  
  
  /**
   * Creates a new Circle centered at the given (x,y), 
   * with the specified radius and color.  
   */
  public Circle(double x, double y, double radius, Color c) {
    xPos = x;
    yPos = y;
    this.radius = radius;
    color = c;
  }
  
  /**
   * Constructs a green circle with a radius of 100.
   */
  public Circle(double x, double y) {
    this(x, y, 100, Color.green);
  }
  
  
  /**
   * Draws a circle on the frame.
   */
  public void draw() {
    //use wheels shape to draw on CoordFrame display
    Ellipse ellipse = new Ellipse((int) (this.xPos - this.radius), 
                                  (int) (this.yPos - this.radius));
    ellipse.setFrameColor(this.color);
    ellipse.setFillColor(Color.white);
    ellipse.setSize((int) this.radius * 2, (int) this.radius * 2);
  }
  
  /**
   * Returns a String of this circle in the form:
   * Circle(<i>x</i>, <i>y</i>; r=<i>radius</i>)
   */
  public String toString() {
    return "Circle(" + xPos + ", " + yPos + "; r=" + radius + ")";
  }

  
  /**
   * Tests the methods of this class by creating a couple
   * circles and displaying them.
   */
  public static void main(String[] args) {
     Circle c = new Circle(50, 0);
     System.out.println("Drawing: " + c);
     c.draw();
     c = new Circle(-200, -100, 30, Color.blue);
     System.out.println("Drawing: " + c);
     c.draw();
  }

}
