[OSM-dev] Patches for OSMApplet
Marcus Bauer
marcus.bauer at gmail.com
Sun Jan 7 19:41:53 GMT 2007
Here are the patches for the OSMApplet. I'm sending them inline as I
don't know if the list allows attachments. If necessary I can resend
them.
The fix for the longer timeout:
===============================
--- Adapter.java.orig 2007-01-07 20:16:02.000000000 +0100
+++ Adapter.java 2007-01-04 15:41:05.000000000 +0100
@@ -279,10 +279,10 @@
// create a singular HttpClient object
HttpClient client = new HttpClient();
- // establish a connection within 5 seconds
- client.getHttpConnectionManager().getParams().setConnectionTimeout(5 * 1000);
- // wait up to 30 seconds for a response
- client.getHttpConnectionManager().getParams().setSoTimeout(30 * 1000);
+ // establish a connection within 15 seconds
+ client.getHttpConnectionManager().getParams().setConnectionTimeout(15 * 1000);
+ // wait up to 600 seconds for a response
+ client.getHttpConnectionManager().getParams().setSoTimeout(600 * 1000);
// use our credentials with the request
client.getState().setCredentials(AuthScope.ANY, creds);
return client;
Two patches for reading the applet-size from the params
========================================================
The patches do the following:
* get the params
* substitute some hardcoded values
Additionally for better visibility/better visual feedback I have changed
the colors of the nodes to blue when outside of a segment and grey when
part of a segment. YMMV.
--- Tile.java.orig 2007-01-07 20:16:35.000000000 +0100
+++ Tile.java 2007-01-07 20:35:10.000000000 +0100
@@ -175,8 +175,8 @@
y_y = lat_to_yahoo(lat(0));
y_x = lon_to_yahoo(lon(0));
- y_y_max = lat_to_yahoo(lat(500)) -1;
- y_x_max = lon_to_yahoo(lon(700)) + 2;
+ y_y_max = lat_to_yahoo(lat(windowHeight)) -1;
+ y_x_max = lon_to_yahoo(lon(windowWidth)) + 2;
System.out.println("OOOOOOOO=======> " + y_x + "," + y_y);
@@ -261,8 +261,8 @@
y_y = lat_to_yahoo(lat(0));
y_x = lon_to_yahoo(lon(0));
- y_y_max = lat_to_yahoo(lat(500)) -1;
- y_x_max = lon_to_yahoo(lon(700)) + 2;
+ y_y_max = lat_to_yahoo(lat(windowHeight)) -1;
+ y_x_max = lon_to_yahoo(lon(windowWidth)) + 2;
System.out.println("OOOOOOOO=======> " + y_x + "," + y_y);
This patch is a bit longer, partly due to the fact that first the params
need to be evaluated before size() can be called -> code just
reordered.
-------------------------------------------------------------------------
--- OsmApplet.java.orig 2007-01-07 20:12:56.000000000 +0100
+++ OsmApplet.java 2007-01-07 20:37:25.000000000 +0100
@@ -121,15 +121,6 @@
public class OsmApplet extends PApplet {
private String copyright = "";
- /**
- * Window standard width in pixel
- */
- private static final int WINDOW_WIDTH = 700;
- /**
- * Window standard height in pixel
- */
- private static final int WINDOW_HEIGHT = 500;
-
public Tile tiles;
private JSObject js;
@@ -139,6 +130,9 @@
*/
private int zoom = 15;
+ private int windowHeight;
+ private int windowWidth;
+
/**
* Whether the left mouse button is pressed down.
*/
@@ -261,26 +255,6 @@
public void setup() {
- size(WINDOW_WIDTH, WINDOW_HEIGHT);
- smooth();
-
- // this font should have all special characters - open
- // to suggestions for changes though
- font = loadFont("/data/LucidaSansUnicode-11.vlw");
-
- // initialise node manager and add buttons in desired order
- modeManager = new ModeManager(this);
- modeManager.addMode(moveMode);
- modeManager.addMode(nodeMode);
- modeManager.addMode(lineMode);
- modeManager.addMode(wayMode);
- modeManager.addMode(nameMode);
- modeManager.addMode(nodeMoveMode);
- modeManager.addMode(deleteMode);
- modeManager.addMode(zoominMode);
- modeManager.addMode(zoomoutMode);
-
- modeManager.draw(); // make modeManager set up things
// for centre lat/lon and scale (degrees per pixel)
float clat = 51.526447f, clon = -0.14746371f;
@@ -288,6 +262,10 @@
zoom = 15;
if (online) {
+ if (param_float_exists("windowHeight"))
+ windowHeight = parse_param_int("windowHeight");
+ if (param_float_exists("windowWidth"))
+ windowWidth = parse_param_int("windowWidth");
if (param_float_exists("clat"))
clat = parse_param_float("clat");
if (param_float_exists("clon"))
@@ -359,8 +337,35 @@
System.out.println("Got clon: " + clon);
System.out.println("Got clat: " + clat);
System.out.println("Got zoom: " + zoom);
+ System.out.println("Got windowHeight: " + windowHeight);
+ System.out.println("Got windowWidth: " + windowWidth);
+ System.out.println("--end params--");
- tiles = new Tile(this, wmsURL, clat, clon, WINDOW_WIDTH, WINDOW_HEIGHT, zoom);
+
+
+ size(windowWidth, windowHeight);
+ smooth();
+
+ // this font should have all special characters - open
+ // to suggestions for changes though
+ font = loadFont("/data/LucidaSansUnicode-11.vlw");
+
+ // initialise node manager and add buttons in desired order
+ modeManager = new ModeManager(this);
+ modeManager.addMode(moveMode);
+ modeManager.addMode(nodeMode);
+ modeManager.addMode(lineMode);
+ modeManager.addMode(wayMode);
+ modeManager.addMode(nameMode);
+ modeManager.addMode(nodeMoveMode);
+ modeManager.addMode(deleteMode);
+ modeManager.addMode(zoominMode);
+ modeManager.addMode(zoomoutMode);
+
+ modeManager.draw(); // make modeManager set up things
+
+
+ tiles = new Tile(this, wmsURL, clat, clon, windowWidth, windowHeight, zoom);
tiles.start();
System.out.println(tiles);
@@ -629,9 +634,11 @@
} else if (node == tempLine.from || node == tempLine.to) {
fill(0xff000000);
} else if (node.lines.size() > 0) {
- fill(0xffffffff);
+ fill(0xffaaaaaa);
+ } else if(node.id == 0) {
+ fill(0xbbccccff);
} else {
- fill(0xff000000);
+ fill(0xff000080);
}
drawPoint(node.coor);
}
@@ -701,14 +708,14 @@
if(osm.commandManager.size() > 0) {
pushMatrix();
- textSize(15);
+ textSize(25);
String txt = "uploading...";
- int xx = getWidth()-(int)textWidth(txt);
- int yy = getHeight()-100;
+ int xx = windowWidth - (int)textWidth(txt);
+ int yy = windowHeight - 100;
- fill(0);
+ fill(0xff0000ff);
text(txt,xx,yy);
- fill(255);
+ fill(0x80ffffff);
text(txt,xx+1,yy+1);
popMatrix();
@@ -717,14 +724,14 @@
// If we're downloading data right now, display something
// to alert the user to the fact
if(osm.getDownloadingOSMData()) {
- textSize(15);
+ textSize(25);
String txt = "fetching OSM data...";
- int xx = 75;
- int yy = getHeight() - 50;
+ int xx = 150;
+ int yy = windowHeight - 50;
- fill(0);
+ fill(0xff0000ff);
text(txt,xx,yy);
- fill(255);
+ fill(0x80ffffff);
text(txt,xx+1,yy+1);
}
@@ -732,11 +739,12 @@
// draw_scale_bar();
- image(YahooLogo, WINDOW_WIDTH - 100, 460);
+ image(YahooLogo, windowWidth - 100, windowHeight - 40);
int xx = 55;
- int yy = 495;
+ int yy = windowHeight - 5;
Character copyrightSymbol = new Character((char)169);
+ textSize(15);
String txt = copyrightSymbol + " 2006 Yahoo! Inc";
fill(255);
text(txt, xx+1,yy+1);
@@ -745,8 +753,8 @@
txt = "Imagery " + copyrightSymbol + " 2006" + copyright ;
// print(txt + "___________");
- xx = WINDOW_WIDTH - (int)textWidth(txt) + 30;
- yy = 495;
+ xx = windowWidth - (int)textWidth(txt) + 30;
+ yy = windowHeight - 5;
fill(255);
text(txt, xx +1, yy +1);
fill(0);
@@ -887,7 +895,7 @@
}
public void updatelinks() {
- js.eval("updatelinks(" + tiles.lon(WINDOW_WIDTH / 2) + "," + tiles.lat(WINDOW_HEIGHT / 2) + "," + tiles.getZoom() + ")");
+ js.eval("updatelinks(" + tiles.lon(windowWidth / 2) + "," + tiles.lat(windowHeight / 2) + "," + tiles.getZoom() + ")");
}
More information about the dev
mailing list