001 // License: GPL. For details, see LICENSE file. 002 package org.openstreetmap.josm.gui.preferences.projection; 003 004 import static org.openstreetmap.josm.tools.I18n.tr; 005 006 import java.util.Collection; 007 import java.util.Collections; 008 009 public 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 public PuwgProjectionChoice() { 027 super(tr("PUWG (Poland)"), "core:puwg", NAMES, tr("PUWG Zone")); 028 } 029 030 @Override 031 public String getCurrentCode() { 032 return CODES[index]; 033 } 034 035 @Override 036 public String getProjectionName() { 037 return NAMES[index]; 038 } 039 040 041 @Override 042 public String[] allCodes() { 043 String[] zones = new String[CODES.length]; 044 for (int idx = 0; idx < CODES.length; idx++) { 045 zones[idx] = CODES[idx]; 046 } 047 return zones; 048 } 049 050 @Override 051 public Collection<String> getPreferencesFromCode(String code) { 052 for (String code2 : CODES) { 053 if (code.equals(code2)) 054 return Collections.singleton(code2); 055 } 056 return null; 057 } 058 059 @Override 060 protected String indexToZone(int index) { 061 return CODES[index]; 062 } 063 064 @Override 065 protected int zoneToIndex(String zone) { 066 for (int i=0; i<CODES.length; i++) { 067 if (zone.equals(CODES[i])) { 068 return i; 069 } 070 } 071 return defaultIndex; 072 } 073 074 }