From dd480a20238c15aa5db9b7651e5dbada939e94ba Mon Sep 17 00:00:00 2001
From: Lucas Philippe <lucasphilippe@MacBook-Air-de-Lucas.local>
Date: Thu, 4 Apr 2024 10:51:57 +0200
Subject: [PATCH] Debut 3eme partie du TP5, Etape 1

---
 .DS_Store                             | Bin 6148 -> 6148 bytes
 TP5/sketch_240321a/Legends.pde        |   2 ++
 TP5/sketch_240321a/sketch_240321a.pde |  28 ++++++++++++++++++++------
 3 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/.DS_Store b/.DS_Store
index 5435a7ff2b2edef631fc07ce7147d9366b17f6e0..307682f3aa99e88340e75c2f425f70c3e6cbc164 100644
GIT binary patch
delta 205
zcmZoMXfc=|#>B!ku~2NHo+2an#(>?7ix)66F>+7lVJeq3^32IkPRhwoVqjnpU|?YE
zW?*2@`ws>T44bQ%co~D48A2EW7);O<{zO*Dz`y`eWs0hbDIL42$*Y(eI801UbrcK@
x%qJT$yE2+?u3)xg+|16w&%wmPwRs}*cjn3bB90u43=B*R3=9mLBSh9P0{~0!Hnji%

delta 72
zcmZoMXfc=|#>B)qu~2NHo+2aL#(>?7jBJy6SjsoAWMN_4e3wm&abrUm^JaDqehwxk
d&dq`x-<c=#i#T#HFfcGMGBB`gju2VH3;?iZ5hnlu

diff --git a/TP5/sketch_240321a/Legends.pde b/TP5/sketch_240321a/Legends.pde
index 8c4b5fe..68fd324 100644
--- a/TP5/sketch_240321a/Legends.pde
+++ b/TP5/sketch_240321a/Legends.pde
@@ -49,6 +49,8 @@ void drawDistributionPopulationLegend(int minPopulation, int maxPopulation, floa
     }
   }
   
+  fill(220, 100, 100);
+  
   // Dessin de l'axe et des barres de l'histogramme
   float binWidth = width / numberOfDiv;
 
diff --git a/TP5/sketch_240321a/sketch_240321a.pde b/TP5/sketch_240321a/sketch_240321a.pde
index 9918691..624d11d 100644
--- a/TP5/sketch_240321a/sketch_240321a.pde
+++ b/TP5/sketch_240321a/sketch_240321a.pde
@@ -13,6 +13,7 @@ int y = 2;
 City cities[];
 
 int legendsHeight=100;
+int minPopulationToDisplay=10000;
 
 void setup() {
   size(900,900);
@@ -21,7 +22,15 @@ void setup() {
 
 void draw(){
   background(255);
-  for (int i = 0 ; i < totalCount - 2 ; ++i) {
+  
+  // Draw title
+  fill(0);
+  textSize(20);
+  textAlign(CENTER,CENTER);
+  text("Afficher les populations supérieures à " + minPopulationToDisplay, width/2, 20);
+  textSize(12);
+  
+  for (int i = 0 ; i < totalCount; ++i) {
     // draw a point at the coordinates of the city
     cities[i].draw();
   }
@@ -30,7 +39,7 @@ void draw(){
   
   // Draw the distribution of the altitude values
   float[] altitudeValues = new float[cities.length];
-  for (int i = 0; i < cities.length - 2; i++) {
+  for (int i = 0; i < totalCount; i++) {
     altitudeValues[i] = cities[i].altitude;
   }
 
@@ -54,15 +63,22 @@ void readData() {
   
   parseInfo(lines[0]); // read the header line
   
-  cities = new City[totalCount];
+  ArrayList<City> filteredCities = new ArrayList<City>();
 
   for (int i = 2 ; i < totalCount ; ++i) {
     String[] columns = split(lines[i], TAB);
       float pointX = float (columns[x]);
       float pointY = float (columns[y]);
-      cities[i-2] = new City(columns[0], columns[4], mapX(pointX), mapY(pointY), float (columns[5]), float (columns[6]), float (columns[7]));
+      // filter the cities
+      if (float (columns[5]) > minPopulationToDisplay) {
+        filteredCities.add(new City(columns[0], columns[4], mapX(pointX), mapY(pointY), float (columns[5]), float (columns[6]), float (columns[7])));
+      }
   }
-  println("City list created: " + cities.length + " cities");
+  
+  totalCount = filteredCities.size();
+  cities = filteredCities.toArray(new City[0]);
+  println("City list created: " + totalCount + " cities");
+
 
 }
 
@@ -95,7 +111,6 @@ void drawLegend() {
   float distributionY = height - legendsHeight;
   float distributionWidth = width - 100;
   float distributionHeight = 50;
-  drawAltitudeLegend(minAltitude, maxAltitude, distributionX, distributionY, distributionWidth, distributionHeight);
   // get list of population values from the cities
   float[] populationValues = new float[cities.length];
   for (int i = 0; i < cities.length - 2; i++) {
@@ -104,5 +119,6 @@ void drawLegend() {
 
   int numberOfDiv = 30;
   // draw the population distribution
+  //drawAltitudeLegend(minAltitude, maxAltitude, distributionX, distributionY, distributionWidth, distributionHeight);
   drawDistributionPopulationLegend(minPopulation, maxPopulation, distributionX, distributionY, distributionWidth, distributionHeight, numberOfDiv, populationValues);
 }
-- 
GitLab