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

Last change on this file since 9168 was 8510, checked in by Don-vip, 9 years ago

checkstyle: enable relevant whitespace checks and fix them

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui;
3
4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
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.gui.help.Helpful;
15
16public class MapScaler extends JComponent implements Helpful {
17
18 private final NavigatableComponent mv;
19
20 private static final int PADDING_RIGHT = 100;
21
22 public MapScaler(NavigatableComponent mv) {
23 this.mv = mv;
24 setSize(100+PADDING_RIGHT, 30);
25 setOpaque(false);
26 }
27
28 @Override
29 public void paint(Graphics g) {
30 String text = mv.getDist100PixelText();
31 Rectangle2D bound = g.getFontMetrics().getStringBounds(text, g);
32 g.setColor(getColor());
33 g.drawLine(0, 5, 99, 5);
34 g.drawLine(0, 0, 0, 10);
35 g.drawLine(99, 0, 99, 10);
36 g.drawLine(49, 3, 49, 7);
37 g.drawLine(24, 3, 24, 7);
38 g.drawLine(74, 3, 74, 7);
39 g.drawString(text, (int) (100-bound.getWidth()/2), 23);
40 g.drawString("0", 0, 23);
41 }
42
43 public static Color getColor() {
44 return Main.pref.getColor(marktr("scale"), Color.white);
45 }
46
47 @Override
48 public String helpTopic() {
49 return ht("/MapView/Scaler");
50 }
51}
Note: See TracBrowser for help on using the repository browser.