source: josm/trunk/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java@ 627

Last change on this file since 627 was 627, checked in by framm, 16 years ago
  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.gui.preferences;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.Color;
7import java.awt.GridBagLayout;
8
9import javax.swing.BorderFactory;
10import javax.swing.JComboBox;
11import javax.swing.JLabel;
12import javax.swing.JPanel;
13
14import org.openstreetmap.josm.Main;
15import org.openstreetmap.josm.data.projection.Projection;
16import org.openstreetmap.josm.tools.GBC;
17
18public 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}
Note: See TracBrowser for help on using the repository browser.