Changeset 588 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2008-03-28T00:04:41+01:00 (16 years ago)
Author:
framm
Message:
  • scale label fixed (now works for all projections), and subdivisions added. Closes #238.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MapScaler.java

    r298 r588  
    99import org.openstreetmap.josm.Main;
    1010import org.openstreetmap.josm.actions.HelpAction.Helpful;
     11import org.openstreetmap.josm.data.coor.LatLon;
    1112import org.openstreetmap.josm.data.projection.Projection;
    1213import org.openstreetmap.josm.tools.ColorHelper;
     
    2526
    2627        @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);
    2933                g.setColor(ColorHelper.html2color(Main.pref.get("color.scale", "#ffffff")));
    3034                g.drawLine(0, 5, 99, 5);
    3135                g.drawLine(0, 0, 0, 10);
    3236                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);
    3440                g.drawString(text, (int)(50-bound.getWidth()/2), 23);
    3541    }
Note: See TracChangeset for help on using the changeset viewer.