package gizmoball.ui.r2;

import gizmoball.game.AbstractGizmo;

import java.awt.Color;
import java.awt.Graphics2D;

import physics.Vect;

/**
 * A drawer for BallGizmos.  BallGizmos are circles with approximate
 * radius L/4 and center specified by its position.
 * 
 * @author Albert Leung
 * @version 1.0
 * 
 */

public class R2BallDrawer implements R2GizmoDrawer {

	/**
	 * The singleton R2BallDrawer returned by the R2DrawerFactory.
	 * 
	 */
	public static final R2BallDrawer DRAWER = new R2BallDrawer();

	/**
	 * Draws a BallGizmo.
	 * 
	 * @param g the Graphics context on which to draw
	 * @param gizmo the gizmo from which to extract properties for
	 * representation
	 * @modifies g
	 * 
	 */
	public void drawGizmo(Graphics2D g, AbstractGizmo gizmo) {
		g.setColor(Color.CYAN);
		Vect position = gizmo.getPosition();
		int posx = (int)(position.x()*L_IN_PIXELS - L_IN_PIXELS/4);
		int posy = (int)(position.y()*L_IN_PIXELS - L_IN_PIXELS/4);
		g.fillOval(posx, posy, L_IN_PIXELS/2, L_IN_PIXELS/2);
	}

	/**
	 * Returns the singleton instance.
	 * 
	 * @return the only instance of an R2BallDrawer
	 * 
	 */
	public static R2GizmoDrawer getInstance() {
		return DRAWER;
	}

}
