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
009import org.openstreetmap.josm.tools.Utils;
010
011public class PuwgProjectionChoice extends ListProjectionChoice {
012
013    private static final String[] CODES = {
014        "EPSG:2180",
015        "EPSG:2176",
016        "EPSG:2177",
017        "EPSG:2178",
018        "EPSG:2179"
019    };
020
021    private static final String[] NAMES = {
022        tr("PUWG 1992 (Poland)"),
023        tr("PUWG 2000 Zone {0} (Poland)", 5),
024        tr("PUWG 2000 Zone {0} (Poland)", 6),
025        tr("PUWG 2000 Zone {0} (Poland)", 7),
026        tr("PUWG 2000 Zone {0} (Poland)", 8)
027    };
028
029    /**
030     * Constructs a new {@code PuwgProjectionChoice}.
031     */
032    public PuwgProjectionChoice() {
033        super(tr("PUWG (Poland)"), /* NO-ICON */ "core:puwg", NAMES, tr("PUWG Zone"));
034    }
035
036    @Override
037    public String getCurrentCode() {
038        return CODES[index];
039    }
040
041    @Override
042    public String getProjectionName() {
043        return NAMES[index];
044    }
045
046    @Override
047    public String[] allCodes() {
048        return Utils.copyArray(CODES);
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}