import java.awt.Color;
import java.awt.Graphics;

/**
 * This class represents a colorable dot, that is, a dot which has a color.
 *
 * @author fpereira
 *
 */
public class Dot implements Shape, Colorable {
  /**
   * The object color.
   */
  private Color color;

  /**
   * We use a radius to control the size of the dot. Notice that the dot may
   * appear a bit displaced when we draw it, because we start drawing from the
   * point that should be its center, and move right and down by 'RADIUS'
   * pixels.
   */
  public static final int RADIUS = 2;

  /**
   * The dot's X coordinate.
   */
  private int x;

  /**
   * The dot's Y coordinate.
   */
  private int y;

  /**
   * Constructor.
   * @param xp The dot's X coordinate.
   * @param yp The dot's Y coordinate.
   */
  public Dot(final int xp, final int yp) {
    this.x = xp;
    this.y = yp;
  }

  /**
   * Determines the new color of the Dot.
   * @param rp And integer between 0 and 255, specifying the amount of red in
   * color of this dot.
   * @param gp The amount of green.
   * @param bp The amount of blue.
   */
  public final void setColor(final int rp, final int gp, final int bp) {
    this.color = new Color(rp, gp, bp);
  }

  /**
   * Draws the rectangle on the screen.
   * @param c the graphics object responsible for renderizing this shape.
   */
  public final void draw(final Graphics c) {
    Color cr = c.getColor();
    c.setColor(color);
    c.fillOval(x, y, Dot.RADIUS, Dot.RADIUS);
    c.setColor(cr);
  }
}
