//BT IRELAND MTM,Destination CID Name,VIA,Calls,MINS,ALOC,% User,ASR,NER 02 boolean DEBUG=true; import proxml.*; //java.io.NotSerializableException: geomerative.RShape // ATTEMPT TO SERIALISE COUNTRY DATA.. unfinished // // use proxml manually // class country{ String name; float calls,mins; transient RShape outline; country() { super(); } country(String n,float c,float m,RShape shp){ name=n; calls=c; mins=m; outline=shp; } void addnetwork(float c,float m) { calls+=c; mins+=m; } void printOut() { println(name+" "+calls+" "+mins); } RPoint getpoint(int tries){ RPoint tl=outline.getTopLeft(); RPoint br=outline.getBottomRight(); RPoint np= new RPoint(0,0); int searching =1; while (searching>0&&searching0)); if (searching==10||searching==100||searching==1000||searching==10000||searching==100000) { println(name+"; try "+searching+": MISS at "+np.x+","+np.y+" bounds: "+tl.x+","+tl.y+" - "+br.x+","+br.y); } } if (searching==0) return np; else return new RPoint(0,0); } RPoint getcentre() { RPoint tl=outline.getTopLeft(); RPoint br=outline.getBottomRight(); return new RPoint((tl.x+br.x)/2,(tl.y+br.y)/2); } } class weightedpixel { float bright; RPoint pt; float index; //index weighted from 0-1 weightedpixel(RPoint _p,float _b) { pt=_p; bright=_b; } } class bitmapcountry extends country { //examines a bitmap //builds a table of population desnsity //look at it from the POV of how its gonna be used //getpoints(int num) should be able to return an array of points to draw from //should be dithered //has to distribute the points around the brightest points first //distribute in proportion to their brightness - weighted //table of pixels: if within shape: //sample brightness, keep running total and store normalised weighted index for quick searching float xo,xs,yo,ys; Vector points = new Vector(); bitmapcountry(){super();} bitmapcountry(String n,float c,float m,RShape shp) { super(n,c,m,shp); } void analyse(float _xo,float _xs,float _yo,float _ys) { int step=10; //speedup xo=_xo; xs=_xs; yo=_yo; ys=_ys; //scan country outline by pixel RPoint tl=outline.getTopLeft(); RPoint br=outline.getBottomRight(); RPoint tlp=normpix(tl); RPoint brp=normpix(br); float pixstep=xs/lightmap.width; float totalbright=0; float bmin=255; float bmax=0; println("searching "+tl.x+","+tl.y+" -> "+(tl.x+(pixstep*(brp.x-tlp.x)))+","+(tl.y+(pixstep*(brp.y-tlp.y)))); for (int i=0;ibmax) bmax=bn; if (bn countries = new Vector(); HashMap outlines = new HashMap(); proxml.XMLElement xmlcountries; XMLInOut xmlInOut; PApplet pApplet; boolean loaded; country getcountry(int w) { return countries.get(w); } void loadxml(proxml.XMLElement element) { xmlcountries = element; //reconstruct countries from xml data including attaching shapes proxml.XMLElement country; proxml.XMLElement pt; int pts=0; for(int i = 0; i < xmlcountries.countChildren();i++){ country = xmlcountries.getChild(i); String name=country.getAttribute("name"); if (outlines.containsKey(name.substring(0, 3))) { bitmapcountry c=new bitmapcountry(name,(int)country.getFloatAttribute("calls"),(int)country.getFloatAttribute("mins"),shp.children[outlines.get(name.substring(0, 3))]); for(int j = 0; j < country.countChildren();j++){ pt = country.getChild(j); weightedpixel p=new weightedpixel(new RPoint(pt.getFloatAttribute("x"),pt.getFloatAttribute("y")),pt.getFloatAttribute("b")); p.index=pt.getFloatAttribute("i"); c.points.add(p); } pts+=country.countChildren(); countries.add(c); } } println("loaded "+countries.size()+" countries, "+pts+" data points"); loaded=true; } calldata(String[][] data,RShape shp,String filename,PApplet _pApplet) { boolean parsedata=true; pApplet=_pApplet; loaded=false; /* try { //to deserialise File file = new File("countries.dat"); ObjectInputStream in = new ObjectInputStream(new FileInputStream(file)); Vector countries = (Vector) in.readObject(); in.close(); parsedata=false; } catch (ClassNotFoundException e) { println("problem parsing countries.dat"); e.printStackTrace(); } catch (IOException e) { println("problem loading countries.dat"); } if (parsedata) { */ for (int i=0;i