import processing.core.*; 
import processing.xml.*; 

import java.applet.*; 
import java.awt.*; 
import java.awt.image.*; 
import java.awt.event.*; 
import java.io.*; 
import java.net.*; 
import java.text.*; 
import java.util.*; 
import java.util.zip.*; 
import java.util.regex.*; 

public class testCode extends PApplet {

float[] apNorthTrain = {4.52f,5.07f,5.22f,5.37f,5.52f,6.07f,6.18f,6.30f,6.42f,6.54f,7.06f,7.18f,7.30f,7.42f,7.54f,8.06f,8.18f,8.30f,8.42f,8.54f,9.09f,9.24f,9.39f,9.54f,10.09f,10.24f,10.39f,10.54f,11.09f,11.24f,11.39f,11.54f,12.09f,12.24f,12.39f,12.54f,13.09f,13.24f,13.39f,13.54f,14.09f,14.24f,14.39f,14.54f,15.09f,15.21f,15.33f,15.45f,15.57f,16.09f,16.21f,16.33f,16.45f,16.57f,17.09f,17.21f,17.33f,17.45f,17.57f,18.09f,18.21f,18.33f,18.45f,18.57f,19.09f,19.21f,19.37f,19.52f,20.07f,20.22f,20.37f,20.52f,99,99,99,99,99,99,99,99,99,99,99,99,99,99};
float[] apSouthTrain = {5.36f,5.51f,6.06f,6.21f,6.36f,6.49f,7.01f,7.13f,7.25f,7.37f,7.49f,8.01f,8.13f,8.25f,8.37f,8.49f,9.01f,9.13f,9.25f,9.37f,9.51f,10.03f,10.18f,10.33f,10.48f,11.03f,11.18f,11.33f,11.48f,12.03f,12.18f,12.33f,12.48f,13.03f,13.18f,13.33f,13.48f,14.03f,14.18f,14.33f,14.48f,15.15f,15.18f,15.33f,15.48f,16.01f,16.13f,16.25f,16.37f,16.51f,17.01f,17.13f,17.25f,17.37f,17.49f,18.01f,18.13f,18.25f,18.37f,18.49f,19.01f,19.13f,19.25f,19.37f,19.49f,20.01f,20.16f,20.29f,20.44f,20.59f,21.14f,21.29f,21.32f,99,99,99,99,99,99,99,99,99,99,99,99,99};
ArrayList ptS;
ArrayList ptN;
PFont font;
class Points{
  int ptX;
  int ptY;
  Points(int ptOne, int ptTwo){
    ptX = ptOne;
    ptY = ptTwo; 
  }
  public int getX(){
    return ptX;
  }
  public int getY(){
    return ptY;
  }
}

public void setup() 
{
  size(500, 500);  // Size should be the first statement
  stroke(255);     // Set line drawing color to white
  frameRate(30);
  noLoop();
  font = loadFont("Calibri-24.vlw");
  ptS = new ArrayList();
  ptN = new ArrayList();
}

public void draw() 
{ 
  background(0);   // Set the background to black
  stroke(255);
  line(250,0,250,500);
  textFont(font);
  text("North",430,20);
  text("South",10,20);
  stroke(255,0,0);
  int count = 0;
  int count2 = 0;
  int curr = floor(apNorthTrain[0]);
  int curr2 = floor(apSouthTrain[0]);
  int pos = 0;
  for (int i=0; i<apNorthTrain.length; i++){
    if(curr == floor(apNorthTrain[i])){// && floor(apNorthTrain[i]) != 99){
      count++;
    } else {//if (curr != floor(apNorthTrain[i]) && curr != 99){
      line(250, curr*20, 250+(count*20),curr*20);
      if(curr != 99){
        ptN.add(new Points(250+(count*20),curr*20));
      }
      curr = floor(apNorthTrain[i]);
      count = 0;  
    }  
  }
  stroke(0,0,255);
  for (int i=0; i<apSouthTrain.length; i++){
    if(curr2 == floor(apSouthTrain[i]) && floor(apSouthTrain[i]) != 99){
      count2++;
    } else if (curr2 != floor(apSouthTrain[i]) && curr2 != 99){
      line(250, curr2*20, 250-(count2*20),curr2*20);
      
      ptS.add(new Points(250-(count2*20),curr2*20));
      
      curr2 = floor(apSouthTrain[i]);
      count2 = 0;  
    }  
  }
  noFill();
  stroke(255,0,0);
  //beginShape();
  for(int i=0;i<ptN.size()-1;i++){
    Points thisPt = (Points)ptN.get(i);
    Points nextPt = (Points)ptN.get(i+1);
   //println( "X"+ i + " - " + thisPt.getX());
   //println( "Y"+ i + " - " + thisPt.getY());
    line(thisPt.getX(), thisPt.getY(), nextPt.getX(), nextPt.getY()); 
  }
  
  stroke(0,0,255);
  //beginShape();
  for(int i=0;i<ptS.size()-1;i++){
    Points thisPt = (Points)ptS.get(i);
    Points nextPt = (Points)ptS.get(i+1);
   //println( "X"+ i + " - " + thisPt.getX());
   //println( "Y"+ i + " - " + thisPt.getY());
    line(thisPt.getX(), thisPt.getY(), nextPt.getX(), nextPt.getY()); 
  }
  //endShape();
  //y = y - 1; 
  //if (y < 0) { y = height; }
  //line(0, y, width, y);  
} 



  static public void main(String args[]) {
    PApplet.main(new String[] { "--bgcolor=#F0F0F0", "testCode" });
  }
}
