Hi there. I was given the advice to use noloop() to keep my interactive visual from re-drawing over and over. But I have a drop-down list that not doesn't work. if I get rid of the noloop() command the drop down list works but the interactive visual doesn't work right anymore (data constantly being redrawn, and selected data only appearing for a split second). Can anyone help me? Thanks! Kevin PS - I removed some code below because it apparently was too long to post.
- import controlP5.*;
- ControlP5 cp5;
- String currentPlayerF = "";
- String currentPlayerL = "";
- String Assessment;
- int i;
- String [] lines;
- void setup() {
- size(1280, 760);
- PFont font = loadFont("DIN-Medium-48.vlw");
- textFont(font);
- lines = loadStrings("StartingPitcherDashboard2.txt");
- cp5 = new ControlP5(this);
- cp5.setControlFont(new ControlFont(createFont("DIN-Medium", 12), 12));
- DropdownList player = cp5.addDropdownList("PLAYER").setPosition(1150, 105).setSize(100, 600);
- for (int x=1; x<lines.length; x++) {
- String[] pieces = split(lines[x], '\t');
- player.addItem(pieces[1], x);
- }
- customize(player);
- smooth();
- noLoop();
- }
- void draw() {
- // background(250);
- background(30, 30, 30);
- PImage logo;
- logo = loadImage("paintomaticlogo.png");
- image(logo, 0, 3);
- textSize(14);
- fill(Rtext, Gtext, Btext);
- textAlign(LEFT);
- strokeWeight(2);
- stroke(Rtext, Gtext, Btext);
- line(20, 60, 1250, 60);
- strokeWeight(1.25);
- stroke(Rline, Gline, Bline);
- line(X0-275, Y0, X0+275, Y0);
- line(X0, YY0, X0, 700);
- stroke(Rline, Gline, Bline);
- // line(XX00, 250, XX00, 700);
- // line(XX002, 250, XX002, 700);
- // line(XX003, 250, XX003, 700);
- // line(XX004, 250, XX004, 700);
- // line(XX005, 250, XX005, 700);
- line(XX0, YY0, XX0, 700);
- line(XX1, YY0, XX1, 700);
- line(XX2, YY0, XX2, 700);
- line(XX3, YY0, XX3, 700);
- line(XX4, YY0, XX4, 700);
- line(XX5, YY0, XX5, 700);
- line(XX6, YY0, XX6, 700);
- line(XX7, YY0, XX7, 700);
- fill(Rtext, Gtext, Btext);
- textAlign(CENTER);
- smooth();
- text("VERTICAL MOVEMENT", X0, YY0-20);
- textAlign(LEFT);
- text("HORIZONTAL MOVEMENT", 30, YY0+350);
- textAlign(CENTER);
- text("Fastball", XX0, YY0-20);
- text("2-Seamer", XX1, YY0-20);
- text("Cutter", XX2, YY0-20);
- text("Splitter", XX3, YY0-20);
- text("Sinker", XX4, YY0-20);
- text("Slider", XX5, YY0-20);
- text("Curve", XX6, YY0-20);
- text("Changeup", XX7, YY0-20);
- textAlign(RIGHT);
- // text(demarc4+" MPH", XX0-40, 178+((100-demarc4)*mult));
- // text(demarc3+" MPH", XX0-40, 178+((100-demarc3)*mult));
- // text(demarc2+" MPH", XX0-40, 178+((100-demarc2)*mult));
- // text(demarc1+" MPH", XX0-40, 178+((100-demarc1)*mult));
- text("MPH", 1245, YY0-20);
- text(demarc5, 1245, YY0+((MaxVel-demarc5)*mult));
- text(demarc4, 1245, YY0+((MaxVel-demarc4)*mult));
- text(demarc3, 1245, YY0+((MaxVel-demarc3)*mult));
- text(demarc2, 1245, YY0+((MaxVel-demarc2)*mult));
- text(demarc1, 1245, YY0+((MaxVel-demarc1)*mult));
- text(demarc0, 1245, YY0+((MaxVel-demarc0)*mult));
- ///////////////////////////
- for (int i=1; i<lines.length; i++) {
-
- ///////////// CHARTS FOR ERA, K, BB, HITS, HR
- fill(Rtext, Gtext, Btext);
- // fill(0, 250);
- noStroke();
- strokeWeight(2);
- // stroke(250, 80);
- fill(Rtext, Gtext, Btext);
- noStroke();
- //////////// for all players except for selected player
- if (lastname.equals(currentPlayerL)) {
- // if (lastname.equals(SelectedLName) && (firstname.equals(SelectedFName))) {
- }
- else {
- if (FAthrown > .05) {
- if (FAS <=demarc1) {
- ValueR = Rlevel1;
- ValueG = Glevel1;
- ValueB = Blevel1;
- }
- else if (FAS > demarc1 && FAS <=demarc2) {
- ValueR = Rlevel2;
- ValueG = Glevel2;
- ValueB = Blevel2;
- }
-
- else {
- ValueR = Rlevel5;
- ValueG = Glevel5;
- ValueB = Blevel5;
- }
- strokeWeight(mult2*FTthrown);
- stroke(ValueR, ValueG, ValueB, Opac);
- line(X0, Y0, X0+FTHmov, Y0-FTVmov);
- noStroke();
- fill(ValueR, ValueG, ValueB, Opac3);
- // ellipse(X0+FTHmov, Y0-FTVmov, 50*FTthrown, 50*FTthrown);
- ellipse(XX1-(rand/2)+random(rand), FTspeed, mult2*FTthrown, mult2*FTthrown);
- }
- if (FCthrown > .05) {
- if (FCS <=demarc1) {
- ValueR = Rlevel1;
- ValueG = Glevel1;
- ValueB = Blevel1;
- }
-
- else {
- ValueR = Rlevel5;
- ValueG = Glevel5;
- ValueB = Blevel5;
- }
- strokeWeight(mult2*FCthrown);
- stroke(ValueR, ValueG, ValueB, Opac);
- line(X0, Y0, X0+FCHmov, Y0-FCVmov);
- noStroke();
- fill(ValueR, ValueG, ValueB, Opac3);
- // ellipse(X0+FCHmov, Y0-FCVmov, 50*FCthrown, 50*FCthrown);
- ellipse(XX2-(rand/2)+random(rand), FCspeed, mult2*FCthrown, mult2*FCthrown);
- }
- if (FSthrown > .05) {
- if (FSS <=demarc1) {
- ValueR = Rlevel1;
- ValueG = Glevel1;
- ValueB = Blevel1;
- }
-
- else {
- ValueR = Rlevel5;
- ValueG = Glevel5;
- ValueB = Blevel5;
- }
- strokeWeight(mult2*FSthrown);
- stroke(ValueR, ValueG, ValueB, Opac);
- line(X0, Y0, X0+FSHmov, Y0-FSVmov);
- noStroke();
- fill(ValueR, ValueG, ValueB, Opac3);
- // ellipse(X0+FSHmov, Y0-FSVmov, 50*FSthrown, 50*FSthrown);
- ellipse(XX3-(rand/2)+random(rand), FSspeed, mult2*FSthrown, mult2*FSthrown);
- }
-
- else {
- ValueR = Rlevel5;
- ValueG = Glevel5;
- ValueB = Blevel5;
- }
- strokeWeight(mult2*SIthrown);
- stroke(ValueR, ValueG, ValueB, Opac);
- line(X0, Y0, X0+SIHmov, Y0-SIVmov);
- noStroke();
- fill(ValueR, ValueG, ValueB, Opac3);
- // ellipse(X0+SIHmov, Y0-SIVmov, 50*SIthrown, 50*SIthrown);
- ellipse(XX4-(rand/2)+random(rand), SIspeed, mult2*SIthrown, mult2*SIthrown);
- }
- if (SLthrown > .05) {
- if (SLS <=demarc1) {
- ValueR = Rlevel1;
- ValueG = Glevel1;
- ValueB = Blevel1;
- }
-
- else {
- ValueR = Rlevel5;
- ValueG = Glevel5;
- ValueB = Blevel5;
- }
- strokeWeight(mult2*SLthrown);
- stroke(ValueR, ValueG, ValueB, Opac);
- line(X0, Y0, X0+SLHmov, Y0-SLVmov);
- noStroke();
- fill(ValueR, ValueG, ValueB, Opac3);
- // ellipse(X0+SLHmov, Y0-SLVmov, 50*SLthrown, 50*SLthrown);
- ellipse(XX5-(rand/2)+random(rand), SLspeed, mult2*SLthrown, mult2*SLthrown);
- }
- if (CUthrown > .05) {
- if (CUS <=demarc1) {
- ValueR = Rlevel1;
- ValueG = Glevel1;
- ValueB = Blevel1;
- }
- else if (CUS > demarc1 && CUS <=demarc2) {
- ValueR = Rlevel2;
- ValueG = Glevel2;
- ValueB = Blevel2;
- }
- else if (CUS > demarc2 && CUS <=demarc3) {
- ValueR = Rlevel3;
- ValueG = Glevel3;
- ValueB = Blevel3;
- }
- else if (CUS > demarc3 && CUS <=demarc4) {
- ValueR = Rlevel4;
- ValueG = Glevel4;
- ValueB = Blevel4;
- }
- else {
- ValueR = Rlevel5;
- ValueG = Glevel5;
- ValueB = Blevel5;
- }
- strokeWeight(mult2*CUthrown);
- stroke(ValueR, ValueG, ValueB, Opac);
- line(X0, Y0, X0+CUHmov, Y0-CUVmov);
- noStroke();
- fill(ValueR, ValueG, ValueB, Opac3);
- // ellipse(X0+CUHmov, Y0-CUVmov, 50*CUthrown, 50*CUthrown);
- ellipse(XX6-(rand/2)+random(rand), CUspeed, mult2*CUthrown, mult2*CUthrown);
- }
- if (CHthrown > .05) {
- if (CHS <=demarc1) {
- ValueR = Rlevel1;
- ValueG = Glevel1;
- ValueB = Blevel1;
- }
- else if (CHS > demarc1 && CHS <=demarc2) {
- ValueR = Rlevel2;
- ValueG = Glevel2;
- ValueB = Blevel2;
- }
- else if (CHS > demarc2 && CHS <=demarc3) {
- ValueR = Rlevel3;
- ValueG = Glevel3;
- ValueB = Blevel3;
- }
- else if (CHS > demarc3 && CHS <=demarc4) {
- ValueR = Rlevel4;
- ValueG = Glevel4;
- ValueB = Blevel4;
- }
- else {
- ValueR = Rlevel5;
- ValueG = Glevel5;
- ValueB = Blevel5;
- }
- strokeWeight(mult2*CHthrown);
- stroke(ValueR, ValueG, ValueB, Opac);
- line(X0, Y0, X0+CHHmov, Y0-CHVmov);
- noStroke();
- fill(ValueR, ValueG, ValueB, Opac3);
- // ellipse(X0+CHHmov, Y0-CHVmov, 50*CHthrown, 50*CHthrown);
- ellipse(XX7-(rand/2)+random(rand), CHspeed, mult2*CHthrown, mult2*CHthrown);
- }
- }
- }
- for (int i=1; i<lines.length; i++) {
- String[] pieces = split(lines[i], '\t');
- String wins = pieces[T+1];
- String losses = pieces[T+2];
- String firstname = pieces[FN];
- String lastname = pieces[LN];
- float IP = float (pieces[I]);
- float GS = float (pieces[G]);
- float ERA = float(pieces[E]);
- float FIP = float (pieces[F]);
- float K = float (pieces[SO]);
- float BB = float (pieces[B]);
- float TOTALHITS = float (pieces[Hits]);
- float HP9 = 9*(TOTALHITS/IP);
- float HR = float (pieces[Hr]);
- if (lastname.equals(currentPlayerL) ) {
- // if (lastname.equals(SelectedLName) && (firstname.equals(SelectedFName))) {
- String team = pieces[T];
- fill(Rtext, Gtext, Btext);
- textAlign(RIGHT);
- textSize(22);
- // SelectedFName = SelectedFName.toUpperCase();
- // SelectedLName = SelectedLName.toUpperCase();
- currentPlayerL = currentPlayerL.toUpperCase();
- text(currentPlayerL, 1250, 55);
- // text(SelectedFName+" "+SelectedLName, 1250, 55);
- textAlign(RIGHT);
- // team = team.toUpperCase();
- // text(team, 1250, 70);
- textSize(14);
- textAlign(LEFT);
- String ERAstring = nf(ERA, 1, 2);
- String FIPstring = nf(FIP, 1, 2);
-
- fill(Rtext, Gtext, Btext);
- textSize(70);
- textSize(14);
- noStroke();
- textAlign(LEFT);
- strokeWeight(1);
- // line(XX00+200, 250, XX00+200, 725);
- if (FAthrown > .05) {
- if (FAS <=demarc1) {
- ValueR = Rlevel1;
- ValueG = Glevel1;
- ValueB = Blevel1;
- }
-
- else {
- ValueR = Rlevel5;
- ValueG = Glevel5;
- ValueB = Blevel5;
- }
- strokeWeight(mult2*FAthrown);
- stroke(ValueR, ValueG, ValueB, Opac2);
- line(X0, Y0, X0+FAHmov, Y0-FAVmov);
- strokeWeight(2);
- stroke(0, 100);
- fill(ValueR, ValueG, ValueB, Opac4);
- ellipse(X0+FAHmov, Y0-FAVmov, mult2*FAthrown, mult2*FAthrown);
- ellipse(XX0, FAspeed, mult2*FAthrown, mult2*FAthrown);
- fill(Rtext, Gtext, Btext);
- textAlign(CENTER);
- text("Fastball", X0+FAHmov, Y0-FAVmov-25*FAthrown-15);
- }
- if (FTthrown > .05) {
- if (FTS <=demarc1) {
- ValueR = Rlevel1;
- ValueG = Glevel1;
- ValueB = Blevel1;
- }
-
- else {
- ValueR = Rlevel5;
- ValueG = Glevel5;
- ValueB = Blevel5;
- }
- strokeWeight(mult2*FTthrown);
- stroke(ValueR, ValueG, ValueB, Opac2);
- line(X0, Y0, X0+FTHmov, Y0-FTVmov);
- strokeWeight(2);
- stroke(0, 100);
- fill(ValueR, ValueG, ValueB, Opac4);
- ellipse(X0+FTHmov, Y0-FTVmov, mult2*FTthrown, mult2*FTthrown);
- ellipse(XX1, FTspeed, mult2*FTthrown, mult2*FTthrown);
- fill(Rtext, Gtext, Btext);
- textAlign(CENTER);
- text("2-Seamer", X0+FTHmov, Y0-FTVmov-25*FTthrown-15);
- }
- if (FCthrown > .05) {
- if (FCS <=demarc1) {
- ValueR = Rlevel1;
- ValueG = Glevel1;
- ValueB = Blevel1;
- }
-
- else {
- ValueR = Rlevel5;
- ValueG = Glevel5;
- ValueB = Blevel5;
- }
- strokeWeight(mult2*FCthrown);
- stroke(ValueR, ValueG, ValueB, Opac2);
- line(X0, Y0, X0+FCHmov, Y0-FCVmov);
- strokeWeight(2);
- stroke(0, 100);
- fill(ValueR, ValueG, ValueB, Opac4);
- ellipse(X0+FCHmov, Y0-FCVmov, mult2*FCthrown, mult2*FCthrown);
- ellipse(XX2, FCspeed, mult2*FCthrown, mult2*FCthrown);
- fill(Rtext, Gtext, Btext);
- textAlign(CENTER);
- text("Cutter", X0+FCHmov, Y0-FCVmov-25*FCthrown-10);
- }
- if (FSthrown > .05) {
- if (FSS <=demarc1) {
- ValueR = Rlevel1;
- ValueG = Glevel1;
- ValueB = Blevel1;
- }
-
- else {
- ValueR = Rlevel5;
- ValueG = Glevel5;
- ValueB = Blevel5;
- }
- strokeWeight(mult2*FSthrown);
- stroke(ValueR, ValueG, ValueB, Opac2);
- line(X0, Y0, X0+FSHmov, Y0-FSVmov);
- strokeWeight(2);
- stroke(0, 100);
- fill(ValueR, ValueG, ValueB, Opac4);
- ellipse(X0+FSHmov, Y0-FSVmov, mult2*FSthrown, mult2*FSthrown);
- ellipse(XX3, FSspeed, mult2*FSthrown, mult2*FSthrown);
- fill(Rtext, Gtext, Btext);
- textAlign(CENTER);
- text("Splitter", X0+FSHmov, Y0-FSVmov-25*FSthrown-10);
- }
- if (SIthrown > .05) {
- if (SIS <=demarc1) {
- ValueR = Rlevel1;
- ValueG = Glevel1;
- ValueB = Blevel1;
- }
-
- else {
- ValueR = Rlevel5;
- ValueG = Glevel5;
- ValueB = Blevel5;
- }
- strokeWeight(mult2*SIthrown);
- stroke(ValueR, ValueG, ValueB, Opac2);
- line(X0, Y0, X0+SIHmov, Y0-SIVmov);
- strokeWeight(2);
- stroke(0, 100);
- fill(ValueR, ValueG, ValueB, Opac4);
- ellipse(X0+SIHmov, Y0-SIVmov, mult2*SIthrown, mult2*SIthrown);
- ellipse(XX4, SIspeed, mult2*SIthrown, mult2*SIthrown);
- fill(Rtext, Gtext, Btext);
- textAlign(CENTER);
- text("Sinker", X0+SIHmov, Y0-SIVmov-25*SIthrown-10);
- }
- if (SLthrown > .05) {
- if (SLS <=demarc1) {
- ValueR = Rlevel1;
- ValueG = Glevel1;
- ValueB = Blevel1;
- }
-
- else {
- ValueR = Rlevel5;
- ValueG = Glevel5;
- ValueB = Blevel5;
- }
- strokeWeight(mult2*SLthrown);
- stroke(ValueR, ValueG, ValueB, Opac2);
- line(X0, Y0, X0+SLHmov, Y0-SLVmov);
- strokeWeight(2);
- stroke(0, 100);
- fill(ValueR, ValueG, ValueB, Opac4);
- ellipse(X0+SLHmov, Y0-SLVmov, mult2*SLthrown, mult2*SLthrown);
- ellipse(XX5, SLspeed, mult2*SLthrown, mult2*SLthrown);
- fill(Rtext, Gtext, Btext);
- textAlign(CENTER);
- text("Slider", X0+SLHmov, Y0-SLVmov-25*SLthrown-10);
- }
- if (CUthrown > .05) {
- if (CUS <=demarc1) {
- ValueR = Rlevel1;
- ValueG = Glevel1;
- ValueB = Blevel1;
- }
-
- else {
- ValueR = Rlevel5;
- ValueG = Glevel5;
- ValueB = Blevel5;
- }
- strokeWeight(mult2*CUthrown);
- stroke(ValueR, ValueG, ValueB, Opac2);
- line(X0, Y0, X0+CUHmov, Y0-CUVmov);
- strokeWeight(2);
- stroke(0, 100);
- fill(ValueR, ValueG, ValueB, Opac4);
- ellipse(X0+CUHmov, Y0-CUVmov, mult2*CUthrown, mult2*CUthrown);
- ellipse(XX6, CUspeed, mult2*CUthrown, mult2*CUthrown);
- fill(Rtext, Gtext, Btext);
- textAlign(CENTER);
- text("Curve", X0+CUHmov, Y0-CUVmov-25*CUthrown-10);
- }
- if (CHthrown > .05) {
- if (CHS <=demarc1) {
- ValueR = Rlevel1;
- ValueG = Glevel1;
- ValueB = Blevel1;
- }
-
- else {
- ValueR = Rlevel5;
- ValueG = Glevel5;
- ValueB = Blevel5;
- }
- strokeWeight(mult2*CHthrown);
- stroke(ValueR, ValueG, ValueB, Opac2);
- line(X0, Y0, X0+CHHmov, Y0-CHVmov);
- strokeWeight(2);
- stroke(0, 100);
- fill(ValueR, ValueG, ValueB, Opac4);
- ellipse(X0+CHHmov, Y0-CHVmov, mult2*CHthrown, mult2*CHthrown);
- ellipse(XX7, CHspeed, mult2*CHthrown, mult2*CHthrown);
- fill(Rtext, Gtext, Btext);
- textAlign(CENTER);
- text("Changeup", X0+CHHmov, Y0-CHVmov-25*CHthrown-10);
- }
- }
- }
- textAlign(LEFT);
- }
- void controlEvent(ControlEvent theEvent) {
- if (theEvent.isGroup()) {
- String listName = theEvent.getName();
- String itemName = theEvent.getGroup().captionLabel().getText();
- if (listName.equals("PLAYER")) {
- currentPlayerL = itemName;
- }
- }
- }
- void customize(DropdownList ddl) {
- ddl.setBackgroundColor(color(0));
- ddl.setItemHeight(30);
- ddl.setBarHeight(30);
- ddl.captionLabel().style().marginTop = 3;
- ddl.captionLabel().style().marginLeft = 3;
- ddl.valueLabel().style().marginTop = 3;
- ddl.setColorBackground(color(Rtext, Gtext, Btext));
- //ddl.setColorActive(color(255, 128));
- }
1