1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.gui.preferences;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.Color;
|
---|
7 | import java.awt.GridBagLayout;
|
---|
8 |
|
---|
9 | import javax.swing.BorderFactory;
|
---|
10 | import javax.swing.JComboBox;
|
---|
11 | import javax.swing.JLabel;
|
---|
12 | import javax.swing.JPanel;
|
---|
13 |
|
---|
14 | import org.openstreetmap.josm.Main;
|
---|
15 | import org.openstreetmap.josm.data.projection.Projection;
|
---|
16 | import org.openstreetmap.josm.tools.GBC;
|
---|
17 |
|
---|
18 | public class ProjectionPreference implements PreferenceSetting {
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Combobox with all projections available
|
---|
22 | */
|
---|
23 | private JComboBox projectionCombo = new JComboBox(Projection.allProjections);
|
---|
24 |
|
---|
25 | public void addGui(PreferenceDialog gui) {
|
---|
26 | for (int i = 0; i < projectionCombo.getItemCount(); ++i) {
|
---|
27 | if (projectionCombo.getItemAt(i).getClass().getName().equals(Main.pref.get("projection"))) {
|
---|
28 | projectionCombo.setSelectedIndex(i);
|
---|
29 | break;
|
---|
30 | }
|
---|
31 | }
|
---|
32 | projectionCombo.addActionListener(gui.requireRestartAction);
|
---|
33 |
|
---|
34 | JPanel projPanel = new JPanel();
|
---|
35 | projPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.gray), tr("Map Projection")));
|
---|
36 | projPanel.setLayout(new GridBagLayout());
|
---|
37 | projPanel.add(new JLabel(tr("Projection method")), GBC.std().insets(5,5,0,5));
|
---|
38 | projPanel.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL));
|
---|
39 | projPanel.add(projectionCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,5,5,5));
|
---|
40 | gui.map.add(projPanel, GBC.eol().insets(0,0,0,10).fill(GBC.HORIZONTAL));
|
---|
41 | }
|
---|
42 |
|
---|
43 | public void ok() {
|
---|
44 | Main.pref.put("projection", projectionCombo.getSelectedItem().getClass().getName());
|
---|
45 | }
|
---|
46 | }
|
---|