source: josm/trunk/src/org/openstreetmap/josm/gui/layer/AlignImageryPanel.java@ 13967

Last change on this file since 13967 was 12630, checked in by Don-vip, 7 years ago

see #15182 - deprecate Main.map and Main.isDisplayingMapView(). Replacements: gui.MainApplication.getMap() / gui.MainApplication.isDisplayingMapView()

  • Property svn:eol-style set to native
File size: 4.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.layer;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.Color;
7import java.awt.Font;
8import java.awt.GridBagLayout;
9
10import javax.swing.JButton;
11import javax.swing.JCheckBox;
12import javax.swing.JPanel;
13import javax.swing.border.CompoundBorder;
14import javax.swing.border.EmptyBorder;
15import javax.swing.border.EtchedBorder;
16
17import org.openstreetmap.josm.data.imagery.ImageryInfo;
18import org.openstreetmap.josm.data.preferences.BooleanProperty;
19import org.openstreetmap.josm.gui.MainApplication;
20import org.openstreetmap.josm.gui.MapFrame;
21import org.openstreetmap.josm.gui.util.GuiHelper;
22import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
23import org.openstreetmap.josm.gui.widgets.UrlLabel;
24import org.openstreetmap.josm.tools.GBC;
25import org.openstreetmap.josm.tools.ImageProvider;
26
27/**
28 * The panel to nag a user ONCE that he/she has to align imagery.
29 *
30 * @author zverik
31 */
32public class AlignImageryPanel extends JPanel {
33
34 /**
35 * @param oneLine if true, show the nagging message in one line, otherwise - in two lines
36 * @param showAgain show again property
37 * @param infoToAdd imagery info for which the nagging message is shown
38 */
39 public AlignImageryPanel(boolean oneLine, final BooleanProperty showAgain, ImageryInfo infoToAdd) {
40 Font font = getFont().deriveFont(Font.PLAIN, 14.0f);
41 JMultilineLabel nagLabel = new JMultilineLabel(
42 tr("Aerial imagery \"{0}\" might be misaligned. Please check its offset using GPS tracks!", infoToAdd.getName()));
43 UrlLabel detailsList = new UrlLabel(tr("http://wiki.openstreetmap.org/wiki/Using_Imagery"), tr("Details..."));
44 nagLabel.setFont(font);
45 nagLabel.setForeground(Color.BLACK);
46 detailsList.setFont(font);
47 final JCheckBox doNotShowAgain = new JCheckBox(tr("Do not show this message again"));
48 doNotShowAgain.setOpaque(false);
49 doNotShowAgain.setForeground(Color.BLACK);
50
51 JButton closeButton = new JButton(ImageProvider.get("misc", "black_x"));
52 closeButton.setContentAreaFilled(false);
53 closeButton.setRolloverEnabled(true);
54 closeButton.setBorderPainted(false);
55 closeButton.setToolTipText(tr("Hide this message and never show it again"));
56 closeButton.addActionListener(e -> {
57 if (MainApplication.isDisplayingMapView()) {
58 MainApplication.getMap().removeTopPanel(AlignImageryPanel.class);
59 if (doNotShowAgain.isSelected()) {
60 showAgain.put(Boolean.FALSE);
61 }
62 }
63 });
64
65 setLayout(new GridBagLayout());
66 if (!oneLine) { // tune for small screens
67 add(nagLabel, GBC.std(1, 1).fill());
68 add(detailsList, GBC.std(1, 2).fill());
69 add(doNotShowAgain, GBC.std(1, 3).fill());
70 add(closeButton, GBC.std(2, 1).span(1, 2).anchor(GBC.EAST));
71 } else {
72 add(nagLabel, GBC.std(1, 1).fill());
73 add(detailsList, GBC.std(2, 1).fill());
74 add(doNotShowAgain, GBC.std(1, 2).fill());
75 add(closeButton, GBC.std(3, 1).anchor(GBC.EAST));
76 }
77 setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.LOWERED), new EmptyBorder(12, 12, 12, 12)));
78 setBackground(new Color(224, 236, 249));
79 }
80
81 /**
82 * @param infoToAdd ImageryInfo for which the nag panel should be created
83 */
84 public static void addNagPanelIfNeeded(ImageryInfo infoToAdd) {
85 BooleanProperty showAgain = new BooleanProperty("message.imagery.nagPanel." + infoToAdd.getUrl(), true);
86 MapFrame map = MainApplication.getMap();
87 if (MainApplication.isDisplayingMapView() && showAgain.get() && !infoToAdd.isGeoreferenceValid()
88 && map.getTopPanel(AlignImageryPanel.class) == null) {
89 double w = GuiHelper.getScreenSize().getWidth();
90 map.addTopPanel(new AlignImageryPanel(w > 1300, showAgain, infoToAdd));
91 }
92 }
93}
Note: See TracBrowser for help on using the repository browser.