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

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

checkstyle

  • 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;
9import java.awt.Toolkit;
10import java.awt.event.ActionEvent;
11import java.awt.event.ActionListener;
12
13import javax.swing.JButton;
14import javax.swing.JCheckBox;
15import javax.swing.JLabel;
16import javax.swing.JPanel;
17import javax.swing.border.CompoundBorder;
18import javax.swing.border.EmptyBorder;
19import javax.swing.border.EtchedBorder;
20
21import org.openstreetmap.josm.Main;
22import org.openstreetmap.josm.data.imagery.ImageryInfo;
23import org.openstreetmap.josm.data.preferences.BooleanProperty;
24import org.openstreetmap.josm.gui.widgets.UrlLabel;
25import org.openstreetmap.josm.tools.GBC;
26import org.openstreetmap.josm.tools.ImageProvider;
27
28/**
29 * The panel to nag a user ONCE that he/she has to align imagery.
30 *
31 * @author zverik
32 */
33public class AlignImageryPanel extends JPanel {
34
35 /**
36 * @param oneLine if true, show the nagging message in one line, otherwise - in two lines
37 * @param showAgain show again property
38 * @param infoToAdd imagery info for which the nagging message is shown
39 */
40 public AlignImageryPanel(boolean oneLine, final BooleanProperty showAgain, ImageryInfo infoToAdd) {
41 Font font = getFont().deriveFont(Font.PLAIN, 14.0f);
42 JLabel nagLabel = new JLabel(
43 tr("Aerial imagery \"{0}\" might be misaligned. Please check its offset using GPS tracks!", infoToAdd.getName()));
44 UrlLabel detailsList = new UrlLabel(tr("http://wiki.openstreetmap.org/wiki/Using_Imagery"), tr("Details..."));
45 nagLabel.setLabelFor(detailsList);
46 nagLabel.setFont(font);
47 detailsList.setFont(font);
48 final JCheckBox doNotShowAgain = new JCheckBox(tr("Do not show this message again"));
49 doNotShowAgain.setOpaque(false);
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(new ActionListener() {
57 @Override
58 public void actionPerformed(ActionEvent e) {
59 if (Main.isDisplayingMapView()) {
60 Main.map.removeTopPanel(AlignImageryPanel.class);
61 if (doNotShowAgain.isSelected()) {
62 showAgain.put(false);
63 }
64 }
65 }
66 });
67
68 setLayout(new GridBagLayout());
69 if (!oneLine) { // tune for small screens
70 add(nagLabel, GBC.std(1, 1).fill());
71 add(detailsList, GBC.std(1, 2).fill());
72 add(doNotShowAgain, GBC.std(1, 3).fill());
73 add(closeButton, GBC.std(2, 1).span(1, 2).anchor(GBC.EAST));
74 } else {
75 add(nagLabel, GBC.std(1, 1).fill());
76 add(detailsList, GBC.std(2, 1).fill());
77 add(doNotShowAgain, GBC.std(1, 2).fill());
78 add(closeButton, GBC.std(3, 1).anchor(GBC.EAST));
79 }
80 setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.LOWERED), new EmptyBorder(12, 12, 12, 12)));
81 setBackground(new Color(224, 236, 249));
82 }
83
84 /**
85 * @param infoToAdd ImageryInfo for which the nag panel should be created
86 */
87 public static void addNagPanelIfNeeded(ImageryInfo infoToAdd) {
88 BooleanProperty showAgain = new BooleanProperty("message.imagery.nagPanel." + infoToAdd.getUrl(), true);
89 if (Main.isDisplayingMapView() && showAgain.get() && !infoToAdd.isGeoreferenceValid()) {
90 if (Main.map.getTopPanel(AlignImageryPanel.class) == null) {
91 double w = Toolkit.getDefaultToolkit().getScreenSize().getWidth();
92 AlignImageryPanel p = new AlignImageryPanel(w > 1300, showAgain, infoToAdd);
93 Main.map.addTopPanel(p);
94 }
95 }
96 }
97}
Note: See TracBrowser for help on using the repository browser.