//initialize array to import data String[] ps1; String[] ps2; String[] ps3; String[] ps4; String[] ps5; String[] ps6; String[] ps7; String[] ps8; String[] ps9; String[] ps10; String[] ps11; String[] cornar; String[] bc1; String[] bc2; String[] bc3; String[] bc4; String[] bc5; String[] bc6; String[] bc7; String[] bc8; String[] pc1; String[] pc2; String[] pc5; String[] pc8; int index = 0; //time slot int time,val=1,frate=1; //current time, interval of display, framerate float timepos; //position of timeline //variable to determine weather mouse is on the partidular button boolean mouseontime = false,mouseonframe = false, mouseonplay = false, playonoff = true; //display player on and off boolean mouseonplayer1 = false,p1onoff = true; boolean mouseonplayer2 = false,p2onoff = true; boolean mouseonplayer3 = false,p3onoff = true; boolean mouseonplayer4 = false,p4onoff = true; boolean mouseonplayer5 = false,p5onoff = true; boolean mouseonplayer6 = false,p6onoff = true; boolean mouseonplayer7 = false,p7onoff = true; boolean mouseonplayer8 = false,p8onoff = true; boolean mouseonplayer9 = false,p9onoff = true; boolean mouseonplayer10 = false,p10onoff = true; boolean mouseonplayer11 = false,p11onoff = true; //player color int p1color= 33; int p2color= 33; int p3color= 33; int p4color= 33; int p5color= 33; int p6color= 33; int p7color= 33; int p8color= 33; int p9color= 33; int p10color= 33; int p11color= 33; int playcolor=255; //define font PFont font; float x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11; float y1,y2,y3,y4,y5,y6,y7,y8,y9,y10,y11; float cx1,cy1,cx2,cy2,cx3,cy3,cx4,cy4; float bx1,bx2,bx3,bx4,bx5,bx6,bx7,bx8,by1,by2,by3,by4,by5,by6,by7,by8; int scaleval = 6, xoffset = 40, yoffset = 35; //setup function will only called once void setup() { size(700, 740); //set up fonts font = loadFont("TheSans-Plain-12.vlw"); textFont(font); //import data from .txt stroke(255); ps1 = loadStrings("pv1.txt"); ps2 = loadStrings("pv2.txt"); ps3 = loadStrings("pv3.txt"); ps4 = loadStrings("pv4.txt"); ps5 = loadStrings("pv5.txt"); ps6 = loadStrings("pv6.txt"); ps7 = loadStrings("pv7.txt"); ps8 = loadStrings("pv8.txt"); ps9 = loadStrings("pv9.txt"); ps10 = loadStrings("pv10.txt"); ps11 = loadStrings("pv11.txt"); cornar = loadStrings("cornar.txt"); // GPS corodinate of 4 corner of soccer field String[] cnr1 = split(cornar[0], '\t'); String[] cnr2 = split(cornar[1], '\t'); String[] cnr3 = split(cornar[2], '\t'); String[] cnr4 = split(cornar[3], '\t'); cx1 = float(cnr1[0])*scaleval + xoffset; cy1 = float(cnr1[1])*scaleval + yoffset; cx2 = float(cnr2[0])*scaleval + xoffset; cy2 = float(cnr2[1])*scaleval + yoffset; cx3 = float(cnr3[0])*scaleval + xoffset; cy3 = float(cnr3[1])*scaleval + yoffset; cx4 = float(cnr4[0])*scaleval + xoffset; cy4 = float(cnr4[1])*scaleval + yoffset; // fill(255); // rectMode(CORNER); // rect(cx1,cy1,cx4,cy4); // fill(56); // ellipse(cx1, cy1, 5, 5); // ellipse(cx2, cy2, 5, 5); // ellipse(cx3, cy3, 5, 5); // ellipse(cx4, cy4, 5, 5); //draw background bkground(); // frameRate(20); } //draw function will called every second (default) or at framerate void draw() { frameRate(frate); if (index >= 1800 || playonoff == false){ val=0; } bkground(); playerpos(); // Go to the next line for the next run through draw() index = index + val; timepos = (index/4); // print("index = " + index); if (playonoff == false){ fill(playcolor); text("Pause", cx4+xoffset+55, cy4+yoffset+20-50); }else{ fill(playcolor,0,0); text("Play", cx4+xoffset+55, cy4+yoffset+20-50); } } //plot player position based on the data imported void playerpos(){ strokeWeight(1); if (p1onoff == true){ if (index < ps1.length ) { String[] pieces1 = split(ps1[index], '\t'); if (pieces1.length == 2) { x1 = float(pieces1[0])*scaleval + xoffset; y1 = float(pieces1[1])*scaleval + yoffset; fill(123); ellipse(x1, y1, 15, 15); fill(255); textSize(12); text("1", x1-3, y1+4); } } } if (p2onoff == true){ if (index < ps2.length){ String[] pieces2 = split(ps2[index], '\t'); if (pieces2.length == 2) { x2 = float(pieces2[0])*scaleval + xoffset; y2 = float(pieces2[1])*scaleval + yoffset; fill(0,0,255); ellipse(x2, y2, 15, 15); fill(255); textSize(12); text("2", x2-3, y2+4); } } } if (p3onoff == true){ if (index < ps3.length){ String[] pieces3 = split(ps3[index], '\t'); if (pieces3.length == 2) { x3 = float(pieces3[0])*scaleval + xoffset; y3 = float(pieces3[1])*scaleval + yoffset; fill(255,255,0); ellipse(x3, y3, 15, 15); fill(0); textSize(12); text("13", x3-3, y3+4); } } } if (p4onoff == true){ if (index < ps4.length){ String[] pieces4 = split(ps4[index], '\t'); if (pieces4.length == 2) { x4 = float(pieces4[0])*scaleval + xoffset; y4 = float(pieces4[1])*scaleval + yoffset; fill(255,0,0); ellipse(x4, y4, 15, 15); fill(0); textSize(12); text("16", x4-3, y4+4); } } } if (p5onoff == true){ if (index < ps5.length){ String[] pieces5 = split(ps5[index], '\t'); if (pieces5.length == 2) { x5 = float(pieces5[0])*scaleval + xoffset; y5 = float(pieces5[1])*scaleval + yoffset; fill(0,0,255); ellipse(x5, y5, 15, 15); fill(255); textSize(12); text("5", x5-3, y5+4); } } } if (p6onoff == true){ if (index < ps6.length){ String[] pieces6 = split(ps6[index], '\t'); if (pieces6.length == 2) { x6 = float(pieces6[0])*scaleval + xoffset; y6 = float(pieces6[1])*scaleval + yoffset; fill(255,255,0); ellipse(x6, y6, 15, 15); fill(0); textSize(12); text("6", x6-3, y6+4); } } } if (p7onoff == true){ if (index < ps7.length){ String[] pieces7 = split(ps7[index], '\t'); if (pieces7.length == 2) { x7 = float(pieces7[0])*scaleval + xoffset; y7 = float(pieces7[1])*scaleval + yoffset; fill(255,255,0); ellipse(x7, y7, 15, 15); fill(0); textSize(12); text("17", x7-3, y7+4); } } } if (p8onoff == true){ if (index < ps8.length){ String[] pieces8 = split(ps8[index], '\t'); if (pieces8.length == 2) { x8 = float(pieces8[0])*scaleval + xoffset; y8 = float(pieces8[1])*scaleval + yoffset; fill(255,255,0); ellipse(x8, y8, 15, 15); fill(0); textSize(12); text("18", x8-3, y8+4); } } } if (p9onoff == true){ if (index < ps9.length){ String[] pieces9 = split(ps9[index], '\t'); if (pieces9.length == 2) { x9 = float(pieces9[0])*scaleval + xoffset; y9 = float(pieces9[1])*scaleval + yoffset; fill(255,0,0); ellipse(x9, y9, 15, 15); fill(0); textSize(12); text("9", x9-3, y9+4); } } } if (p10onoff == true){ if (index < ps10.length){ String[] pieces10 = split(ps10[index], '\t'); if (pieces10.length == 2) { x10 = float(pieces10[0])*scaleval + xoffset; y10 = float(pieces10[1])*scaleval + yoffset; fill(0,0,255); ellipse(x10, y10, 15, 15); fill(255); textSize(12); text("20", x10-3, y10+4); } } } if (p11onoff == true){ if (index < ps11.length){ String[] pieces11 = split(ps11[index], '\t'); if (pieces11.length == 2) { x11 = float(pieces11[0])*scaleval + xoffset; y11 = float(pieces11[1])*scaleval + yoffset; fill(0,0,255); ellipse(x11, y11, 15, 15); fill(255); textSize(12); text("11", x11-3, y11+4); } } } } //draw background void bkground() { background(130,150,150); fill(0, 102, 0); stroke(255); rectMode(CORNER); rect(0,0,cx4+xoffset,cy4+yoffset); rect(cx1,cy1,cx4-xoffset,cy4-yoffset); // fill(56); // ellipse(cx1, cy1, 5, 5); // ellipse(cx2, cy2, 5, 5); // ellipse(cx3, cy3, 5, 5); // ellipse(cx4, cy4, 5, 5); noFill(); arc(cx1, cy1, 30, 30, 0, PI/2); arc(cx3, cy3, 30, 30, PI/2, PI); arc(cx4, cy4, 30, 30, PI, TWO_PI-PI/2); arc(cx2, cy2, 30, 30, TWO_PI-PI/2, TWO_PI); line(cx1,(cy4+yoffset)/2,cx4,(cy4+yoffset)/2); ellipse((cx4+xoffset)/2,(cy4+yoffset)/2,100,100); rectMode(CENTER); rect((cx4+xoffset)/2,cy1+10,100,20); rect((cx4+xoffset)/2,cy4-10,100,20); rect((cx4+xoffset)/2,cy1+30,200,60); rect((cx4+xoffset)/2,cy4-30,200,60); basestation(); timeline(); fratechange(); playerOnOff(); } //draw basestation void basestation(){ fill(25,12,0); stroke(255); bx3 = cx1-10; by3 = (cy4+yoffset)/2; rect(bx3,by3,5,5); //b3 text("B3",cx1-30,(cy4+yoffset)/2); bx7 = cx4+10; by7 = (cy4+yoffset)/2; rect(bx7,by7,5,5); //b7 text("B7",cx4+20,(cy4+yoffset)/2); bx5 = (cx4+xoffset)/2; by5 = cy1-10; rect(bx5,by5,5,5); //b5 text("B5",(cx4+xoffset)/2-7,cy1-15); bx1 = (cx4+xoffset)/2; by1 = cy4+10; rect(bx1,by1,5,5); //b10 text("B1",(cx4+xoffset)/2-10,cy4+25); bx4 = cx1-10; by4 = ((cy4+yoffset)/2-cy1)/2+yoffset; rect(bx4,by4,5,5); //b4 text("B4",cx1-30,((cy4+yoffset)/2-cy1)/2+yoffset); bx6 = cx4+10; by6 = ((cy4+yoffset)/2-cy1)/2+yoffset; rect(bx6,by6,5,5); //b6 text("B6",cx4+20,((cy4+yoffset)/2-cy1)/2+yoffset); bx2 = cx1-10; by2 = (cy4-(cy4+yoffset)/2)/2+(cy4+yoffset)/2; rect(bx2,by2,5,5); //b2 text("B2",cx1-30,(cy4-(cy4+yoffset)/2)/2+(cy4+yoffset)/2); bx8 = cx4+10; by8 = (cy4-(cy4+yoffset)/2)/2+(cy4+yoffset)/2; rect(bx8,by8,5,5); //b8 text("B8",cx4+20,(cy4-(cy4+yoffset)/2)/2+(cy4+yoffset)/2); } //draw time line with moving cursor void timeline(){ strokeWeight(2); stroke(210); line(0, cy4+yoffset+20, cx4+xoffset, cy4+yoffset+20); strokeWeight(1); stroke(57); fill(0,150,255); rect(timepos, cy4+yoffset+20, 8,8); if (mouseontime = overRect(timepos,cy4+yoffset+20,16,16)){ fill(200,255,0); rect(timepos, cy4+yoffset+20, 8,8); if(mousePressed == true){ val=0; } } fill(0); text("Time = ",timepos, cy4+yoffset+20+20); text(index,timepos+40, cy4+yoffset+20+20); } //left click to increase framerate, right click to decreas void fratechange(){ stroke(255); fill(78); rect(cx4+xoffset+40, cy4+yoffset+20,20,20); if (mouseonframe = overRect(cx4+xoffset+40,cy4+yoffset+20,20,20)){ fill(146); rect(cx4+xoffset+40, cy4+yoffset+20,20,20); if (mousePressed && (mouseButton == LEFT)) { if (frate > 100){ }else{ frate = frate + 1; } } else if (mousePressed && (mouseButton == RIGHT)) { if (frate <2){ }else{ frate = frate - 1; } } } fill(255); text(frate,cx4+xoffset+40, cy4+yoffset+20); text("Framerate",cx4+xoffset+55, cy4+yoffset+20); fill(playcolor,0,0); rect(cx4+xoffset+40, cy4+yoffset+20-50,20,20); if (mouseonplay = overRect(cx4+xoffset+40,cy4+yoffset+20-50,20,20)){ stroke(255,255,0); rect(cx4+xoffset+40, cy4+yoffset+20-50,20,20); } } //trun on and off player display void playerOnOff(){ stroke(255); fill(p1color); rect(cx4+xoffset+40, yoffset+50*0,20,20); fill(255); text("1",cx4+xoffset+40, yoffset+50*0); text("Steve Caruana",cx4+xoffset+55, yoffset+50*0); if (mouseonplayer1 = overRect(cx4+xoffset+40,yoffset+50*0,20,20)){ stroke(255,255,0); fill(p1color); rect(cx4+xoffset+40, yoffset+50*0,20,20); fill(255); text("1",cx4+xoffset+40, yoffset+50*0); text("Steve Caruana",cx4+xoffset+55, yoffset+50*0); } stroke(255); fill(p2color); rect(cx4+xoffset+40, yoffset+50*1,20,20); fill(255); text("2",cx4+xoffset+40, yoffset+50*1); text("Joe Giarratano",cx4+xoffset+55, yoffset+50*1); if (mouseonplayer2 = overRect(cx4+xoffset+40,yoffset+50*1,20,20)){ stroke(255,255,0); fill(p2color); rect(cx4+xoffset+40, yoffset+50*1,20,20); fill(255); text("2",cx4+xoffset+40, yoffset+50*1); text("Joe Giarratano",cx4+xoffset+55, yoffset+50*1); } stroke(255); fill(p3color); rect(cx4+xoffset+40, yoffset+50*2,20,20); fill(255); text("13",cx4+xoffset+40, yoffset+50*2); text("Aldo Martelli",cx4+xoffset+55, yoffset+50*2); if (mouseonplayer3 = overRect(cx4+xoffset+40,yoffset+50*2,20,20)){ stroke(255,255,0); fill(p3color); rect(cx4+xoffset+40, yoffset+50*2,20,20); fill(255); text("13",cx4+xoffset+40, yoffset+50*2); text("Aldo Martelli",cx4+xoffset+55, yoffset+50*2); } stroke(255); fill(p4color); rect(cx4+xoffset+40, yoffset+50*3,20,20); fill(255); text("16",cx4+xoffset+40, yoffset+50*3); text("Lu",cx4+xoffset+55, yoffset+50*3); if (mouseonplayer4 = overRect(cx4+xoffset+40,yoffset+50*3,20,20)){ stroke(255,255,0); fill(p4color); rect(cx4+xoffset+40, yoffset+50*3,20,20); fill(255); text("16",cx4+xoffset+40, yoffset+50*3); text("Lu",cx4+xoffset+55, yoffset+50*3); } stroke(255); fill(p5color); rect(cx4+xoffset+40, yoffset+50*4,20,20); fill(255); text("5",cx4+xoffset+40, yoffset+50*4); text("Senad",cx4+xoffset+55, yoffset+50*4); if (mouseonplayer5 = overRect(cx4+xoffset+40,yoffset+50*4,20,20)){ stroke(255,255,0); fill(p5color); rect(cx4+xoffset+40, yoffset+50*4,20,20); fill(255); text("5",cx4+xoffset+40, yoffset+50*4); text("Senad",cx4+xoffset+55, yoffset+50*4); } stroke(255); fill(p6color); rect(cx4+xoffset+40, yoffset+50*5,20,20); fill(255); text("6",cx4+xoffset+40, yoffset+50*5); text("Daniel Cordi",cx4+xoffset+55, yoffset+50*5); if (mouseonplayer6 = overRect(cx4+xoffset+40,yoffset+50*5,20,20)){ stroke(255,255,0); fill(p6color); rect(cx4+xoffset+40, yoffset+50*5,20,20); fill(255); text("6",cx4+xoffset+40, yoffset+50*5); text("Daniel Cordi",cx4+xoffset+55, yoffset+50*5); } stroke(255); fill(p7color); rect(cx4+xoffset+40, yoffset+50*6,20,20); fill(255); text("17",cx4+xoffset+40, yoffset+50*6); text("Mechael Marchioni",cx4+xoffset+55, yoffset+50*6); if (mouseonplayer7 = overRect(cx4+xoffset+40,yoffset+50*6,20,20)){ stroke(255,255,0); fill(p7color); rect(cx4+xoffset+40, yoffset+50*6,20,20); fill(255); text("17",cx4+xoffset+40, yoffset+50*6); text("Mechael Marchioni",cx4+xoffset+55, yoffset+50*6); } stroke(255); fill(p8color); rect(cx4+xoffset+40, yoffset+50*7,20,20); fill(255); text("18",cx4+xoffset+40, yoffset+50*7); text("Aron Bosevski",cx4+xoffset+55, yoffset+50*7); if (mouseonplayer8 = overRect(cx4+xoffset+40,yoffset+50*7,20,20)){ stroke(255,255,0); fill(p8color); rect(cx4+xoffset+40, yoffset+50*7,20,20); fill(255); text("18",cx4+xoffset+40, yoffset+50*7); text("Aron Bosevski",cx4+xoffset+55, yoffset+50*7); } stroke(255); fill(p9color); rect(cx4+xoffset+40, yoffset+50*8,20,20); fill(255); text("9",cx4+xoffset+40, yoffset+50*8); text("Joe Ayub",cx4+xoffset+55, yoffset+50*8); if (mouseonplayer9 = overRect(cx4+xoffset+40,yoffset+50*8,20,20)){ stroke(255,255,0); fill(p9color); rect(cx4+xoffset+40, yoffset+50*8,20,20); fill(255); text("9",cx4+xoffset+40, yoffset+50*8); text("Joe Ayub",cx4+xoffset+55, yoffset+50*8); } stroke(255); fill(p10color); rect(cx4+xoffset+40, yoffset+50*9,20,20); fill(255); text("20",cx4+xoffset+40, yoffset+50*9); text("Paul",cx4+xoffset+55, yoffset+50*9); if (mouseonplayer10 = overRect(cx4+xoffset+40,yoffset+50*9,20,20)){ stroke(255,255,0); fill(p10color); rect(cx4+xoffset+40, yoffset+50*9,20,20); fill(255); text("20",cx4+xoffset+40, yoffset+50*9); text("Paul",cx4+xoffset+55, yoffset+50*9); } stroke(255); fill(p11color); rect(cx4+xoffset+40, yoffset+50*10,20,20); fill(255); text("11",cx4+xoffset+40, yoffset+50*10); text("Vince",cx4+xoffset+55, yoffset+50*10); if (mouseonplayer11 = overRect(cx4+xoffset+40,yoffset+50*10,20,20)){ stroke(255,255,0); fill(p11color); rect(cx4+xoffset+40, yoffset+50*10,20,20); fill(255); text("11",cx4+xoffset+40, yoffset+50*10); text("Vince",cx4+xoffset+55, yoffset+50*10); } } //resume from pause void mouseReleased() { if (mouseontime){ val=1; } } //drag across the time like to change time frame void mouseDragged(){ if (mouseontime){ // index = time; index = mouseX*4; } } //determine on and off of the player display void mousePressed() { if(mouseonplayer1) { p1color = (p1onoff == false) ? 33 : 205; p1onoff = !p1onoff; } if(mouseonplayer2) { p2color = (p2onoff == false) ? 33 : 205; p2onoff = !p2onoff; } if(mouseonplayer3) { p3color = (p3onoff == false) ? 33 : 205; p3onoff = !p3onoff; } if(mouseonplayer4) { p4color = (p4onoff == false) ? 33 : 205; p4onoff = !p4onoff; } if(mouseonplayer5) { p5color = (p5onoff == false) ? 33 : 205; p5onoff = !p5onoff; } if(mouseonplayer6) { p6color = (p6onoff == false) ? 33 : 205; p6onoff = !p6onoff; } if(mouseonplayer7) { p7color = (p7onoff == false) ? 33 : 205; p7onoff = !p7onoff; } if(mouseonplayer8) { p8color = (p8onoff == false) ? 33 : 205; p8onoff = !p8onoff; } if(mouseonplayer9) { p9color = (p9onoff == false) ? 33 : 205; p9onoff = !p9onoff; } if(mouseonplayer10) { p10color = (p10onoff == false) ? 33 : 205; p10onoff = !p10onoff; } if(mouseonplayer11) { p11color = (p11onoff == false) ? 33 : 205; p11onoff = !p11onoff; } //play and pause button if(mouseonplay) { if (playonoff == false){ playcolor = 255; val = 1; }else if (playonoff == true){ playcolor = 0; val = 0; } playonoff = !playonoff; } } //check the position of mouse is on the button or not boolean overRect(float x, float y, int width, int height) { if (mouseX >= x-width/2 && mouseX <= x+width && mouseY >= y-height/2 && mouseY <= y+height) { return true; } else { return false; } }