package plots;

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

public class ActiveCircle {
	public int r;
	// centre
	int c[];
	Matrix2d m;
	boolean centre = false;

	// cx, cy = centre
	public ActiveCircle(Matrix2d m, int cx, int cy, int r) {
		this.m = m;
		this.r = r;
		c = new int[2];
		c[0] = cx; c[1] = cy;
	}
	
	public ActiveCircle(Matrix2d m, int[] c, int r) {
		this.m = m;
		this.r = r;
		this.c = c;
	}

	public void setCentre(boolean b) {
		centre = b;
	}

	public int[] getCentre() {
		return(c);
	}
	
	public void setCentre(int x, int y) {
		c[0] = x; c[1] = y;
	}

	public void translate(int x, int y) {
		c[0] += x; c[1] += y;
	}

	public boolean contains(int x, int y) {
		double d = (x-c[0])*(x-c[0]) + (y-c[1])*(y-c[1]);
		return(d <= r*r);
	}

	public void draw(Graphics gfx, Color col) {
		gfx.setColor(col);
		gfx.drawOval(c[0] - (r), c[1] - (r), 2*r, 2*r);
	}

	public void fill(Graphics gfx, Color col) {
		gfx.setColor(col);
		int[] corner = {c[0]-(r), c[1]-(r)};
		gfx.fillOval(corner[0], corner[1], 2*r, 2*r);
		if (centre) {
			gfx.setColor(Color.red);
			gfx.fillOval(c[0] - 2, c[1] - 2, 4, 4);
			gfx.setColor(Color.black);
			gfx.drawOval(c[0] - 2, c[1] - 2, 4, 4);
		}
		/* gfx.setColor(Color.white);
		int R = 2*r;
		gfx.drawLine(corner[0], corner[1], corner[0]+R, corner[1]);
		gfx.drawLine(corner[0], corner[1], corner[0], corner[1]+R);
		gfx.drawLine(corner[0]+R, corner[1], corner[0]+R, corner[1]+R);
		gfx.drawLine(corner[0]+R, corner[1]+R, corner[0], corner[1]+R); */
	}
}
