source: josm/trunk/src/org/openstreetmap/josm/gui/MapScaler.java@ 1728

Last change on this file since 1728 was 1722, checked in by stoecker, 15 years ago

Large rework in projection handling - now allows only switching and more specific projections
TODO:

  • allow subprojections (i.e. settings for projections)
  • setup preferences for subprojections
  • better support of the new projection depending world bounds (how to handle valid data outside of world)
  • do not allow to zoom out of the world - zoom should stop when whole world is displayed
  • fix Lambert and SwissGrid to handle new OutOfWorld style and subprojections
  • fix new UTM projection
  • handle layers with fixed projection on projection change
  • allow easier projection switching (e.g. in menu)

NOTE:
This checkin very likely will cause problems. Please report or fix them. Older plugins may have trouble. The SVN plugins
have been fixed but may have problems nevertheless. This is a BIG change, but will make JOSMs internal structure much cleaner
and reduce lots of projection related problems.

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1// License: GPL. See LICENSE file for details.
2
3package org.openstreetmap.josm.gui;
4
5import static org.openstreetmap.josm.tools.I18n.marktr;
6
7import java.awt.Color;
8import java.awt.Graphics;
9import java.awt.geom.Rectangle2D;
10
11import javax.swing.JComponent;
12
13import org.openstreetmap.josm.Main;
14import org.openstreetmap.josm.actions.HelpAction.Helpful;
15import org.openstreetmap.josm.data.coor.LatLon;
16
17public class MapScaler extends JComponent implements Helpful {
18
19 private final NavigatableComponent mv;
20 public MapScaler(NavigatableComponent mv) {
21 this.mv = mv;
22 setSize(100,30);
23 setOpaque(false);
24 }
25
26 @Override public void paint(Graphics g) {
27 double dist = mv.getDist100Pixel();
28 String text = dist >= 2000 ? Math.round(dist/100)/10 +" km" : (dist >= 1
29 ? Math.round(dist*10)/10 +" m" : "< 1 m");
30 Rectangle2D bound = g.getFontMetrics().getStringBounds(text, g);
31 g.setColor(getColor());
32 g.drawLine(0, 5, 99, 5);
33 g.drawLine(0, 0, 0, 10);
34 g.drawLine(99, 0, 99, 10);
35 g.drawLine(49, 0, 49, 10);
36 g.drawLine(24, 3, 24, 7);
37 g.drawLine(74, 3, 74, 7);
38 g.drawString(text, (int)(100-bound.getWidth()), 23);
39 g.drawString("0", 0, 23);
40 }
41
42 static public Color getColor()
43 {
44 return Main.pref.getColor(marktr("scale"), Color.white);
45 }
46
47 public String helpTopic() {
48 return "MapView/Scaler";
49 }
50}
Note: See TracBrowser for help on using the repository browser.