1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.layer;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.Color;
|
---|
7 | import java.awt.Font;
|
---|
8 | import java.awt.GridBagLayout;
|
---|
9 | import java.awt.Toolkit;
|
---|
10 | import java.awt.event.ActionEvent;
|
---|
11 | import java.awt.event.ActionListener;
|
---|
12 |
|
---|
13 | import javax.swing.JButton;
|
---|
14 | import javax.swing.JLabel;
|
---|
15 | import javax.swing.JPanel;
|
---|
16 | import javax.swing.border.CompoundBorder;
|
---|
17 | import javax.swing.border.EmptyBorder;
|
---|
18 | import javax.swing.border.EtchedBorder;
|
---|
19 |
|
---|
20 | import org.openstreetmap.josm.Main;
|
---|
21 | import org.openstreetmap.josm.gui.widgets.UrlLabel;
|
---|
22 | import org.openstreetmap.josm.tools.GBC;
|
---|
23 | import org.openstreetmap.josm.tools.ImageProvider;
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * The panel to nag a user ONCE that he/she has to align imagery.
|
---|
27 | *
|
---|
28 | * @author zverik
|
---|
29 | */
|
---|
30 | public class AlignImageryPanel extends JPanel {
|
---|
31 | private static final String PREF = "imagery.offsetnagging";
|
---|
32 |
|
---|
33 | public AlignImageryPanel(boolean oneLine) {
|
---|
34 | Font font = getFont().deriveFont(Font.PLAIN, 14.0f);
|
---|
35 | JLabel nagLabel = new JLabel(tr("Aerial imagery might be misaligned. Please check its offset using GPS tracks!"));
|
---|
36 | UrlLabel detailsList = new UrlLabel(tr("http://wiki.openstreetmap.org/wiki/Using_Imagery"), tr("Details..."));
|
---|
37 | nagLabel.setLabelFor(detailsList);
|
---|
38 | nagLabel.setFont(font);
|
---|
39 | detailsList.setFont(font);
|
---|
40 |
|
---|
41 | JButton closeButton = new JButton(ImageProvider.get("misc", "black_x"));
|
---|
42 | closeButton.setContentAreaFilled(false);
|
---|
43 | closeButton.setRolloverEnabled(true);
|
---|
44 | closeButton.setBorderPainted(false);
|
---|
45 | closeButton.setToolTipText(tr("Hide this message and never show it again"));
|
---|
46 | closeButton.addActionListener(new ActionListener() {
|
---|
47 | @Override
|
---|
48 | public void actionPerformed(ActionEvent e) {
|
---|
49 | if (Main.isDisplayingMapView()) {
|
---|
50 | Main.map.removeTopPanel(AlignImageryPanel.class);
|
---|
51 | Main.pref.put(PREF, false);
|
---|
52 | }
|
---|
53 | }
|
---|
54 | });
|
---|
55 |
|
---|
56 | setLayout(new GridBagLayout());
|
---|
57 | if (!oneLine) { // tune for small screens
|
---|
58 | add(nagLabel, GBC.std(1, 1).fill());
|
---|
59 | add(detailsList, GBC.std(1, 2).fill());
|
---|
60 | add(closeButton, GBC.std(2, 1).span(1, 2).anchor(GBC.EAST));
|
---|
61 | } else {
|
---|
62 | add(nagLabel, GBC.std(1, 1).fill());
|
---|
63 | add(detailsList, GBC.std(2, 1).fill());
|
---|
64 | add(closeButton, GBC.std(3, 1).anchor(GBC.EAST));
|
---|
65 | }
|
---|
66 | setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.LOWERED), new EmptyBorder(12, 12, 12, 12)));
|
---|
67 | setBackground(new Color(224, 236, 249));
|
---|
68 | }
|
---|
69 |
|
---|
70 | public static void addNagPanelIfNeeded() {
|
---|
71 | if (Main.isDisplayingMapView() && !Main.pref.getBoolean("expert") && Main.pref.getBoolean(PREF, true)) {
|
---|
72 | if (Main.map.getTopPanel(AlignImageryPanel.class) == null) {
|
---|
73 | double w = Toolkit.getDefaultToolkit().getScreenSize().getWidth();
|
---|
74 | AlignImageryPanel p = new AlignImageryPanel(w > 1300);
|
---|
75 | Main.map.addTopPanel(p);
|
---|
76 | }
|
---|
77 | }
|
---|
78 | }
|
---|
79 | }
|
---|