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

Last change on this file since 1180 was 1180, checked in by stoecker, 15 years ago

fixed bug #1871, removed all deprecations

  • Property svn:eol-style set to native
File size: 2.5 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.data.coor.LatLon.CoordinateFormat;
17import org.openstreetmap.josm.tools.GBC;
18
19public class ProjectionPreference implements PreferenceSetting {
20
21 /**
22 * Combobox with all projections available
23 */
24 private JComboBox projectionCombo = new JComboBox(Projection.allProjections);
25 private JComboBox coordinatesCombo = new JComboBox(CoordinateFormat.values());
26
27 public void addGui(PreferenceDialog gui) {
28
29 for (int i = 0; i < projectionCombo.getItemCount(); ++i) {
30 if (projectionCombo.getItemAt(i).getClass().getName().equals(Main.pref.get("projection"))) {
31 projectionCombo.setSelectedIndex(i);
32 break;
33 }
34 }
35
36 for (int i = 0; i < coordinatesCombo.getItemCount(); ++i) {
37 if (((CoordinateFormat)coordinatesCombo.getItemAt(i)).name().equals(Main.pref.get("coordinates"))) {
38 coordinatesCombo.setSelectedIndex(i);
39 break;
40 }
41 }
42
43 JPanel projPanel = new JPanel();
44 projPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.gray), tr("Map Projection")));
45 projPanel.setLayout(new GridBagLayout());
46 projPanel.add(new JLabel(tr("Projection method")), GBC.std().insets(5,5,0,5));
47 projPanel.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL));
48 projPanel.add(projectionCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,5,5,5));
49 projPanel.add(new JLabel(tr("Display coordinates as")), GBC.std().insets(5,5,0,5));
50 projPanel.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL));
51 projPanel.add(coordinatesCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,5,5,5));
52 gui.map.add(projPanel, GBC.eol().insets(0,0,0,10).fill(GBC.HORIZONTAL));
53 }
54
55 public boolean ok() {
56 boolean restart = Main.pref.put("projection",
57 projectionCombo.getSelectedItem().getClass().getName());
58 if(Main.pref.put("coordinates",
59 ((CoordinateFormat)coordinatesCombo.getSelectedItem()).name()))
60 restart = true;
61 return restart;
62 }
63}
Note: See TracBrowser for help on using the repository browser.