source: josm/trunk/src/org/openstreetmap/josm/gui/actionsupport/AlignImageryPanel.java @ 6340

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

refactor of some GUI/widgets classes (impacts some plugins):

  • gui.BookmarkList moves to gui.download as it is only meant to be used by gui.download.BookmarkSelection
  • tools.UrlLabel moves to gui.widgets
  • gui.JMultilineLabel, gui.MultiplitLayout, gui.MultiSplitPane move to gui.widgets
File size: 3.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.actionsupport;
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.JLabel;
15import javax.swing.JPanel;
16import javax.swing.border.CompoundBorder;
17import javax.swing.border.EmptyBorder;
18import javax.swing.border.EtchedBorder;
19
20import org.openstreetmap.josm.Main;
21import org.openstreetmap.josm.gui.widgets.UrlLabel;
22import org.openstreetmap.josm.tools.GBC;
23import 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 */
30public class AlignImageryPanel extends JPanel {
31    private static final String PREF = "imagery.offsetnagging";
32
33    public AlignImageryPanel(boolean oneLine) {
34        super();
35
36        Font font = getFont().deriveFont(Font.PLAIN, 14.0f);
37        JLabel nagLabel = new JLabel(tr("Aerial imagery might be misaligned. Please check its offset using GPS tracks!"));
38        UrlLabel detailsList = new UrlLabel(tr("http://wiki.openstreetmap.org/wiki/Using_Imagery"), tr("Details..."));
39        nagLabel.setFont(font);
40        detailsList.setFont(font);
41
42        JButton closeButton = new JButton(ImageProvider.get("misc", "black_x"));
43        closeButton.setContentAreaFilled(false);
44        closeButton.setRolloverEnabled(true);
45        closeButton.setBorderPainted(false);
46        closeButton.setToolTipText(tr("Hide this message and never show it again"));
47        closeButton.addActionListener(new ActionListener() {
48            @Override
49            public void actionPerformed( ActionEvent e ) {
50                if (Main.isDisplayingMapView()) {
51                    Main.map.removeTopPanel(AlignImageryPanel.class);
52                    Main.pref.put(PREF, false);
53                }
54            }
55        });
56
57        setLayout(new GridBagLayout());
58        if (!oneLine) { // tune for small screens
59            add(nagLabel, GBC.std(1, 1).fill());
60            add(detailsList, GBC.std(1, 2).fill());
61            add(closeButton, GBC.std(2, 1).span(1,2).anchor(GBC.EAST));
62        } else {
63            add(nagLabel, GBC.std(1,1).fill());
64            add(detailsList, GBC.std(2,1).fill());
65            add(closeButton, GBC.std(3,1).anchor(GBC.EAST));
66        }
67        setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.LOWERED), new EmptyBorder(12, 12, 12, 12)));
68        setBackground(new Color(224, 236, 249));
69    }
70
71    public static void addNagPanelIfNeeded() {
72        if (Main.isDisplayingMapView() && !Main.pref.getBoolean("expert") && Main.pref.getBoolean(PREF, true) ) {
73            if (Main.map.getTopPanel(AlignImageryPanel.class) == null) {
74                double w = Toolkit.getDefaultToolkit().getScreenSize().getWidth();
75                AlignImageryPanel p = new AlignImageryPanel(w>1300);
76                Main.map.addTopPanel(p);
77            }
78        }
79    }
80}
Note: See TracBrowser for help on using the repository browser.