"A Java exception has occurred"
in
Integration and Hardware
•
1 year ago
Hi, I have a problem that's driving me nuts. I'm writing a sketch involving maps with unfolding and csv. It works fine within processing, but when I export the applet and try to run the JAR, it returns a dialog saying "A Java exception has occurred". I have JRE 7, Processing 1.5.1 and Windows 7 32bit.
Thanks a lot in advance. The code (which runs perfectly) is the following:
- import processing.opengl.*;
- import codeanticode.glgraphics.*;
- import de.fhpotsdam.unfolding.mapdisplay.*;
- import de.fhpotsdam.unfolding.utils.*;
- import de.fhpotsdam.unfolding.marker.*;
- import de.fhpotsdam.unfolding.tiles.*;
- import de.fhpotsdam.unfolding.interactions.*;
- import de.fhpotsdam.unfolding.*;
- import de.fhpotsdam.unfolding.core.*;
- import de.fhpotsdam.unfolding.geo.*;
- import de.fhpotsdam.unfolding.events.*;
- import de.fhpotsdam.utils.*;
- import de.fhpotsdam.unfolding.providers.*;
- PImage mapa, tram;
- float[] mightymarblesx, mightymarblesy, rem;
- int timestart, elapsed;
- String[] stations, coordinates, copyc, code;
- boolean refresh=true;
- de.fhpotsdam.unfolding.Map map;
- public void setup() {
- size(1126, 481);
- smooth();
- mapa=loadImage("map.png");
- tram=loadImage("tram.png");
- timestart=second()+minute()*60;
- coordinates=loadStrings("http://sfmunidata.sytes.net/coordinates.csv");
- stations=loadStrings("http://sfmunidata.sytes.net/coordsofdabitch.csv");
- code=loadStrings("http://sfmunidata.sytes.net/ID.txt");
- noStroke();
- mightymarblesx=new float[coordinates.length];
- mightymarblesy=new float[coordinates.length];
- map=new de.fhpotsdam.unfolding.Map(this);
- map = new de.fhpotsdam.unfolding.Map(this, "Cloudmade Map", 0, 0, width, height, true, false,
- new OpenStreetMap.CloudmadeProvider(MapDisplayFactory.OSM_API_KEY, 1913));
- map.zoomAndPanTo(new Location(37.756f,-122.443f),12);
- MapUtils.createDefaultEventDispatcher(this,map);
- }
- public void draw() {
- //image(mapa, 0, 0);
- map.draw();
- elapsed=(second()+minute()*60)-timestart;
- if (elapsed>5) {
- println("SENDING REFRESHMENT");
- refresh=true;
- }
- updateposition();
- /* ########################################################
- TEXT AND VEHICLES:
- ######################################################## */
- for (int i=0;i<mightymarblesx.length;i++) {
- // Point coord = latlon_to_screen(new latLon(mightymarblesx[i], mightymarblesy[i]));
- Location vehloc=new Location(mightymarblesx[i],mightymarblesy[i]);
- float xy[]=map.getScreenPositionFromLocation(vehloc);
- textAlign(CENTER);
- fill(0);
- text(split(coordinates[i], ",")[0],xy[0],xy[1]);
- image(tram,xy[0],xy[1],20,20);
- }
- /* ########################################################
- MARKERS FOR THE STATIONS:
- ######################################################## */
- for (int i=0;i<stations.length;i++) {
- float lat=float(split(stations[i], ",")[0]);
- float lon=float(split(stations[i], ",")[1]);
- Location staloc=new Location(lat,lon);
- float xy[]=map.getScreenPositionFromLocation(staloc);
- // Point coord = latlon_to_screen(new latLon(lat, lon));
- fill(255, 0, 0);
- ellipse(xy[0], xy[1], 1, 1);
- }
- }
- public void updateposition() {
- if (refresh) {
- println("REFRESHING");
- try{
- if (code[0].equals(loadStrings("http://sfmunidata.sytes.net/ID.txt")[0])==false) {
- code=loadStrings("http://sfmunidata.sytes.net/ID.txt");
- try {
- coordinates=loadStrings("http://sfmunidata.sytes.net/coordinates.csv");
- timestart=second()+minute()*60;
- mightymarblesx=new float[coordinates.length];
- mightymarblesy=new float[coordinates.length];
- }
- catch (Exception e) {
- coordinates=copyc;
- }
- }
- }catch (Exception e) {}
- copyc=coordinates;
- refresh=false;
- }
- for (int i=0;i<coordinates.length;i++) {
- String[] elements= split(coordinates[i], ',');
- String[] hour= split(elements[7]," ");
- float timebefore= float(hour[0])*60+float(hour[1]);
- float timenow= minute()*60+second();
- float actual=timenow-timebefore;
- String stationcode=elements[0];
- float seconds=float(elements[1]);
- float totseconds=float(elements[2]);
- float lat=float(elements[3]);
- float lon=float(elements[4]);
- float lat2=float(elements[5]);
- float lon2=float(elements[6]);
- float cartesianlat=map(seconds-actual, totseconds, 0, lat, lat2);
- float cartesianlon=map(seconds-actual, totseconds, 0, lon, lon2);
- mightymarblesx[i]=cartesianlat;
- mightymarblesy[i]=cartesianlon;
- }
- }
1