001 package drawableShapes;
002 import java.awt.*;
003
004 /** Represents a drawable circle
005 * Implements ShapeInt.
006 * @author Koffman & Wolfgang
007 */
008
009 public class DrawableCircle
010 extends DrawableShape {
011
012 // Constructor
013 /** Construct a DrawableCircle of the given radius,
014 position, and color.
015 @param rad The radius
016 @param poi The coordinates of the center
017 @param border The background color
018 @param inter The interior color
019 */
020 public DrawableCircle(int rad,
021 Point poi, Color border, Color inter) {
022 super(poi, border, inter, new Circle(rad));
023 }
024
025 public DrawableCircle() {
026 super( new Circle());
027 }
028
029 public DrawableShape factory() {
030 return new DrawableCircle();
031 }
032
033 // Methods
034 /** Draw the circle.
035 @param g The graphics context (screen)
036 */
037 public void drawMe(Graphics g) {
038 g.setColor(interiorColor);
039 Circle circle = (Circle) theShape;
040 g.fillOval(pos.x - circle.getRadius(),
041 pos.y - circle.getRadius(),
042 2 * circle.getRadius(), 2 * circle.getRadius());
043 g.setColor(borderColor);
044 g.drawOval(pos.x - circle.getRadius(),
045 pos.y - circle.getRadius(),
046 2 * circle.getRadius(), 2 * circle.getRadius());
047 }
048
049 public String getName() { return "Circle"; }
050
051 /** Return a string representation of the circle.
052 @return A string representation
053 */
054 public String toString() {
055 return "Drawable " + theShape + super.toString();
056 }
057 }