| 1 | // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others
|
|---|
| 2 | package cadastre_fr;
|
|---|
| 3 |
|
|---|
| 4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
|---|
| 5 |
|
|---|
| 6 | import java.awt.GridBagLayout;
|
|---|
| 7 | import java.awt.event.ActionEvent;
|
|---|
| 8 |
|
|---|
| 9 | import javax.swing.JComboBox;
|
|---|
| 10 | import javax.swing.JLabel;
|
|---|
| 11 | import javax.swing.JOptionPane;
|
|---|
| 12 | import javax.swing.JPanel;
|
|---|
| 13 |
|
|---|
| 14 | import org.openstreetmap.josm.Main;
|
|---|
| 15 | import org.openstreetmap.josm.actions.JosmAction;
|
|---|
| 16 | import org.openstreetmap.josm.data.projection.Lambert;
|
|---|
| 17 | import org.openstreetmap.josm.data.projection.LambertCC9Zones;
|
|---|
| 18 | import org.openstreetmap.josm.tools.GBC;
|
|---|
| 19 |
|
|---|
| 20 | public class MenuActionLambertZone extends JosmAction {
|
|---|
| 21 |
|
|---|
| 22 | private static final long serialVersionUID = 1L;
|
|---|
| 23 |
|
|---|
| 24 | public static String name = "Change Lambert zone";
|
|---|
| 25 |
|
|---|
| 26 | public static String[] lambert4zones = { "", "1 (51.30 to 48.15 degrees)", "2 (48.15 to 45.45 degrees)", "3 (45.45 to 42.76 degrees)", "4 (Corsica)" };
|
|---|
| 27 | public static String[] lambert9zones = { "", "1 (41 to 43 degrees)", "2 (42 to 44 degrees)",
|
|---|
| 28 | "3 (43 to 45 degrees)", "4 (44 to 46 degrees)", "5 (45 to 47 degrees)",
|
|---|
| 29 | "6 (46 to 48 degrees)", "7 (47 to 49 degrees)", "8 (48 to 50 degrees)",
|
|---|
| 30 | "9 (49 to 51 degrees)" };
|
|---|
| 31 |
|
|---|
| 32 | public MenuActionLambertZone() {
|
|---|
| 33 | super(tr(name), "cadastre_small", tr("Set manually the Lambert zone"),
|
|---|
| 34 | null, false);
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | public void actionPerformed(ActionEvent e) {
|
|---|
| 38 | JPanel p = new JPanel(new GridBagLayout());
|
|---|
| 39 | final JComboBox inputLambertZone;
|
|---|
| 40 | if (Main.proj instanceof LambertCC9Zones)
|
|---|
| 41 | inputLambertZone = new JComboBox(lambert9zones);
|
|---|
| 42 | else
|
|---|
| 43 | inputLambertZone = new JComboBox(lambert4zones);
|
|---|
| 44 | JLabel newLambertZone = new JLabel(tr("Zone"));
|
|---|
| 45 | p.add(newLambertZone, GBC.std());
|
|---|
| 46 | p.add(inputLambertZone, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 0));
|
|---|
| 47 | JOptionPane pane = new JOptionPane(p, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null) {
|
|---|
| 48 | private static final long serialVersionUID = 1L;
|
|---|
| 49 |
|
|---|
| 50 | @Override
|
|---|
| 51 | public void selectInitialValue() {
|
|---|
| 52 | inputLambertZone.setSelectedIndex(0);
|
|---|
| 53 | }
|
|---|
| 54 | };
|
|---|
| 55 | pane.createDialog(Main.parent, tr("Lambert zone")).setVisible(true);
|
|---|
| 56 | if (!Integer.valueOf(JOptionPane.OK_OPTION).equals(pane.getValue()))
|
|---|
| 57 | return;
|
|---|
| 58 | if (inputLambertZone.getSelectedIndex() > 0) {
|
|---|
| 59 | Lambert.layoutZone = inputLambertZone.getSelectedIndex() - 1;
|
|---|
| 60 | LambertCC9Zones.layoutZone = Lambert.layoutZone;
|
|---|
| 61 | }
|
|---|
| 62 | }
|
|---|
| 63 | }
|
|---|