package model.objects;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;

public class Ball {
	private Color color;
	private int size;
	private Ellipse2D.Double bal;

	public Ball(int size, Color color, int x, int y) {
		this.color = color;
		this.size = size * 20;
		bal = new Ellipse2D.Double(x, y, this.size, this.size);
	}

	public Ball() {
		this(0, Color.black, 0, 0);
	}

	// ** Drawing and Calculating **//

	public void paint(Graphics2D g2d) {
		g2d.setColor(color);
		g2d.fill(bal);
	}

	// ** Getters and Setters **//

	public int getSize() {
		return size / 20;
	}

	public int getX() {
		return (int) bal.getX();
	}

	public int getY() {
		return (int) bal.getY();
	}

	public int getWidth() {
		return (int) bal.getWidth();
	}

	public int getHeight() {
		return (int) bal.getHeight();
	}

	public Color getColor() {
		return color;
	}

	public void setX(int x) {
		bal.setFrame(x, getY(), getWidth(), getHeight());
	}

	public void setY(int y) {
		bal.setFrame(getX(), y, getWidth(), getHeight());
	}

	public void setSize(int size) {
		bal.setFrame(getX(), getY(), size, size);
	}

	// Update info based on network data
	public void updateInfo(int x, int y, Color color, int size) {
		setX(x);
		setY(y);
		this.color = color;
		setSize(size * 20);
	}

}
