import java.awt.*;
//import java.awt.image.*;
//----------------------------------------------------------------------
//public class Wave draws waves on screen
//----------------------------------------------------------------------
public class DopplerWave extends Canvas 
{
//	Image im;
	Graphics wave;
//	int pixelmap[]= new int[1000*200];
	int x,y,black,red,blue,green;
	int scan = 1000;
	public int time,offtime,offset,currentWave,position,WaveSpeed,scale,MpC;
	public int waves[][] = new int[12][2];
//	public void init()
//	{	
		
		//wave = im.getGraphics();
	//	this.im = im.clone();
	//	this.wave = wave.clone();
	//	wave.drawLine(0,50,250,50);	
	//	System.out.println("DopplerWave Init Complete");
//	}
	public DopplerWave(int position, int time,int offset, int[][] waves, int WaveSpeed,int scale, int MpC)
	{
		this.position = position;
		this.scale = scale;
		this.offset = offset;
		this.time = time;
		this.waves = waves;
		this.WaveSpeed = WaveSpeed;
		this.MpC = MpC;
		//this.black = Color.black.getRGB();
		//this.blue = Color.blue.getRGB();
		//this.red = Color.red.getRGB();
		//this.green = Color.green.getRGB();
		//for (x=0;x<1000;x++)
		//pixelmap[1000*100+x]= this.black;
		//this.repaint();
		
	}
	public void paint(Graphics g)
	{	
		//Image WaveI;
		//Graphics wave;
		//WaveI = createImage(size().width,size().height);
		wave = g.create();
		//Image waveI = g.createImage(1000,200);
//--------------------------------------------------------------------------------
//start drawing procedure


/*		for(x=0;x < pixelmap.length;x++)
		{
			if (x % 10000 == 0)
			pixelmap[x]= Color.black.getRGB();
			else
			pixelmap[x]= Color.green.getRGB();
		} */

		
		//Graphics wave;
		//addNotify();
		


//--------------------------------------------------------------------------------		
		
//		pixelmap[1000*100+100+position] = green;
//		pixelmap[1000*99+100+position] = green;
//		pixelmap[1000*101+100+position] = green;
//		pixelmap[1000*100+100+position+1] = green;
//		pixelmap[1000*100+100+position-1] = green;
		wave.drawLine(0,offset/2,1000,offset/2);		
		for (currentWave=1;currentWave <= waves[0][0];currentWave++)
		{	
//offtime = how many cycles have passed sice start of wave
			offtime = time - waves[currentWave][0];
			wave.setColor(Color.green);
			wave.fillOval(100+position,offset/2-2,4,4);
			wave.setColor(Color.red);
			wave.fillOval(100+waves[currentWave][1]-2,offset/2-2,4,4);
//			pixelmap[1000*100+100+waves[currentWave][1]] = red; 
//			pixelmap[1000*99+100+waves[currentWave][1]] = red; 
//			pixelmap[1000*101+100+waves[currentWave][1]] = red; 
//			pixelmap[1000*100+100-1+waves[currentWave][1]] = red; 
//			pixelmap[1000*100+100+1+waves[currentWave][1]] = red; 
			wave.setColor(Color.blue);
			wave.drawOval(100+(waves[currentWave][1]-offtime * (WaveSpeed / MpC)),(offset/2-offtime * (WaveSpeed/MpC)),offtime*2*(WaveSpeed / MpC),offtime*2*(WaveSpeed/MpC));
		}
		//this.show();
		//repaint(100);
//		this.im = createImage(new MemoryImageSource(1000,200,pixelmap,0,1000));
//		g.drawImage(im,0,0,this);
		this.wave = wave;
	}
	
}
