Skip to content
Snippets Groups Projects
Commit dd480a20 authored by Lucas Philippe's avatar Lucas Philippe
Browse files

Debut 3eme partie du TP5, Etape 1

parent bc95bbe6
No related branches found
No related tags found
No related merge requests found
No preview for this file type
...@@ -49,6 +49,8 @@ void drawDistributionPopulationLegend(int minPopulation, int maxPopulation, floa ...@@ -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 // Dessin de l'axe et des barres de l'histogramme
float binWidth = width / numberOfDiv; float binWidth = width / numberOfDiv;
......
...@@ -13,6 +13,7 @@ int y = 2; ...@@ -13,6 +13,7 @@ int y = 2;
City cities[]; City cities[];
int legendsHeight=100; int legendsHeight=100;
int minPopulationToDisplay=10000;
void setup() { void setup() {
size(900,900); size(900,900);
...@@ -21,7 +22,15 @@ void setup() { ...@@ -21,7 +22,15 @@ void setup() {
void draw(){ void draw(){
background(255); 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 // draw a point at the coordinates of the city
cities[i].draw(); cities[i].draw();
} }
...@@ -30,7 +39,7 @@ void draw(){ ...@@ -30,7 +39,7 @@ void draw(){
// Draw the distribution of the altitude values // Draw the distribution of the altitude values
float[] altitudeValues = new float[cities.length]; 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; altitudeValues[i] = cities[i].altitude;
} }
...@@ -54,15 +63,22 @@ void readData() { ...@@ -54,15 +63,22 @@ void readData() {
parseInfo(lines[0]); // read the header line parseInfo(lines[0]); // read the header line
cities = new City[totalCount]; ArrayList<City> filteredCities = new ArrayList<City>();
for (int i = 2 ; i < totalCount ; ++i) { for (int i = 2 ; i < totalCount ; ++i) {
String[] columns = split(lines[i], TAB); String[] columns = split(lines[i], TAB);
float pointX = float (columns[x]); float pointX = float (columns[x]);
float pointY = float (columns[y]); 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() { ...@@ -95,7 +111,6 @@ void drawLegend() {
float distributionY = height - legendsHeight; float distributionY = height - legendsHeight;
float distributionWidth = width - 100; float distributionWidth = width - 100;
float distributionHeight = 50; float distributionHeight = 50;
drawAltitudeLegend(minAltitude, maxAltitude, distributionX, distributionY, distributionWidth, distributionHeight);
// get list of population values from the cities // get list of population values from the cities
float[] populationValues = new float[cities.length]; float[] populationValues = new float[cities.length];
for (int i = 0; i < cities.length - 2; i++) { for (int i = 0; i < cities.length - 2; i++) {
...@@ -104,5 +119,6 @@ void drawLegend() { ...@@ -104,5 +119,6 @@ void drawLegend() {
int numberOfDiv = 30; int numberOfDiv = 30;
// draw the population distribution // draw the population distribution
//drawAltitudeLegend(minAltitude, maxAltitude, distributionX, distributionY, distributionWidth, distributionHeight);
drawDistributionPopulationLegend(minPopulation, maxPopulation, distributionX, distributionY, distributionWidth, distributionHeight, numberOfDiv, populationValues); drawDistributionPopulationLegend(minPopulation, maxPopulation, distributionX, distributionY, distributionWidth, distributionHeight, numberOfDiv, populationValues);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment