import java.awt.*;

public class VarInit extends Canvas
{
	Graphics graphic;
	public int Ospeed,Wspeed,PulseTime,busy;
	String s;
	public VarInit(int Ospeed, int Wspeed, int PulseTime)
	{
		this.busy = 0;
		this.Wspeed = Wspeed;
		this.Ospeed = Ospeed;
		this.PulseTime = PulseTime;
		this.hide();
		this.repaint(0);
		this.show();
	}
	public void paint(Graphics g)
	{
		Graphics graphic = g.create();
		graphic.setColor(Color.black);
		//control.drawRect(1,1,499,98);
		//--Object Speed-----------------
		graphic.drawLine(10,2,10,100);
		graphic.drawLine(5,this.Ospeed/100,15,this.Ospeed/100);
		s = Integer.toString(this.Ospeed);
		graphic.drawString("Object Speed:",16,25);
		graphic.drawString(s + " meters / Second",16,50);
		//--Wave Speed--------------------
		graphic.drawLine(200+10,2,200+10,100);
		graphic.drawLine(5+200,this.Wspeed/100,15+200,this.Wspeed/100);
		s = Integer.toString(this.Wspeed);
		graphic.drawString("Wbject Speed:",16+200,25);
		graphic.drawString(s + " meters / Second",16+200,50);		
		//--Pulse Time----------------------
		graphic.drawLine(400+10,2,400+10,100);
		graphic.drawLine(5+400,this.PulseTime/10,15+400,this.PulseTime/10);
		s = Integer.toString(this.PulseTime);
		graphic.drawString("Pulse Time:",16+400,25);
		graphic.drawString(s + " ms",16+400,50);
		//--Start Button----------------
		graphic.drawString("Press Here To Engage",530,50);
		this.show();
	
	}
	public boolean handleEvent(Event e)
	{
		//System.out.println(e);
		if((e.target == this) & ((e.id == 506) || (e.id == 501)))
		{
			if ((e.x <=15) & (e.x >=5))
			{
				if (e.y <= 0)
					this.Ospeed = 100;
				else
					this.Ospeed = e.y * 100;
				this.hide();
				this.repaint(0);
				this.show();
				
			}
			else if ((e.x <= 600) & (e.x >= 530))
				this.busy = 1;
				
			else if ((e.x <=15 + 200) & (e.x >=5 + 200))
			{
				if (e.y <= 0)
					this.Wspeed = 100;
				else
					this.Wspeed = e.y * 100;
				if (this.Ospeed >= 1000 && this.Wspeed < 1000)
					this.Wspeed = this.Wspeed + 900;
				this.hide();
				this.repaint(0);
				this.show();
				
			}
			else if ((e.x <=15+400) & (e.x >=5+400))
			{
				if (e.y <= 0)
					this.PulseTime = 10;
				else
					this.PulseTime = e.y * 10;
				this.hide();
				this.repaint(0);
				this.show();
				
			}
			return true;
		}

		else return false;
	}

}
