void setup()
{

  size(1924, 768); // size of image
  //colorMode(RGB,360,100,100); // mode
  //colorMode(RGB,360,200,100); // mode
  

  //colorMode(RGB, 255, 255, 255, 255);
  //noStroke();
  //fill(nColor3, 0, 0, nAlpha);
  //background(10); // color: 
  //frameRate(60); // FPS, not used here
  smooth(); // evens out the edges in fonts so that it blends with background

  gFont1 = createFont("Arial", 12, true); // true is to set for smoothness, x-axis
  gFont2 = createFont("Helvetica", 18, true);
  gFont3 = createFont("Arial", 15, true);

  // for files:
  // for year: 2008-2008 => idx: 0-0
  // for day: 1-31 => 0-30
  // better implementation
  gDataMatrices = new int[gFilenames.length][1][36];  // no need to initialization, 3-D array, gFilenames.length = 10 (form GlobalVar),10 files, 700-790, org 10x1x31, new = 
  
  //println("gflen " + gFilenames.length); // 10

  // get data
  for (int i=0; i<gFilenames.length; i++ ) { // no. of cols, from 0-9

    // try to read local file
    println("reading "+gFilenames[i]+"..."); // there are 10 text files from 700-709.txt, every file will have 3 cols
    
    String filestr = String.format("../query/%s.txt",gFilenames[i]);
    String [] textData = loadStrings(filestr); // loads all the strings line by line in the file
    //println("len of test_data="+ textData.length); // len = 37 (1st line + 36 values
   
    for ( int j=1; j<textData.length; j++ ) {  // ignore first line, no. of rows, j=1-36
      String textSplitted[] = split(textData[j], ","); // splits the ','

      int y = (int)Integer.parseInt(textSplitted[0]); // year
      int m = (int)Integer.parseInt(textSplitted[1]); // month
      int val = (int)Integer.parseInt(textSplitted[2]); // value (count)
      
      //println("val "+textData[j]);
      //println("mon " + m);
      
      gDataMatrices[i][0][j-1] = val; // i- length of gfiles, y-2208: since year is 2008, m-1: since month is 1, gDM[0][0][0] = val0, gDM[1][0][0]=val1, gDM[2][0][0] = val3 and so on 
    }
  }
  //println("len full "+ gDataMatrices.length); // len = 10
 
  //println("len ij "+ gDataMatrices[i][j].length);
  //println("len fijk "+ gDataMatrices[i][j][k].length)   
  // find max value of the entire 3d matrix (for noamalization)
  for ( int i=0; i<gDataMatrices.length; i++ ) { // i=0-9
    //println("len i "+ gDataMatrices[i].length); // len of gDM[i] = 3 
    for ( int j=0; j<gDataMatrices[i].length; j++ ) { //j=0 only
      int maxval = max(gDataMatrices[i][j]); //gDM[i][j] is a vector, finds the max value of the vector
      //println("max of gDM[i][j] = "+ maxval); //+ gDataMatrices[i][j]); 
      if ( gMaxValue < maxval ) {   // gMaxVal is initialized to 0 in globalVAr
        gMaxValue = maxval; // finally gMaxVal will be the maximum of all
      }
    }
  }
 //println("gMaxVal = "+ gMaxValue); //ans =561 for naruto
 
}

