Hi !
I'm trying to visualize a school project and now I have a SketchException but can't find it.
Please help me.
// PShape Objekte erzeugen
PShape world;
PShape[] country;
PFont font;
PFont legende;
Table locationTable;
int rowCount;
Table dataTable;
float dataMin = MAX_FLOAT;
float dataMax = MIN_FLOAT;
void setup()
{
size(1450,700);
//Vektorgraphik laden
world = loadShape("Weltkarte.svg");
// Pfade der einzelnen Länder extrahieren
country = world.getChildren();
locationTable = new Table("Table_Country.csv");
rowCount = locationTable.getRowCount();
// read data table
dataTable = new Table("random.csv");
//Find minimum and maximum values
for(int row = 0; row < rowCount; row++)
{
float value = dataTable.getFloat(row,1);
if(value > dataMax)
{
dataMax = value;
}
if(value < dataMin)
{
dataMin = value;
}
}
}
void draw()
{
background(186,194,240);
// Gibt world auf dem Bildschirm aus
shape(world,0,0,0,0);
smooth();
noStroke();
// Beschriftung auf dem Bildschirm
font = loadFont("AVGmdBU-48.vlw");
textFont(font,20);
fill(255);
text("Co2 Emission 1990-2010",15,20);
// Koordinatensystem speichern
pushMatrix();
//Zeichnen der Länder
for(int i = 0;i < country.length;i++)
{
//zeichen der Länder
shape(country[i],20,30);
}
//Koordinatensystem repositionieren
popMatrix();
legende = loadFont("AVGmdBU-48.vlw");
textFont(legende,15);
fill(255);
text("Legende \nCo2 pro Person in Tonnen \n >= \n >= \n >= \n >= \n >=",15,400);
fill(#FFAAAA);
rect(15, 430, 15, 10);
fill(#FF8080);
rect(15, 450, 15, 10);
fill(#FF5555);
rect(15,470,15,10);
fill(#FF2A2A);
rect(15,490,15,10);
fill(#D40000);
rect(15,510,15,10);
for(int row = 0; row < rowCount; row++)
{
String abbrev = dataTable.getRowName(row);
float x = locationTable.getFloat(abbrev,1);
float y = locationTable.getFloat(abbrev, 2);
drawData(x,y,abbrev);
}
}
//Map the size of the ellipse to the data value
void drawData(float x, float y,String abbrev)
{
float value = dataTable.getFloat(abbrev,1);
// Re-map the value to a number between 2 and 40
float mapped = map(value; dataMin;dataMax;2;40);
//Draw an ellipse for this item
ellipse(x,y,mapped,mapped);
}
1