Changeset 5234 in josm for trunk/src/org/openstreetmap/josm/data/projection/GaussKrueger.java
- Timestamp:
- 2012-05-12T18:23:08+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/projection/GaussKrueger.java
r5226 r5234 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import java.awt.GridBagLayout;7 import java.awt.event.ActionListener;8 import java.util.Collection;9 import java.util.Collections;10 11 import javax.swing.JComboBox;12 import javax.swing.JLabel;13 import javax.swing.JPanel;14 5 15 6 import org.openstreetmap.josm.data.Bounds; … … 19 10 import org.openstreetmap.josm.data.projection.proj.ProjParameters; 20 11 import org.openstreetmap.josm.data.projection.proj.TransverseMercator; 21 import org.openstreetmap.josm.tools.GBC;22 12 23 public class GaussKrueger extends AbstractProjection implements ProjectionSubPrefs{13 public class GaussKrueger extends AbstractProjection { 24 14 25 15 public static final int DEFAULT_ZONE = 2; 26 private int zone;16 private final int zone; 27 17 28 18 private static Bounds[] bounds = { … … 33 23 }; 34 24 35 private static String[] zones = { "2", "3", "4", "5" };36 37 25 public GaussKrueger() { 38 26 this(DEFAULT_ZONE); … … 40 28 41 29 public GaussKrueger(int zone) { 42 updateParameters(zone); 43 } 44 45 private void updateParameters(int zone) { 30 if (zone < 2 || zone > 5) 31 throw new IllegalArgumentException(); 46 32 this.zone = zone; 47 33 ellps = Ellipsoid.Bessel1841; … … 63 49 @Override 64 50 public String toString() { 65 return tr("Gau\u00DF-Kr\u00FCger ");51 return tr("Gau\u00DF-Kr\u00FCger Zone {0}", zone); 66 52 } 67 53 … … 81 67 } 82 68 83 @Override84 public void setupPreferencePanel(JPanel p, ActionListener listener) {85 JComboBox prefcb = new JComboBox(zones);86 87 prefcb.setSelectedIndex(zone-2);88 p.setLayout(new GridBagLayout());89 p.add(new JLabel(tr("GK Zone")), GBC.std().insets(5,5,0,5));90 p.add(GBC.glue(1, 0), GBC.std().fill(GBC.HORIZONTAL));91 /* Note: we use component position 2 below to find this again */92 p.add(prefcb, GBC.eop().fill(GBC.HORIZONTAL));93 p.add(GBC.glue(1, 1), GBC.eol().fill(GBC.BOTH));94 95 if (listener != null) {96 prefcb.addActionListener(listener);97 }98 }99 100 @Override101 public Collection<String> getPreferences(JPanel p) {102 Object prefcb = p.getComponent(2);103 if(!(prefcb instanceof JComboBox))104 return null;105 int zone = ((JComboBox)prefcb).getSelectedIndex();106 return Collections.singleton(Integer.toString(zone+2));107 }108 109 @Override110 public void setPreferences(Collection<String> args) {111 int zone = DEFAULT_ZONE;112 if (args != null) {113 try {114 for(String s : args)115 {116 zone = Integer.parseInt(s);117 if(zone < 2 || zone > 5) {118 zone = DEFAULT_ZONE;119 }120 break;121 }122 } catch(NumberFormatException e) {}123 }124 updateParameters(zone);125 }126 127 @Override128 public String[] allCodes() {129 String[] zones = new String[4];130 for (int zone = 2; zone <= 5; zone++) {131 zones[zone-2] = "EPSG:" + (31464 + zone);132 }133 return zones;134 }135 136 @Override137 public Collection<String> getPreferencesFromCode(String code)138 {139 //zone 2 = EPSG:31466 up to zone 5 = EPSG:31469140 for (int zone = 2; zone <= 5; zone++) {141 String epsg = "EPSG:" + (31464 + zone);142 if (epsg.equals(code))143 return Collections.singleton(String.valueOf(zone));144 }145 return null;146 }147 148 69 }
Note:
See TracChangeset
for help on using the changeset viewer.