[OSM-dev] [RFC] Scale bar
Jan-Benedict Glaw
jbglaw at lug-owl.de
Fri May 12 21:19:50 BST 2006
Hi!
I'm quite new to OSM, signed up just some days ago. I'm /not/ a Java
hacker (but I'm quite used to C) and thus I tried to address a problem
I faces with the online editing applet: the missing scale bar
disturbed me a lot. That's also a bug in the trac'ker.
Not being really familiar with the Java stuff, I implemented a
statically sized status bar and a text that points out the bar's
length in meters. (-> So this is basically always a floating value and
not something "nice.")
Index: src/org/openstreetmap/processing/OsmApplet.java
===================================================================
--- src/org/openstreetmap/processing/OsmApplet.java (revision 1015)
+++ src/org/openstreetmap/processing/OsmApplet.java (working copy)
@@ -384,6 +385,31 @@
return Integer.parseInt(param(paramName));
}
+ private void draw_scale_bar() {
+ int dist_bottom = 70;
+ int dist_right = 20;
+ int bar_length = getWidth() / 5;
+ int ending_bar_length = getHeight() / 30;
+
+ pushMatrix();
+ /* Horizonthal bar */
+ line(getWidth() - bar_length - dist_right, getHeight() - dist_bottom,
+ getWidth() - dist_right, getHeight() - dist_bottom);
+ /* Left ending bar */
+ line(getWidth() - bar_length - dist_right, getHeight() - dist_bottom + ending_bar_length / 2,
+ getWidth() - bar_length - dist_right, getHeight() - dist_bottom - ending_bar_length / 2);
+ /* Right ending bar */
+ line(getWidth() - dist_right, getHeight() - dist_bottom + ending_bar_length / 2,
+ getWidth() - dist_right, getHeight() - dist_bottom - ending_bar_length / 2);
+
+ String meters = String.format ("%10.5f m", tiles.kilometersPerPixel()
+ * bar_length * 1000.0f);
+ translate(getWidth() - dist_right - bar_length + (bar_length - textWidth(meters))/2,
+ getHeight() - dist_bottom + 5);
+ text(meters);
+ popMatrix();
+ }
+
public void draw() {
tiles.draw();
try {
@@ -604,6 +630,9 @@
text("uploading...");
popMatrix();
}
+
+ // finally draw a scale bar
+ draw_scale_bar();
} catch (NullPointerException npe) {
npe.printStackTrace();
}
Comments?
MfG, JBG
--
Jan-Benedict Glaw jbglaw at lug-owl.de . +49-172-7608481 _ O _
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg _ _ O
für einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20060512/1ca22207/attachment.pgp>
More information about the dev
mailing list