001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.preferences.projection; 003 004import static org.openstreetmap.josm.tools.I18n.tr; 005 006import java.util.Collection; 007import java.util.Collections; 008 009public class PuwgProjectionChoice extends ListProjectionChoice { 010 011 public static final String[] CODES = { 012 "EPSG:2180", 013 "EPSG:2176", 014 "EPSG:2177", 015 "EPSG:2178", 016 "EPSG:2179" 017 }; 018 public static final String[] NAMES = { 019 tr("PUWG 1992 (Poland)"), 020 tr("PUWG 2000 Zone {0} (Poland)", 5), 021 tr("PUWG 2000 Zone {0} (Poland)", 6), 022 tr("PUWG 2000 Zone {0} (Poland)", 7), 023 tr("PUWG 2000 Zone {0} (Poland)", 8) 024 }; 025 026 /** 027 * Constructs a new {@code PuwgProjectionChoice}. 028 */ 029 public PuwgProjectionChoice() { 030 super(tr("PUWG (Poland)"), "core:puwg", NAMES, tr("PUWG Zone")); 031 } 032 033 @Override 034 public String getCurrentCode() { 035 return CODES[index]; 036 } 037 038 @Override 039 public String getProjectionName() { 040 return NAMES[index]; 041 } 042 043 044 @Override 045 public String[] allCodes() { 046 String[] zones = new String[CODES.length]; 047 System.arraycopy(CODES, 0, zones, 0, CODES.length); 048 return zones; 049 } 050 051 @Override 052 public Collection<String> getPreferencesFromCode(String code) { 053 for (String code2 : CODES) { 054 if (code.equals(code2)) 055 return Collections.singleton(code2); 056 } 057 return null; 058 } 059 060 @Override 061 protected String indexToZone(int index) { 062 return CODES[index]; 063 } 064 065 @Override 066 protected int zoneToIndex(String zone) { 067 for (int i=0; i<CODES.length; i++) { 068 if (zone.equals(CODES[i])) { 069 return i; 070 } 071 } 072 return defaultIndex; 073 } 074 075}