source: josm/trunk/src/org/openstreetmap/josm/gui/preferences/projection/PuwgProjectionChoice.java@ 6228

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

Sonar - replace array copy loops by more efficient calls to System.arraycopy

File size: 1.8 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 PuwgProjectionChoice extends ListProjectionChoice {
10
11 public static final String[] CODES = {
12 "EPSG:2180",
13 "EPSG:2176",
14 "EPSG:2177",
15 "EPSG:2178",
16 "EPSG:2179"
17 };
18 public static final String[] NAMES = {
19 tr("PUWG 1992 (Poland)"),
20 tr("PUWG 2000 Zone {0} (Poland)", 5),
21 tr("PUWG 2000 Zone {0} (Poland)", 6),
22 tr("PUWG 2000 Zone {0} (Poland)", 7),
23 tr("PUWG 2000 Zone {0} (Poland)", 8)
24 };
25
26 /**
27 * Constructs a new {@code PuwgProjectionChoice}.
28 */
29 public PuwgProjectionChoice() {
30 super(tr("PUWG (Poland)"), "core:puwg", NAMES, tr("PUWG Zone"));
31 }
32
33 @Override
34 public String getCurrentCode() {
35 return CODES[index];
36 }
37
38 @Override
39 public String getProjectionName() {
40 return NAMES[index];
41 }
42
43
44 @Override
45 public String[] allCodes() {
46 String[] zones = new String[CODES.length];
47 System.arraycopy(CODES, 0, zones, 0, CODES.length);
48 return zones;
49 }
50
51 @Override
52 public Collection<String> getPreferencesFromCode(String code) {
53 for (String code2 : CODES) {
54 if (code.equals(code2))
55 return Collections.singleton(code2);
56 }
57 return null;
58 }
59
60 @Override
61 protected String indexToZone(int index) {
62 return CODES[index];
63 }
64
65 @Override
66 protected int zoneToIndex(String zone) {
67 for (int i=0; i<CODES.length; i++) {
68 if (zone.equals(CODES[i])) {
69 return i;
70 }
71 }
72 return defaultIndex;
73 }
74
75}
Note: See TracBrowser for help on using the repository browser.