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 */ 026 public SingleProjectionChoice(String name, String id, String code) { 027 super(name, id); 028 this.code = code; 029 } 030 031 @Override 032 public JPanel getPreferencePanel(ActionListener listener) { 033 return new JPanel(); 034 } 035 036 @Override 037 public String[] allCodes() { 038 return new String[] {code}; 039 } 040 041 @Override 042 public void setPreferences(Collection<String> args) { 043 // Do nothing 044 } 045 046 @Override 047 public Collection<String> getPreferences(JPanel p) { 048 return Collections.emptyList(); 049 } 050 051 @Override 052 public Collection<String> getPreferencesFromCode(String code) { 053 if (code.equals(this.code)) 054 return Collections.emptyList(); 055 else 056 return null; 057 } 058 059 @Override 060 public String getCurrentCode() { 061 return code; 062 } 063 064 @Override 065 public String getProjectionName() { 066 return name; // the same name as the projection choice 067 } 068 069}