Changeset 588 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2008-03-28T00:04:41+01:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapScaler.java
r298 r588 9 9 import org.openstreetmap.josm.Main; 10 10 import org.openstreetmap.josm.actions.HelpAction.Helpful; 11 import org.openstreetmap.josm.data.coor.LatLon; 11 12 import org.openstreetmap.josm.data.projection.Projection; 12 13 import org.openstreetmap.josm.tools.ColorHelper; … … 25 26 26 27 @Override public void paint(Graphics g) { 27 double circum = mv.getScale()*100*proj.scaleFactor()*40041455; // circumference of the earth in meter 28 String text = circum > 1000 ? (Math.round(circum/100)/10.0)+"km" : Math.round(circum)+"m"; 28 LatLon ll1 = mv.getLatLon(0,0); 29 LatLon ll2 = mv.getLatLon(100,0); 30 int dist = ll1.distance(ll2); 31 String text = dist > 1000 ? (Math.round(dist/100)/10.0)+"km" : dist+"m"; 32 Rectangle2D bound = g.getFontMetrics().getStringBounds(text, g); 29 33 g.setColor(ColorHelper.html2color(Main.pref.get("color.scale", "#ffffff"))); 30 34 g.drawLine(0, 5, 99, 5); 31 35 g.drawLine(0, 0, 0, 10); 32 36 g.drawLine(99, 0, 99, 10); 33 Rectangle2D bound = g.getFontMetrics().getStringBounds(text, g); 37 g.drawLine(49, 0, 49, 10); 38 g.drawLine(24, 3, 24, 7); 39 g.drawLine(74, 3, 74, 7); 34 40 g.drawString(text, (int)(50-bound.getWidth()/2), 23); 35 41 }
Note:
See TracChangeset
for help on using the changeset viewer.