package gizmoball.ui.r2;

import gizmoball.game.AbstractGizmo;

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

import physics.Vect;

/**
 * A drawer for CircleGizmos.  CircleGizmos are circles with
 * radius L/2.<p>
 * 
 * @author Albert Leung
 * @version 1.0
 * 
 */
public class R2CircleDrawer implements R2GizmoDrawer {

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

	/**
	 * Draws a CircleGizmo.
	 * 
	 * @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.GREEN);
		Vect position = gizmo.getPosition();
		int posx = (int)position.x()*L_IN_PIXELS;
		int posy = (int)position.y()*L_IN_PIXELS;
		g.drawOval(posx, posy, L_IN_PIXELS, L_IN_PIXELS);
	}

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

}
