1 | // License: GPL. See LICENSE file for details.
|
---|
2 |
|
---|
3 | package org.openstreetmap.josm.gui;
|
---|
4 |
|
---|
5 | import static org.openstreetmap.josm.tools.I18n.marktr;
|
---|
6 |
|
---|
7 | import java.awt.Color;
|
---|
8 | import java.awt.Graphics;
|
---|
9 | import java.awt.geom.Rectangle2D;
|
---|
10 |
|
---|
11 | import javax.swing.JComponent;
|
---|
12 |
|
---|
13 | import org.openstreetmap.josm.Main;
|
---|
14 | import org.openstreetmap.josm.gui.help.Helpful;
|
---|
15 |
|
---|
16 | public class MapScaler extends JComponent implements Helpful {
|
---|
17 |
|
---|
18 | private final NavigatableComponent mv;
|
---|
19 | public MapScaler(NavigatableComponent mv) {
|
---|
20 | this.mv = mv;
|
---|
21 | setSize(100,30);
|
---|
22 | setOpaque(false);
|
---|
23 | }
|
---|
24 |
|
---|
25 | @Override public void paint(Graphics g) {
|
---|
26 | String text = mv.getDist100PixelText();
|
---|
27 | Rectangle2D bound = g.getFontMetrics().getStringBounds(text, g);
|
---|
28 | g.setColor(getColor());
|
---|
29 | g.drawLine(0, 5, 99, 5);
|
---|
30 | g.drawLine(0, 0, 0, 10);
|
---|
31 | g.drawLine(99, 0, 99, 10);
|
---|
32 | g.drawLine(49, 0, 49, 10);
|
---|
33 | g.drawLine(24, 3, 24, 7);
|
---|
34 | g.drawLine(74, 3, 74, 7);
|
---|
35 | g.drawString(text, (int)(100-bound.getWidth()), 23);
|
---|
36 | g.drawString("0", 0, 23);
|
---|
37 | }
|
---|
38 |
|
---|
39 | static public Color getColor()
|
---|
40 | {
|
---|
41 | return Main.pref.getColor(marktr("scale"), Color.white);
|
---|
42 | }
|
---|
43 |
|
---|
44 | public String helpTopic() {
|
---|
45 | return "MapView/Scaler";
|
---|
46 | }
|
---|
47 | }
|
---|