1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.preferences.projection;
|
---|
3 |
|
---|
4 | import java.awt.event.ActionListener;
|
---|
5 | import java.util.Collection;
|
---|
6 | import java.util.Collections;
|
---|
7 |
|
---|
8 | import javax.swing.JPanel;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * ProjectionChoice, that offers just one projection as choice.
|
---|
12 | *
|
---|
13 | * The GUI is an empty panel.
|
---|
14 | */
|
---|
15 | public class SingleProjectionChoice extends AbstractProjectionChoice {
|
---|
16 |
|
---|
17 | protected String code;
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * Constructs a new {@code SingleProjectionChoice}.
|
---|
21 | *
|
---|
22 | * @param name short name of the projection choice as shown in the GUI
|
---|
23 | * @param id unique identifier for the projection choice, e.g. "core:thisproj"
|
---|
24 | * @param code the unique identifier for the projection, e.g. "EPSG:1234"
|
---|
25 | * @param cacheDir a cache directory name
|
---|
26 | */
|
---|
27 | public SingleProjectionChoice(String name, String id, String code, String cacheDir) {
|
---|
28 | super(name, id, cacheDir);
|
---|
29 | this.code = code;
|
---|
30 | }
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Constructs a new {@code SingleProjectionChoice}.
|
---|
34 | *
|
---|
35 | * @param name short name of the projection choice as shown in the GUI
|
---|
36 | * @param id unique identifier for the projection choice, e.g. "core:thisproj"
|
---|
37 | * @param code the unique identifier for the projection, e.g. "EPSG:1234"
|
---|
38 | */
|
---|
39 | public SingleProjectionChoice(String name, String id, String code) {
|
---|
40 | super(name, id);
|
---|
41 | this.code = code;
|
---|
42 | }
|
---|
43 |
|
---|
44 | @Override
|
---|
45 | public JPanel getPreferencePanel(ActionListener listener) {
|
---|
46 | return new JPanel();
|
---|
47 | }
|
---|
48 |
|
---|
49 | @Override
|
---|
50 | public String[] allCodes() {
|
---|
51 | return new String[] { code };
|
---|
52 | }
|
---|
53 |
|
---|
54 | @Override
|
---|
55 | public void setPreferences(Collection<String> args) {
|
---|
56 | }
|
---|
57 |
|
---|
58 | @Override
|
---|
59 | public Collection<String> getPreferences(JPanel p) {
|
---|
60 | return Collections.emptyList();
|
---|
61 | }
|
---|
62 |
|
---|
63 | @Override
|
---|
64 | public Collection<String> getPreferencesFromCode(String code) {
|
---|
65 | if (code.equals(this.code))
|
---|
66 | return Collections.emptyList();
|
---|
67 | else
|
---|
68 | return null;
|
---|
69 | }
|
---|
70 |
|
---|
71 | @Override
|
---|
72 | public String getCurrentCode() {
|
---|
73 | return code;
|
---|
74 | }
|
---|
75 |
|
---|
76 | @Override
|
---|
77 | public String getProjectionName() {
|
---|
78 | return name; // the same name as the projection choice
|
---|
79 | }
|
---|
80 |
|
---|
81 | }
|
---|