From 6b47aa628182fc6dfa376113145d8f8b8bb047d1 Mon Sep 17 00:00:00 2001 From: "git@eclectronics.org" Date: Fri, 17 Feb 2012 13:56:30 +0000 Subject: load/save data working --- vodaviz.pde | 274 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 140 insertions(+), 134 deletions(-) (limited to 'vodaviz.pde') diff --git a/vodaviz.pde b/vodaviz.pde index f0c8d87..566276e 100644 --- a/vodaviz.pde +++ b/vodaviz.pde @@ -193,8 +193,8 @@ void setup(){ println("vodaviz v0.21"); RG.init(this); - //mode="PDF"; - if (mode=="PDF") size(832,220,PDF, "vodaviz_bg_160212.pdf"); //P3D); //832,220); //nb pdf is 800x600 + mode="PDF"; + if (mode=="PDF") size(832,220,PDF, "vodaviz_circles_170212.pdf"); //P3D); //832,220); //nb pdf is 800x600 else size(832,220); //,PDF, "testoutput.pdf"); //P3D); //832,220); //nb pdf is 800x600 // C. 33 - M. 3 - Y. 0 - K. 0 @@ -220,10 +220,10 @@ void setup(){ float bezierfract=0.25; bstroke = new bezierstroke(startsize,endsize,linewidth,mpfract,raisefract,bezierfract); - startsize=.2; - endsize=.1; - float[] transpos={0.0,0.15,0.85,1.0}; - float[] transamt={0.5,0.2,0.2,0.5}; + startsize=2; + endsize=.2; + float[] transpos={0.0,0.25,0.75,1.0}; + float[] transamt={0.5,0.05,0.05,0.5}; color col=color(0,0,0); gstroke=new gradientstroke3D(startsize,endsize,transpos,transamt,col,smap); @@ -232,7 +232,7 @@ void setup(){ Ireland=new bitmapcountry("Ireland",0,0,shp.children[0]); Ireland.analyse(18.279,746.302,109,374.293); data=new csvloader("calls.csv"); - calls=new calldata(data.data,shp); + calls=new calldata(data.data,shp,"countries5.xml",this); background(255,255,255); noFill(); @@ -255,144 +255,150 @@ int i=0; int j=0; void draw() { - noStroke(); - - float hw=getWidth()/2; - float hh=getHeight()/2; + if (calls.loaded) { // wait for 1st xmlevent + noStroke(); + + float hw=getWidth()/2; + float hh=getHeight()/2; + + if (i==0) { + //image(lightmap,0,0,getWidth(),getHeight()); + //fill(bg); + //rect(0,0,width,height); + //background(0); + + if (false) { //render lightmap in 3D + float pw=0.5/lightmap.width; + float ph=0.5/lightmap.height; + for (int j=0;j0&&e.x>0){ //point found + RPoint sp=ptrans.form(pnorm.alise(s)); + RPoint ep=ptrans.form(pnorm.alise(e)); + RPoint Sp=smap.per(sp,4); + RPoint Ep=smap.per(ep,4); + RPoint Mp=smap.per(GCircFract(sp,ep,0.8),4.1); + beginShape(); + line(Sp.x+(getWidth()/2),Sp.y+(getHeight()/2),Mp.x+(getWidth()/2),Mp.y+(getHeight()/2)); + line(Mp.x+(getWidth()/2),Mp.y+(getHeight()/2),Ep.x+(getWidth()/2),Ep.y+(getHeight()/2)); + endShape(); + } } - } + //println("plotting "+calls.countries.get(i).name+": "+calls.countries.get(i).calls+" calls"); + } + + if (true) { //draw gradient 3D lines + if (calls.countries.get(i).points.size()>0) { + for (int j=0;j0&&e.x>0){ //point found + RPoint Sp=screenMapper(pnorm.alise(s)); + RPoint Ep=screenMapper(pnorm.alise(e)); + RPoint Mp=plerp(Sp,Ep,0.75); + //beginShape(); + //line(Sp.x+(getWidth()/2),Sp.y+(getHeight()/2),Mp.x+(getWidth()/2),Mp.y+(getHeight()/2)); + //line(Mp.x+(getWidth()/2),Mp.y+(getHeight()/2),Ep.x+(getWidth()/2),Ep.y+(getHeight()/2)); + //bezier(Sp.x, Sp.y, Sp.x, Sp.y-((getHeight()-Sp.y)*.1), Ep.x, Ep.y-((getHeight()-Ep.y)*.1), Ep.x, Ep.y); + //endShape(); + bstroke.drawstroke(Sp,Ep); + } } - - } - - if (false) { //draw centre lines from countries to ireland - RPoint Sp=ptrans.form(pnorm.alise(calls.countries.get(i).getcentre())); - RPoint Ep=ptrans.form(pnorm.alise(Ireland.getcentre())); - gstroke.drawstroke(Sp,Ep,fg); - } - - if (false) { //draw great circle lines - for (int j=0;j0&&e.x>0){ //point found - RPoint sp=ptrans.form(pnorm.alise(s)); - RPoint ep=ptrans.form(pnorm.alise(e)); - RPoint Sp=smap.per(sp,4); - RPoint Ep=smap.per(ep,4); - RPoint Mp=smap.per(GCircFract(sp,ep,0.8),4.1); - beginShape(); - line(Sp.x+(getWidth()/2),Sp.y+(getHeight()/2),Mp.x+(getWidth()/2),Mp.y+(getHeight()/2)); - line(Mp.x+(getWidth()/2),Mp.y+(getHeight()/2),Ep.x+(getWidth()/2),Ep.y+(getHeight()/2)); - endShape(); + //println("plotting "+calls.countries.get(i).name+": "+calls.countries.get(i).calls+" calls"); + } + if (false) { //fill country + for (int j=0;j0&&e.x>0){ //point found - RPoint Sp=screenMapper(pnorm.alise(s)); - RPoint Ep=screenMapper(pnorm.alise(e)); - RPoint Mp=plerp(Sp,Ep,0.75); - //beginShape(); - //line(Sp.x+(getWidth()/2),Sp.y+(getHeight()/2),Mp.x+(getWidth()/2),Mp.y+(getHeight()/2)); - //line(Mp.x+(getWidth()/2),Mp.y+(getHeight()/2),Ep.x+(getWidth()/2),Ep.y+(getHeight()/2)); - //bezier(Sp.x, Sp.y, Sp.x, Sp.y-((getHeight()-Sp.y)*.1), Ep.x, Ep.y-((getHeight()-Ep.y)*.1), Ep.x, Ep.y); - //endShape(); - bstroke.drawstroke(Sp,Ep); - } - } - //println("plotting "+calls.countries.get(i).name+": "+calls.countries.get(i).calls+" calls"); - } - if (false) { //fill country - for (int j=0;j