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

Last change on this file since 10461 was 10000, checked in by Don-vip, 8 years ago

sonar - fix various issues

  • Property svn:eol-style set to native
File size: 4.1 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.event.ActionEvent;
10import java.awt.event.ActionListener;
11
12import javax.swing.JButton;
13import javax.swing.JCheckBox;
14import javax.swing.JPanel;
15import javax.swing.border.CompoundBorder;
16import javax.swing.border.EmptyBorder;
17import javax.swing.border.EtchedBorder;
18
19import org.openstreetmap.josm.Main;
20import org.openstreetmap.josm.data.imagery.ImageryInfo;
21import org.openstreetmap.josm.data.preferences.BooleanProperty;
22import org.openstreetmap.josm.gui.util.GuiHelper;
23import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
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 JMultilineLabel nagLabel = new JMultilineLabel(
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.setFont(font);
46 nagLabel.setForeground(Color.BLACK);
47 detailsList.setFont(font);
48 final JCheckBox doNotShowAgain = new JCheckBox(tr("Do not show this message again"));
49 doNotShowAgain.setOpaque(false);
50 doNotShowAgain.setForeground(Color.BLACK);
51
52 JButton closeButton = new JButton(ImageProvider.get("misc", "black_x"));
53 closeButton.setContentAreaFilled(false);
54 closeButton.setRolloverEnabled(true);
55 closeButton.setBorderPainted(false);
56 closeButton.setToolTipText(tr("Hide this message and never show it again"));
57 closeButton.addActionListener(new ActionListener() {
58 @Override
59 public void actionPerformed(ActionEvent e) {
60 if (Main.isDisplayingMapView()) {
61 Main.map.removeTopPanel(AlignImageryPanel.class);
62 if (doNotShowAgain.isSelected()) {
63 showAgain.put(Boolean.FALSE);
64 }
65 }
66 }
67 });
68
69 setLayout(new GridBagLayout());
70 if (!oneLine) { // tune for small screens
71 add(nagLabel, GBC.std(1, 1).fill());
72 add(detailsList, GBC.std(1, 2).fill());
73 add(doNotShowAgain, GBC.std(1, 3).fill());
74 add(closeButton, GBC.std(2, 1).span(1, 2).anchor(GBC.EAST));
75 } else {
76 add(nagLabel, GBC.std(1, 1).fill());
77 add(detailsList, GBC.std(2, 1).fill());
78 add(doNotShowAgain, GBC.std(1, 2).fill());
79 add(closeButton, GBC.std(3, 1).anchor(GBC.EAST));
80 }
81 setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.LOWERED), new EmptyBorder(12, 12, 12, 12)));
82 setBackground(new Color(224, 236, 249));
83 }
84
85 /**
86 * @param infoToAdd ImageryInfo for which the nag panel should be created
87 */
88 public static void addNagPanelIfNeeded(ImageryInfo infoToAdd) {
89 BooleanProperty showAgain = new BooleanProperty("message.imagery.nagPanel." + infoToAdd.getUrl(), true);
90 if (Main.isDisplayingMapView() && showAgain.get() && !infoToAdd.isGeoreferenceValid()) {
91 if (Main.map.getTopPanel(AlignImageryPanel.class) == null) {
92 double w = GuiHelper.getScreenSize().getWidth();
93 AlignImageryPanel p = new AlignImageryPanel(w > 1300, showAgain, infoToAdd);
94 Main.map.addTopPanel(p);
95 }
96 }
97 }
98}
Note: See TracBrowser for help on using the repository browser.