001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.preferences.projection; 003 004import java.awt.event.ActionListener; 005import java.util.Collection; 006import java.util.Collections; 007 008import javax.swing.JPanel; 009 010/** 011 * ProjectionChoice, that offers just one projection as choice. 012 * 013 * The GUI is an empty panel. 014 */ 015public class SingleProjectionChoice extends AbstractProjectionChoice { 016 017 protected String code; 018 019 /** 020 * Constructs a new {@code SingleProjectionChoice}. 021 * 022 * @param name short name of the projection choice as shown in the GUI 023 * @param id unique identifier for the projection choice, e.g. "core:thisproj" 024 * @param code the unique identifier for the projection, e.g. "EPSG:1234" 025 * @param cacheDir unused 026 * @deprecated use {@link #SingleProjectionChoice(String, String, String)} instead 027 */ 028 @Deprecated 029 public SingleProjectionChoice(String name, String id, String code, String cacheDir) { 030 this(name, id, code); 031 } 032 033 /** 034 * Constructs a new {@code SingleProjectionChoice}. 035 * 036 * @param name short name of the projection choice as shown in the GUI 037 * @param id unique identifier for the projection choice, e.g. "core:thisproj" 038 * @param code the unique identifier for the projection, e.g. "EPSG:1234" 039 */ 040 public SingleProjectionChoice(String name, String id, String code) { 041 super(name, id); 042 this.code = code; 043 } 044 045 @Override 046 public JPanel getPreferencePanel(ActionListener listener) { 047 return new JPanel(); 048 } 049 050 @Override 051 public String[] allCodes() { 052 return new String[] {code}; 053 } 054 055 @Override 056 public void setPreferences(Collection<String> args) { 057 // Do nothing 058 } 059 060 @Override 061 public Collection<String> getPreferences(JPanel p) { 062 return Collections.emptyList(); 063 } 064 065 @Override 066 public Collection<String> getPreferencesFromCode(String code) { 067 if (code.equals(this.code)) 068 return Collections.emptyList(); 069 else 070 return null; 071 } 072 073 @Override 074 public String getCurrentCode() { 075 return code; 076 } 077 078 @Override 079 public String getProjectionName() { 080 return name; // the same name as the projection choice 081 } 082 083}