001    package drawableShapes;
002    import java.awt.*;
003    
004    /** Represents a drawable rectangle.
005    *   Implements ShapeInt.
006    *   @author Koffman & Wolfgang
007    */
008    
009    public class DrawableRectangle
010        extends DrawableShape {
011    
012      // Constructor
013      /** Construct a rectangle of the given size, position, and color.
014          @param wid The width
015          @param hei The height
016          @param poi The coordinates of the upper left corner
017          @param border The border color
018          @param inter The interior color
019       */
020      public DrawableRectangle(int wid, int hei,
021                               Point poi, Color border, Color inter) {
022        super(poi, border, inter, new Rectangle(wid, hei));
023      }
024    
025      DrawableRectangle() {
026          super( new Rectangle());
027      }
028      
029      public DrawableShape factory() { 
030          return new DrawableRectangle();
031      }
032    
033      /** Draw the rectangle.
034          @param g The graphics context (screen)
035       */
036      public void drawMe(Graphics g) {
037        g.setColor(interiorColor);
038        Rectangle rectangle = (Rectangle) theShape;
039        g.fillRect(pos.x, pos.y,
040                   rectangle.getWidth(), rectangle.getHeight());
041        g.setColor(borderColor);
042        g.drawRect(pos.x, pos.y,
043                   rectangle.getWidth(), rectangle.getHeight());
044      }
045    
046      public String toString() {
047        return "Drawable " + theShape + super.toString();
048      }
049    }