source: josm/trunk/src/org/openstreetmap/josm/gui/preferences/projection/GaussKruegerProjectionChoice.java@ 6295

Last change on this file since 6295 was 6295, checked in by Don-vip, 11 years ago

Sonar/Findbugs - fix various problems, javadoc

File size: 1.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.preferences.projection;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.util.Collection;
7import java.util.Collections;
8
9public class GaussKruegerProjectionChoice extends ListProjectionChoice {
10
11 private static String[] zones = { "2", "3", "4", "5" };
12
13 /**
14 * Constructs a new {@code GaussKruegerProjectionChoice}.
15 */
16 public GaussKruegerProjectionChoice() {
17 super(tr("Gau\u00DF-Kr\u00FCger"), "core:gauss-krueger", zones, tr("GK Zone"));
18 }
19
20 @Override
21 public String getCurrentCode() {
22 return "EPSG:"+Integer.toString(31466 + index);
23 }
24
25 @Override
26 protected String indexToZone(int index) {
27 return Integer.toString(index + 2);
28 }
29
30 @Override
31 protected int zoneToIndex(String zone) {
32 try {
33 return Integer.parseInt(zone) - 2;
34 } catch(NumberFormatException e) {}
35 return defaultIndex;
36 }
37
38 @Override
39 public String[] allCodes() {
40 String[] codes = new String[4];
41 for (int zone = 2; zone <= 5; zone++) {
42 codes[zone-2] = "EPSG:" + (31464 + zone);
43 }
44 return codes;
45 }
46
47 @Override
48 public Collection<String> getPreferencesFromCode(String code)
49 {
50 //zone 2 = EPSG:31466 up to zone 5 = EPSG:31469
51 for (int zone = 2; zone <= 5; zone++) {
52 String epsg = "EPSG:" + (31464 + zone);
53 if (epsg.equals(code))
54 return Collections.singleton(String.valueOf(zone));
55 }
56 return null;
57 }
58
59 @Override
60 public String getProjectionName() {
61 return tr("Gau\u00DF-Kr\u00FCger Zone {0}", index + 2);
62 }
63
64}
Note: See TracBrowser for help on using the repository browser.