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 | import org.openstreetmap.josm.data.projection.Projection;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * ProjectionChoice, that offers just one projection as choice.
|
---|
14 | *
|
---|
15 | * The GUI is an empty panel.
|
---|
16 | */
|
---|
17 | public class SingleProjectionChoice implements ProjectionChoice {
|
---|
18 |
|
---|
19 | private String id;
|
---|
20 | private String name;
|
---|
21 | private Projection projection;
|
---|
22 |
|
---|
23 | public SingleProjectionChoice(String id, String name, Projection projection) {
|
---|
24 | this.id = id;
|
---|
25 | this.name = name;
|
---|
26 | this.projection = projection;
|
---|
27 | }
|
---|
28 |
|
---|
29 | public SingleProjectionChoice(String id, Projection projection) {
|
---|
30 | this(id, projection.toString(), projection);
|
---|
31 | }
|
---|
32 |
|
---|
33 | @Override
|
---|
34 | public JPanel getPreferencePanel(ActionListener listener) {
|
---|
35 | return new JPanel();
|
---|
36 | }
|
---|
37 |
|
---|
38 | @Override
|
---|
39 | public String getId() {
|
---|
40 | return id;
|
---|
41 | }
|
---|
42 |
|
---|
43 | @Override
|
---|
44 | public String[] allCodes() {
|
---|
45 | return new String[] { projection.toCode() };
|
---|
46 | }
|
---|
47 |
|
---|
48 | @Override
|
---|
49 | public void setPreferences(Collection<String> args) {
|
---|
50 | }
|
---|
51 |
|
---|
52 | @Override
|
---|
53 | public Collection<String> getPreferences(JPanel p) {
|
---|
54 | return Collections.emptyList();
|
---|
55 | }
|
---|
56 |
|
---|
57 | @Override
|
---|
58 | public Projection getProjection() {
|
---|
59 | return projection;
|
---|
60 | }
|
---|
61 |
|
---|
62 | @Override
|
---|
63 | public String toString() {
|
---|
64 | return name;
|
---|
65 | }
|
---|
66 |
|
---|
67 | @Override
|
---|
68 | public Collection<String> getPreferencesFromCode(String code) {
|
---|
69 | if (code.equals(projection.toCode()))
|
---|
70 | return Collections.emptyList();
|
---|
71 | else
|
---|
72 | return null;
|
---|
73 | }
|
---|
74 | }
|
---|