package primitives.spaces;
//import primitvies.geomtry.*;
import primitives.machines.NarmsMachineProof;
import java.awt.*;
public class MultipleCircles extends CircleSpace{
	protected NarmsMachineProof rMachine ;
	private Dimension realD;
	private int shape;
//	private Polygon polygon;
	public MultipleCircles(Dimension d,int shape,int arms){
		super(new Dimension(d.width/2,(int)(d.height/Math.pow(2,arms-4))),0,Math.PI*2);
		realD = d;
		this.shape = shape;
	
 
	}
	public void finalize() throws Throwable{
		rMachine = null;
		realD = null;
		super.finalize();
//		polygon = null;
	}
	public void update(Graphics g){
		if(rMachine!=null){
		super.update(g);
		g.copyArea(0,0,d.width,d.height,realD.width/2,0);
		for(int i=1;i<(int)Math.pow(2,rMachine.arms-4);i++){
			g.copyArea(0,0,d.width,d.height,0,i*realD.height/(int)Math.pow(2,rMachine.arms-4));
			g.copyArea(0,0,d.width,d.height,realD.width/2,i*realD.height/(int)Math.pow(2,rMachine.arms-4));
		}
		}
	}
	public void setMachine(NarmsMachineProof machine){
			this.rMachine = machine;
			super.setMachine(machine);
		dalpha = setChangeRate();
	}
	public void changeState(){
		super.changeState();
		int offset = 0;
		for(int i=3;i<rMachine.arms-1;i++)
			offset = offset+(1-rMachine.bendStates[i])*(int)Math.pow(2,i-3)/2;
		state.translate(realD.width*(1-rMachine.bendStates[2])/4,
			offset*realD.height/(int)Math.pow(2,rMachine.arms-4));
	}
}
		