package automatvgi.drawing;

import java.awt.Graphics;
import java.util.List;

import automatvgi.Projection;
import automatvgi.components.StateComponent;
import automatvgi.drawing.tools.DrawShape;
import automatvgi.tools.Vector;

public class DrawState {
	private double r=1;//cm
	private double width=1.8;//pt
	
	public void drawState(StateComponent state, Graphics g, Projection j){
		int x=j.getAbs(state.getCenter());
		int y=j.getOrd(state.getCenter());
		/*
		g.setColor(state.getLineColor().getColor());
		g.fillOval(x-rl,y-rl,rl*2,rl*2);
		g.setColor(state.getFillColor().getColor());
		w= r-width/2;
		rl=(int)(w*j.getVi().norm());	
		*/
		int w=j.mmToPix(width);
		int r=j.cmToPix(getRadius());
		DrawShape.drawCircle(g,x,y,r,w,state.getLineColor().getColor(),state.getFillColor().getColor());
		List<StateComponent> jetons=state.getJetons();
		int n=jetons.size();
		switch(n){
		case 0:
			g.setColor(state.getLabelColor().getColor());
			DrawLabel.draw(state.getLabel(),x,y,g,j);
			break;
		case 1:
			StateComponent sca=jetons.get(0);
			DrawShape.drawCircle(g,x,y,r/4,w,sca.getLineColor().getColor(),sca.getLineColor().getColor());
			break;
		default:
			Vector v=new Vector(getRadius()/2,0); 
			for(StateComponent sc : jetons){
				v.rot(Math.PI*2/n);
				int xj=j.getAbs(state.getCenter().addTo(v));
				int yj=j.getOrd(state.getCenter().addTo(v));
				DrawShape.drawCircle(g,xj,yj,r/(n+2),w,sc.getLineColor().getColor(),sc.getLineColor().getColor());
				
			}
		}
	}
	
	public double getRadius(){
		return r;
	}
}
