package chronoDivers;


import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Stroke;

import chrono.ChronoPanel;
import signals.Signals;

public class VertLines
{
	private int Xstart;
	private int Xend;
	private int startNum;
	private int endNum;
	private Signals s;
  
	public VertLines(Signals s, int Xstart, int Xend, int startNum, int endNum)
	{
		this.s = s;
		this.Xstart = Xstart;
		this.Xend = Xend;
		this.startNum = startNum;
		this.endNum = endNum;
	}
  
	public void draw(Graphics g, ChronoPanel chrono)
	{
		Graphics2D g2 = (Graphics2D)g;
		float[] dash1 = { 5.0F };
		Stroke dashed = new BasicStroke(1.0F, 0, 0, 10.0F, dash1, 0.0F);
		g2.setStroke(dashed);
		g2.setColor(new Color(150, 150, 150));
		for (int index = 0; index <= (this.Xend - this.Xstart) / this.s.widthUnit; index++)
		{
			boolean inTimeLapse = false;
			for (int i = 0; i < chrono.nbrTimeLapse; i++) 
			{
				for (int j = 0; j < 3; j++) 
				{
					if ((this.Xstart + index * this.s.widthUnit - Signals.leftSpace > chrono.timeLapse[i][0]) && (this.Xstart + index * this.s.widthUnit - Signals.leftSpace < chrono.timeLapse[i][3])) 
					{
						inTimeLapse = true;
					}
				}
			}
      
			if (!inTimeLapse) 
			{
				if ((this.s.wave[index] == 0) && (this.s.wave[(index + 1)] == 1)) 
				{
					g.drawLine(this.Xstart + index * this.s.widthUnit, (this.startNum + 1) * (Signals.Yspace + Signals.heightUnit), this.Xstart + index * this.s.widthUnit, this.endNum * (Signals.Yspace + Signals.heightUnit) + 5);
				}
			}
		}
    
		g2.setColor(Color.black);
		g2.setStroke(new BasicStroke(1.0F));
	}
}
