//http://benfry.com/writing/map/map.png//http://benfry.com/writing/map/Table.pde//http://benfry.com/writing/map/random.tsv//http://benfry.com/writing/map/names.tsvPImagemapImage;TablelocationTable;TablenameTable;introwCount;TabledataTable;floatdataMin=-10;floatdataMax=10;Integrator[]interpolators;voidsetup(){size(640,400);mapImage=loadImage("map.png");locationTable=newTable("locations.tsv");rowCount=locationTable.getRowCount();dataTable=newTable("random.tsv");nameTable=newTable("names.tsv");//fontPFontfont=loadFont("LucidaGrande-12.vlw");textFont(font);interpolators=newIntegrator[rowCount];for(introw=0;row<rowCount;row++){floatinitialValue=dataTable.getFloat(row,1);interpolators[row]=newIntegrator(initialValue);}smooth();noStroke();frameRate(10);}floatclosestDist;StringclosestText;floatclosestTextX;floatclosestTextY;voiddraw(){background(255);image(mapImage,0,0);fill(192,0,0);closestDist=MAX_FLOAT;for(introw=0;row<rowCount;row++){interpolators[row].update();}for(introw=0;row<rowCount;row++){Stringabbrev=dataTable.getRowName(row);floatx=locationTable.getFloat(row,1);//column1floaty=locationTable.getFloat(row,2);//column2drawData(x,y,abbrev);}if(closestDist!=MAX_FLOAT){fill(0);textAlign(CENTER);text(closestText,closestTextX,closestTextY);}}voiddrawData(floatx,floaty,Stringabbrev){introw=dataTable.getRowIndex(abbrev);// Get the current value.floatvalue=interpolators[row].value;floatradius=0;if(value>=0){radius=map(value,0,dataMax,1.5,15);fill(#4422CC);}else{radius=map(value,0,dataMin,1.5,15);fill(#FF4422);}ellipseMode(RADIUS);ellipse(x,y,radius,radius);floatd=dist(x,y,mouseX,mouseY);if((d<radius+2)&&(d<closestDist)){closestDist=d;Stringname=nameTable.getString(abbrev,1);// Use target (not current) value for showing the data pointStringval=nfp(interpolators[row].target,0,2);closestText=name+" "+val;closestTextX=x;closestTextY=y-radius-4;}}voidkeyPressed(){if(key==' '){updateTable();}}voidupdateTable(){for(introw=0;row<rowCount;row++){floatnewValue=random(-10,10);interpolators[row].target(newValue);}}