| 1 | package org.openstreetmap.josm.gui.actionsupport; |
| 2 | |
| 3 | |
| 4 | import java.awt.BorderLayout; |
| 5 | import java.awt.Color; |
| 6 | import java.awt.Font; |
| 7 | import java.awt.event.ActionEvent; |
| 8 | import java.awt.event.ActionListener; |
| 9 | import javax.swing.BoxLayout; |
| 10 | import javax.swing.JButton; |
| 11 | import javax.swing.JLabel; |
| 12 | import javax.swing.JPanel; |
| 13 | import javax.swing.Box; |
| 14 | import javax.swing.JSplitPane; |
| 15 | import javax.swing.border.CompoundBorder; |
| 16 | import javax.swing.border.EmptyBorder; |
| 17 | import javax.swing.border.EtchedBorder; |
| 18 | |
| 19 | import org.openstreetmap.josm.Main; |
| 20 | import static org.openstreetmap.josm.tools.I18n.tr; |
| 21 | import org.openstreetmap.josm.tools.ImageProvider; |
| 22 | import org.openstreetmap.josm.tools.UrlLabel; |
| 23 | |
| 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() { |
| 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 | // JLabel nagLabel = new JLabel(tr("Снимки могут быть смещены. Не забудьте проверить привязку снимков по GPS-трекам!")); |
| 39 | UrlLabel detailsList = new UrlLabel(tr("http://wiki.openstreetmap.org/wiki/Using_Imagery"), tr("Details...")); |
| 40 | nagLabel.setFont(font); |
| 41 | detailsList.setFont(font); |
| 42 | |
| 43 | // JButton closeButton = new JButton("X"); |
| 44 | JButton closeButton = new JButton(ImageProvider.get("misc", "black_x")); |
| 45 | closeButton.setContentAreaFilled(false); |
| 46 | closeButton.setRolloverEnabled(true); |
| 47 | closeButton.setBorderPainted(false); |
| 48 | closeButton.setToolTipText(tr("Hide this message and never show it again")); |
| 49 | closeButton.addActionListener(new ActionListener() { |
| 50 | @Override |
| 51 | public void actionPerformed( ActionEvent e ) { |
| 52 | setVisible(false); |
| 53 | getParent().remove(AlignImageryPanel.this); |
| 54 | } |
| 55 | }); |
| 56 | |
| 57 | BoxLayout box = new BoxLayout(this, BoxLayout.X_AXIS); |
| 58 | setLayout(box); |
| 59 | add(nagLabel); |
| 60 | add(Box.createHorizontalStrut(12)); |
| 61 | add(detailsList); |
| 62 | add(Box.createHorizontalGlue()); |
| 63 | add(closeButton); |
| 64 | // setBorder(new EmptyBorder(12, 12, 12, 12)); |
| 65 | setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.LOWERED), new EmptyBorder(12, 12, 12, 12))); |
| 66 | setBackground(new Color(224, 236, 249)); |
| 67 | } |
| 68 | |
| 69 | public static void addNagPanel() { |
| 70 | if( Main.map != null && !Main.pref.getBoolean("expert") && Main.pref.getBoolean(PREF, true) ) { |
| 71 | if( Main.map.mapView != null && Main.map.mapView.getParent() instanceof JSplitPane ) { |
| 72 | // This is really a hack. If you don't like it, use the line in "else" block |
| 73 | JPanel p = new JPanel(new BorderLayout()); |
| 74 | ((JSplitPane)Main.map.mapView.getParent()).setLeftComponent(p); |
| 75 | p.add(Main.map.mapView, BorderLayout.CENTER); |
| 76 | p.add(new AlignImageryPanel(), BorderLayout.NORTH); |
| 77 | } else |
| 78 | Main.map.add(new AlignImageryPanel(), BorderLayout.NORTH); |
| 79 | Main.pref.put(PREF, false); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | } |