|
|
|
|
@ -3,7 +3,7 @@ class Scoreboard {
|
|
|
|
|
String dataSource; // nom du fichier csv
|
|
|
|
|
Table table;
|
|
|
|
|
boolean autoload = true; // chargement et rechargement automatique
|
|
|
|
|
boolean display = false;
|
|
|
|
|
boolean display = true;
|
|
|
|
|
float posX, posY, width, height; // position et dimensions de l'afficheur
|
|
|
|
|
|
|
|
|
|
Scoreboard() {
|
|
|
|
|
@ -17,10 +17,10 @@ class Scoreboard {
|
|
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
|
if (autoload) this.load();
|
|
|
|
|
this.posX = 348;
|
|
|
|
|
this.posY = 59;
|
|
|
|
|
this.width = 1239;
|
|
|
|
|
this.height = 158;
|
|
|
|
|
this.posX = 1548;
|
|
|
|
|
this.posY = 0;
|
|
|
|
|
this.width = 300;
|
|
|
|
|
this.height = 118;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// charge ou génère le tableau des scores
|
|
|
|
|
@ -131,64 +131,80 @@ class Scoreboard {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void draw() {
|
|
|
|
|
if (!this.display) return;
|
|
|
|
|
//if (!this.display) return;
|
|
|
|
|
int count = 0;
|
|
|
|
|
//int podium = 3;
|
|
|
|
|
int margin = 60;
|
|
|
|
|
float offsetX = this.posX+this.width+10;
|
|
|
|
|
float offsetX = this.posX;
|
|
|
|
|
float offsetY = this.posY;
|
|
|
|
|
float lastX = 0;
|
|
|
|
|
rectMode(CORNER);
|
|
|
|
|
|
|
|
|
|
fill(color(0, 0, 0, 100));
|
|
|
|
|
stroke(color(0, 0, 0));
|
|
|
|
|
strokeWeight(1);
|
|
|
|
|
rect(this.posX, this.posY+20, this.width, this.height);
|
|
|
|
|
|
|
|
|
|
// pour chaque score de 50 à 1
|
|
|
|
|
for (int i=50; i>0; i--) {
|
|
|
|
|
// on limite aux 5 premières équipes
|
|
|
|
|
if (count==5) break;
|
|
|
|
|
// récupération des équipes à ce score
|
|
|
|
|
Iterable<TableRow> rowsIterable = this.findEquipesByScore(i);
|
|
|
|
|
ArrayList<String> teams = new ArrayList<String>();
|
|
|
|
|
for (TableRow row : rowsIterable) { teams.add(row.getString("equipe")); }
|
|
|
|
|
|
|
|
|
|
// arrêter la boucle si on est hors du cadre d'affichage
|
|
|
|
|
if (offsetX-margin<=this.posX) break;
|
|
|
|
|
//if (offsetX-margin<=this.posX) break;
|
|
|
|
|
// passer cette itération si aucune équipe à afficher
|
|
|
|
|
if (teams.size()==0) continue;
|
|
|
|
|
|
|
|
|
|
// affichage du score
|
|
|
|
|
fill(color(0,0,0));
|
|
|
|
|
rect(offsetX-66, offsetY+20, 55, 50);
|
|
|
|
|
rect(offsetX, offsetY+20, 55, 50);
|
|
|
|
|
fill(color(240, 240, 80));
|
|
|
|
|
stroke(color(0, 0, 0));
|
|
|
|
|
strokeWeight(1);
|
|
|
|
|
textFont(quicksandFont, 40);
|
|
|
|
|
String text = str(count+1);
|
|
|
|
|
// correction de positionnement horizontal
|
|
|
|
|
float localMarginX = (i<=9)? margin-14: (i>=40)? margin+8: margin;
|
|
|
|
|
localMarginX = (teams.size()>1)? localMarginX+((teams.size()-1)*margin)/2: localMarginX;
|
|
|
|
|
//text(i, offsetX-margin, offsetY+margin);
|
|
|
|
|
// selon largeur du texte
|
|
|
|
|
//float localMarginX = (i<=9)? margin+14: (i>=40)? margin-8: margin;
|
|
|
|
|
float localMarginX = count==0? 10: 0;
|
|
|
|
|
// selon nombre d'équipes à afficher pour ce score
|
|
|
|
|
// localMarginX = (teams.size()>1)? localMarginX+((teams.size()-1)*margin)/2: localMarginX;
|
|
|
|
|
//fill(color(0, 250, 0));
|
|
|
|
|
text(i, offsetX-localMarginX, offsetY+margin);
|
|
|
|
|
text(text, offsetX+localMarginX, offsetY+margin);
|
|
|
|
|
|
|
|
|
|
localMarginX = count==0? 20: 25;
|
|
|
|
|
textFont(quicksandFont, 20);
|
|
|
|
|
text = count==0? " er": "e";
|
|
|
|
|
text(text, offsetX+localMarginX, offsetY+margin-16);
|
|
|
|
|
|
|
|
|
|
// affichage des équipes
|
|
|
|
|
for(int j=0; j<teams.size(); j++) {
|
|
|
|
|
float subLocalMarginX = (int(teams.get(j))<=9)? margin-10: (int(teams.get(j))>=40)? margin+4: margin;
|
|
|
|
|
subLocalMarginX -=4;
|
|
|
|
|
// correction de positionnement horizontal
|
|
|
|
|
// selon nombre d'équipes à afficher pour ce score
|
|
|
|
|
float subLocalMarginX = ((teams.size()-j)*margin)-margin/2;
|
|
|
|
|
//subLocalMarginX = (teams.size()>1)? localMarginX+((teams.size()-1)*margin)/2: localMarginX;
|
|
|
|
|
fill(color(240, 240, 80));
|
|
|
|
|
circle(offsetX-(margin*(j+1))+20, offsetY+(margin*2)-12, 50);
|
|
|
|
|
circle(offsetX+subLocalMarginX, offsetY+(margin*2)-12, 50);
|
|
|
|
|
fill(color(0, 0, 0));
|
|
|
|
|
textFont(quicksandFont, 32);
|
|
|
|
|
//text(teams.get(j), offsetX-(margin*(j+1)), offsetY+(margin*2));
|
|
|
|
|
//fill(color(0, 250, 0));
|
|
|
|
|
text(teams.get(j), offsetX-(subLocalMarginX*(j+1)), offsetY+(margin*2));
|
|
|
|
|
// selon largeur du texte
|
|
|
|
|
subLocalMarginX = (int(teams.get(j))<=9)? (int(teams.get(j))==1)? subLocalMarginX-6: subLocalMarginX-8: (int(teams.get(j))>=40)? subLocalMarginX-20: subLocalMarginX-15;
|
|
|
|
|
text(teams.get(j), offsetX+subLocalMarginX, offsetY+(margin*2));
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
line(offsetX-(margin*teams.size())-10, offsetY, offsetX-(margin*teams.size())-10, offsetY+this.height);
|
|
|
|
|
lastX = offsetX-(margin*teams.size())-10;
|
|
|
|
|
|
|
|
|
|
offsetX -= margin*teams.size();
|
|
|
|
|
//line(offsetX-(margin*teams.size())-10, offsetY, offsetX-(margin*teams.size())-10, offsetY+this.height);
|
|
|
|
|
lastX = offsetX+(margin*teams.size())-10;
|
|
|
|
|
|
|
|
|
|
offsetX += margin*teams.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
noFill();
|
|
|
|
|
stroke(color(0, 0, 0));
|
|
|
|
|
rect(lastX, this.posY, margin*count, this.height);
|
|
|
|
|
//rect(lastX, this.posY, margin*count, this.height);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|