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

Ajout etape 2

parent dd480a20
No related branches found
No related tags found
No related merge requests found
...@@ -14,10 +14,13 @@ City cities[]; ...@@ -14,10 +14,13 @@ City cities[];
int legendsHeight=100; int legendsHeight=100;
int minPopulationToDisplay=10000; int minPopulationToDisplay=10000;
boolean redrawInProgress=false;
void setup() { void setup() {
size(900,900); size(900,900);
colorMode(HSB, 360, 100, 100);
readData(); readData();
noLoop();
} }
void draw(){ void draw(){
...@@ -46,11 +49,11 @@ void draw(){ ...@@ -46,11 +49,11 @@ void draw(){
if (legendsHeight > 0) { if (legendsHeight > 0) {
drawLegend(); drawLegend();
} }
redrawInProgress=false;
} }
void readData() { void readData() {
redrawInProgress=true;
String[] lines = loadStrings("./villes.tsv"); String[] lines = loadStrings("./villes.tsv");
// check that the file has been loaded // check that the file has been loaded
...@@ -99,11 +102,11 @@ void parseInfo(String line) { ...@@ -99,11 +102,11 @@ void parseInfo(String line) {
} }
float mapX(float x) { float mapX(float x) {
return map(x, minX, maxX, 0, 800); return map(x, minX, maxX, 50, 800);
} }
float mapY(float y) { float mapY(float y) {
return map(y, maxY, minY, 0, 800); return map(y, maxY, minY, 50, 800);
} }
void drawLegend() { void drawLegend() {
...@@ -122,3 +125,21 @@ void drawLegend() { ...@@ -122,3 +125,21 @@ void drawLegend() {
//drawAltitudeLegend(minAltitude, maxAltitude, distributionX, distributionY, distributionWidth, distributionHeight); //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);
} }
void keyPressed() {
if(redrawInProgress) {
return;
}
int gap=2;
if (key == '+') {
if (minPopulationToDisplay == 0) {
minPopulationToDisplay = 1;
}
minPopulationToDisplay = minPopulationToDisplay * gap;
readData();
} else if (key == '-') {
minPopulationToDisplay = minPopulationToDisplay / gap;
readData();
}
redraw();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment