source: josm/trunk/src/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreference.java@ 13182

Last change on this file since 13182 was 13182, checked in by Don-vip, 6 years ago

see #15310 - cacheDir is unused, deprecate new methods

  • Property svn:eol-style set to native
File size: 24.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.preferences.projection;
3
4import static org.openstreetmap.josm.data.SystemOfMeasurement.ALL_SYSTEMS;
5import static org.openstreetmap.josm.tools.I18n.tr;
6
7import java.awt.Component;
8import java.awt.GridBagLayout;
9import java.awt.event.ActionListener;
10import java.util.ArrayList;
11import java.util.Collection;
12import java.util.Collections;
13import java.util.HashMap;
14import java.util.List;
15import java.util.Map;
16
17import javax.swing.BorderFactory;
18import javax.swing.JButton;
19import javax.swing.JLabel;
20import javax.swing.JOptionPane;
21import javax.swing.JPanel;
22import javax.swing.JSeparator;
23
24import org.openstreetmap.josm.Main;
25import org.openstreetmap.josm.actions.ExpertToggleAction;
26import org.openstreetmap.josm.data.Bounds;
27import org.openstreetmap.josm.data.SystemOfMeasurement;
28import org.openstreetmap.josm.data.coor.conversion.CoordinateFormatManager;
29import org.openstreetmap.josm.data.coor.conversion.ICoordinateFormat;
30import org.openstreetmap.josm.data.preferences.ListProperty;
31import org.openstreetmap.josm.data.preferences.StringProperty;
32import org.openstreetmap.josm.data.projection.CustomProjection;
33import org.openstreetmap.josm.data.projection.Projection;
34import org.openstreetmap.josm.data.projection.Projections;
35import org.openstreetmap.josm.gui.ExtendedDialog;
36import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
37import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
38import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
39import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
40import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
41import org.openstreetmap.josm.gui.widgets.JosmComboBox;
42import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
43import org.openstreetmap.josm.spi.preferences.Config;
44import org.openstreetmap.josm.tools.GBC;
45import org.openstreetmap.josm.tools.JosmRuntimeException;
46import org.openstreetmap.josm.tools.Logging;
47
48/**
49 * Projection preferences.
50 *
51 * How to add new Projections:
52 * - Find EPSG code for the projection.
53 * - Look up the parameter string for Proj4, e.g. on http://spatialreference.org/
54 * and add it to the file 'data/projection/epsg' in JOSM trunk
55 * - Search for official references and verify the parameter values. These
56 * documents are often available in the local language only.
57 * - Use {@link #registerProjectionChoice}, to make the entry known to JOSM.
58 *
59 * In case there is no EPSG code:
60 * - override {@link AbstractProjectionChoice#getProjection()} and provide
61 * a manual implementation of the projection. Use {@link CustomProjection}
62 * if possible.
63 */
64public class ProjectionPreference implements SubPreferenceSetting {
65
66 /**
67 * Factory used to create a new {@code ProjectionPreference}.
68 */
69 public static class Factory implements PreferenceSettingFactory {
70 @Override
71 public PreferenceSetting createPreferenceSetting() {
72 return new ProjectionPreference();
73 }
74 }
75
76 private static final List<ProjectionChoice> projectionChoices = new ArrayList<>();
77 private static final Map<String, ProjectionChoice> projectionChoicesById = new HashMap<>();
78
79 /**
80 * WGS84: Directly use latitude / longitude values as x/y.
81 */
82 public static final ProjectionChoice wgs84 = registerProjectionChoice(tr("WGS84 Geographic"), "core:wgs84", 4326);
83
84 /**
85 * Mercator Projection.
86 *
87 * The center of the mercator projection is always the 0 grad coordinate.
88 *
89 * See also USGS Bulletin 1532 (http://pubs.usgs.gov/bul/1532/report.pdf)
90 * initially EPSG used 3785 but that has been superseded by 3857, see https://www.epsg-registry.org/
91 */
92 public static final ProjectionChoice mercator = registerProjectionChoice(tr("Mercator"), "core:mercator", 3857);
93
94 /**
95 * Lambert conic conform 4 zones using the French geodetic system NTF.
96 *
97 * This newer version uses the grid translation NTF&lt;-&gt;RGF93 provided by IGN for a submillimetric accuracy.
98 * (RGF93 is the French geodetic system similar to WGS84 but not mathematically equal)
99 *
100 * Source: http://geodesie.ign.fr/contenu/fichiers/Changement_systeme_geodesique.pdf
101 */
102 public static final ProjectionChoice lambert = new LambertProjectionChoice();
103
104 /**
105 * French departements in the Caribbean Sea and Indian Ocean.
106 *
107 * Using the UTM transvers Mercator projection and specific geodesic settings.
108 */
109 public static final ProjectionChoice utm_france_dom = new UTMFranceDOMProjectionChoice();
110
111 /**
112 * Lambert Conic Conform 9 Zones projection.
113 *
114 * As specified by the IGN in this document
115 * http://geodesie.ign.fr/contenu/fichiers/documentation/rgf93/cc9zones.pdf
116 */
117 public static final ProjectionChoice lambert_cc9 = new LambertCC9ZonesProjectionChoice();
118
119 static {
120
121 /************************
122 * Global projections.
123 */
124
125 /**
126 * UTM.
127 */
128 registerProjectionChoice(new UTMProjectionChoice());
129
130 /************************
131 * Regional - alphabetical order by country code.
132 */
133
134 /**
135 * Belgian Lambert 72 projection.
136 *
137 * As specified by the Belgian IGN in this document:
138 * http://www.ngi.be/Common/Lambert2008/Transformation_Geographic_Lambert_FR.pdf
139 *
140 * @author Don-vip
141 */
142 registerProjectionChoice(tr("Belgian Lambert 1972"), "core:belgianLambert1972", 31370); // BE
143
144 /**
145 * Belgian Lambert 2008 projection.
146 *
147 * As specified by the Belgian IGN in this document:
148 * http://www.ngi.be/Common/Lambert2008/Transformation_Geographic_Lambert_FR.pdf
149 *
150 * @author Don-vip
151 */
152 registerProjectionChoice(tr("Belgian Lambert 2008"), "core:belgianLambert2008", 3812); // BE
153
154 /**
155 * SwissGrid CH1903 / L03, see https://en.wikipedia.org/wiki/Swiss_coordinate_system.
156 *
157 * Actually, what we have here, is CH1903+ (EPSG:2056), but without
158 * the additional false easting of 2000km and false northing 1000 km.
159 *
160 * To get to CH1903, a shift file is required. So currently, there are errors
161 * up to 1.6m (depending on the location).
162 */
163 registerProjectionChoice(new SwissGridProjectionChoice()); // CH
164
165 registerProjectionChoice(new GaussKruegerProjectionChoice()); // DE
166
167 /**
168 * Estonian Coordinate System of 1997.
169 *
170 * Thanks to Johan Montagnat and its geoconv java converter application
171 * (https://www.i3s.unice.fr/~johan/gps/ , published under GPL license)
172 * from which some code and constants have been reused here.
173 */
174 registerProjectionChoice(tr("Lambert Zone (Estonia)"), "core:lambertest", 3301); // EE
175
176 /**
177 * Lambert conic conform 4 zones using the French geodetic system NTF.
178 *
179 * This newer version uses the grid translation NTF<->RGF93 provided by IGN for a submillimetric accuracy.
180 * (RGF93 is the French geodetic system similar to WGS84 but not mathematically equal)
181 *
182 * Source: http://geodesie.ign.fr/contenu/fichiers/Changement_systeme_geodesique.pdf
183 * @author Pieren
184 */
185 registerProjectionChoice(lambert); // FR
186
187 /**
188 * Lambert 93 projection.
189 *
190 * As specified by the IGN in this document
191 * http://geodesie.ign.fr/contenu/fichiers/documentation/rgf93/Lambert-93.pdf
192 * @author Don-vip
193 */
194 registerProjectionChoice(tr("Lambert 93 (France)"), "core:lambert93", 2154); // FR
195
196 /**
197 * Lambert Conic Conform 9 Zones projection.
198 *
199 * As specified by the IGN in this document
200 * http://geodesie.ign.fr/contenu/fichiers/documentation/rgf93/cc9zones.pdf
201 * @author Pieren
202 */
203 registerProjectionChoice(lambert_cc9); // FR
204
205 /**
206 * French departements in the Caribbean Sea and Indian Ocean.
207 *
208 * Using the UTM transvers Mercator projection and specific geodesic settings.
209 */
210 registerProjectionChoice(utm_france_dom); // FR
211
212 /**
213 * LKS-92/ Latvia TM projection.
214 *
215 * Based on data from spatialreference.org.
216 * http://spatialreference.org/ref/epsg/3059/
217 *
218 * @author Viesturs Zarins
219 */
220 registerProjectionChoice(tr("LKS-92 (Latvia TM)"), "core:tmerclv", 3059); // LV
221
222 /**
223 * Netherlands RD projection
224 *
225 * @author vholten
226 */
227 registerProjectionChoice(tr("Rijksdriehoekscoördinaten (Netherlands)"), "core:dutchrd", 28992); // NL
228
229 /**
230 * PUWG 1992 and 2000 are the official cordinate systems in Poland.
231 *
232 * They use the same math as UTM only with different constants.
233 *
234 * @author steelman
235 */
236 registerProjectionChoice(new PuwgProjectionChoice()); // PL
237
238 /**
239 * SWEREF99 13 30 projection. Based on data from spatialreference.org.
240 * http://spatialreference.org/ref/epsg/3008/
241 *
242 * @author Hanno Hecker
243 */
244 registerProjectionChoice(tr("SWEREF99 13 30 / EPSG:3008 (Sweden)"), "core:sweref99", 3008); // SE
245
246 /************************
247 * Projection by Code.
248 */
249 registerProjectionChoice(new CodeProjectionChoice());
250
251 /************************
252 * Custom projection.
253 */
254 registerProjectionChoice(new CustomProjectionChoice());
255 }
256
257 public static void registerProjectionChoice(ProjectionChoice c) {
258 projectionChoices.add(c);
259 projectionChoicesById.put(c.getId(), c);
260 for (String code : c.allCodes()) {
261 Projections.registerProjectionSupplier(code, () -> {
262 Collection<String> pref = c.getPreferencesFromCode(code);
263 c.setPreferences(pref);
264 try {
265 return c.getProjection();
266 } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
267 Logging.log(Logging.LEVEL_WARN, "Unable to get projection "+code+" with "+c+':', e);
268 return null;
269 }
270 });
271 }
272 }
273
274 /**
275 * Registers a new projection choice.
276 * @param name short name of the projection choice as shown in the GUI
277 * @param id short name of the projection choice as shown in the GUI
278 * @param epsg the unique numeric EPSG identifier for the projection
279 * @param cacheDir unused
280 * @return the registered {@link ProjectionChoice}
281 * @deprecated use {@link #registerProjectionChoice(String, String, Integer)} instead
282 */
283 @Deprecated
284 public static ProjectionChoice registerProjectionChoice(String name, String id, Integer epsg, String cacheDir) {
285 return registerProjectionChoice(name, id, epsg);
286 }
287
288 /**
289 * Registers a new projection choice.
290 * @param name short name of the projection choice as shown in the GUI
291 * @param id short name of the projection choice as shown in the GUI
292 * @param epsg the unique numeric EPSG identifier for the projection
293 * @return the registered {@link ProjectionChoice}
294 */
295 private static ProjectionChoice registerProjectionChoice(String name, String id, Integer epsg) {
296 ProjectionChoice pc = new SingleProjectionChoice(name, id, "EPSG:"+epsg);
297 registerProjectionChoice(pc);
298 return pc;
299 }
300
301 public static List<ProjectionChoice> getProjectionChoices() {
302 return Collections.unmodifiableList(projectionChoices);
303 }
304
305 private static String projectionChoice;
306
307 private static final StringProperty PROP_PROJECTION_DEFAULT = new StringProperty("projection.default", mercator.getId());
308 private static final StringProperty PROP_COORDINATES = new StringProperty("coordinates", null);
309 private static final ListProperty PROP_SUB_PROJECTION_DEFAULT = new ListProperty("projection.default.sub", null);
310 private static final String[] unitsValues = ALL_SYSTEMS.keySet().toArray(new String[ALL_SYSTEMS.size()]);
311 private static final String[] unitsValuesTr = new String[unitsValues.length];
312 static {
313 for (int i = 0; i < unitsValues.length; ++i) {
314 unitsValuesTr[i] = tr(unitsValues[i]);
315 }
316 }
317
318 /**
319 * Combobox with all projections available
320 */
321 private final JosmComboBox<ProjectionChoice> projectionCombo;
322
323 /**
324 * Combobox with all coordinate display possibilities
325 */
326 private final JosmComboBox<ICoordinateFormat> coordinatesCombo;
327
328 private final JosmComboBox<String> unitsCombo = new JosmComboBox<>(unitsValuesTr);
329
330 /**
331 * This variable holds the JPanel with the projection's preferences. If the
332 * selected projection does not implement this, it will be set to an empty
333 * Panel.
334 */
335 private JPanel projSubPrefPanel;
336 private final JPanel projSubPrefPanelWrapper = new JPanel(new GridBagLayout());
337
338 private final JLabel projectionCodeLabel = new JLabel(tr("Projection code"));
339 private final Component projectionCodeGlue = GBC.glue(5, 0);
340 private final JLabel projectionCode = new JLabel();
341 private final JLabel projectionNameLabel = new JLabel(tr("Projection name"));
342 private final Component projectionNameGlue = GBC.glue(5, 0);
343 private final JLabel projectionName = new JLabel();
344 private final JLabel bounds = new JLabel();
345
346 /**
347 * This is the panel holding all projection preferences
348 */
349 private final VerticallyScrollablePanel projPanel = new VerticallyScrollablePanel(new GridBagLayout());
350
351 /**
352 * The GridBagConstraints for the Panel containing the ProjectionSubPrefs.
353 * This is required twice in the code, creating it here keeps both occurrences
354 * in sync
355 */
356 private static final GBC projSubPrefPanelGBC = GBC.std().fill(GBC.BOTH).weight(1.0, 1.0);
357
358 public ProjectionPreference() {
359 this.projectionCombo = new JosmComboBox<>(
360 projectionChoices.toArray(new ProjectionChoice[projectionChoices.size()]));
361 this.coordinatesCombo = new JosmComboBox<>(
362 CoordinateFormatManager.getCoordinateFormats().toArray(new ICoordinateFormat[0]));
363 }
364
365 @Override
366 public void addGui(PreferenceTabbedPane gui) {
367 final ProjectionChoice pc = setupProjectionCombo();
368
369 for (int i = 0; i < coordinatesCombo.getItemCount(); ++i) {
370 if (coordinatesCombo.getItemAt(i).getId().equals(PROP_COORDINATES.get())) {
371 coordinatesCombo.setSelectedIndex(i);
372 break;
373 }
374 }
375
376 for (int i = 0; i < unitsValues.length; ++i) {
377 if (unitsValues[i].equals(SystemOfMeasurement.PROP_SYSTEM_OF_MEASUREMENT.get())) {
378 unitsCombo.setSelectedIndex(i);
379 break;
380 }
381 }
382
383 projPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
384 projPanel.add(new JLabel(tr("Projection method")), GBC.std().insets(5, 5, 0, 5));
385 projPanel.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));
386 projPanel.add(projectionCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5, 5, 5));
387 projPanel.add(projectionCodeLabel, GBC.std().insets(25, 5, 0, 5));
388 projPanel.add(projectionCodeGlue, GBC.std().fill(GBC.HORIZONTAL));
389 projPanel.add(projectionCode, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5, 5, 5));
390 projPanel.add(projectionNameLabel, GBC.std().insets(25, 5, 0, 5));
391 projPanel.add(projectionNameGlue, GBC.std().fill(GBC.HORIZONTAL));
392 projPanel.add(projectionName, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5, 5, 5));
393 projPanel.add(new JLabel(tr("Bounds")), GBC.std().insets(25, 5, 0, 5));
394 projPanel.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));
395 projPanel.add(bounds, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5, 5, 5));
396 projPanel.add(projSubPrefPanelWrapper, GBC.eol().fill(GBC.HORIZONTAL).insets(20, 5, 5, 5));
397
398 projectionCodeLabel.setLabelFor(projectionCode);
399 projectionNameLabel.setLabelFor(projectionName);
400
401 JButton btnSetAsDefault = new JButton(tr("Set as default"));
402 projPanel.add(btnSetAsDefault, GBC.eol().insets(5, 10, 5, 5));
403 btnSetAsDefault.addActionListener(e -> {
404 ProjectionChoice pc2 = (ProjectionChoice) projectionCombo.getSelectedItem();
405 String id = pc2.getId();
406 Collection<String> prefs = pc2.getPreferences(projSubPrefPanel);
407 setProjection(id, prefs, true);
408 pc2.setPreferences(prefs);
409 Projection proj = pc2.getProjection();
410 new ExtendedDialog(gui, tr("Default projection"), tr("OK"))
411 .setButtonIcons("ok")
412 .setIcon(JOptionPane.INFORMATION_MESSAGE)
413 .setContent(tr("Default projection has been set to ''{0}''", proj.toCode()))
414 .showDialog();
415 });
416 ExpertToggleAction.addVisibilitySwitcher(btnSetAsDefault);
417
418 projPanel.add(new JSeparator(), GBC.eol().fill(GBC.HORIZONTAL).insets(0, 5, 0, 10));
419 projPanel.add(new JLabel(tr("Display coordinates as")), GBC.std().insets(5, 5, 0, 5));
420 projPanel.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));
421 projPanel.add(coordinatesCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5, 5, 5));
422 projPanel.add(new JLabel(tr("System of measurement")), GBC.std().insets(5, 5, 0, 5));
423 projPanel.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));
424 projPanel.add(unitsCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0, 5, 5, 5));
425 projPanel.add(GBC.glue(1, 1), GBC.std().fill(GBC.HORIZONTAL).weight(1.0, 1.0));
426
427 gui.getMapPreference().addSubTab(this, tr("Map Projection"), projPanel.getVerticalScrollPane());
428
429 selectedProjectionChanged(pc);
430 }
431
432 private void updateMeta(ProjectionChoice pc) {
433 pc.setPreferences(pc.getPreferences(projSubPrefPanel));
434 Projection proj = pc.getProjection();
435 projectionCode.setText(proj.toCode());
436 projectionName.setText(proj.toString());
437 Bounds b = proj.getWorldBoundsLatLon();
438 ICoordinateFormat cf = CoordinateFormatManager.getDefaultFormat();
439 bounds.setText(cf.lonToString(b.getMin()) + ", " + cf.latToString(b.getMin()) + " : " +
440 cf.lonToString(b.getMax()) + ", " + cf.latToString(b.getMax()));
441 boolean showCode = true;
442 boolean showName = false;
443 if (pc instanceof SubPrefsOptions) {
444 showCode = ((SubPrefsOptions) pc).showProjectionCode();
445 showName = ((SubPrefsOptions) pc).showProjectionName();
446 }
447 projectionCodeLabel.setVisible(showCode);
448 projectionCodeGlue.setVisible(showCode);
449 projectionCode.setVisible(showCode);
450 projectionNameLabel.setVisible(showName);
451 projectionNameGlue.setVisible(showName);
452 projectionName.setVisible(showName);
453 }
454
455 @Override
456 public boolean ok() {
457 ProjectionChoice pc = (ProjectionChoice) projectionCombo.getSelectedItem();
458
459 String id = pc.getId();
460 Collection<String> prefs = pc.getPreferences(projSubPrefPanel);
461
462 setProjection(id, prefs, false);
463
464 if (PROP_COORDINATES.put(((ICoordinateFormat) coordinatesCombo.getSelectedItem()).getId())) {
465 CoordinateFormatManager.setCoordinateFormat((ICoordinateFormat) coordinatesCombo.getSelectedItem());
466 }
467
468 int i = unitsCombo.getSelectedIndex();
469 SystemOfMeasurement.setSystemOfMeasurement(unitsValues[i]);
470
471 return false;
472 }
473
474 public static void setProjection() {
475 setProjection(PROP_PROJECTION_DEFAULT.get(), PROP_SUB_PROJECTION_DEFAULT.get(), false);
476 }
477
478 /**
479 * Set projection.
480 * @param id id of the selected projection choice
481 * @param pref the configuration for the selected projection choice
482 * @param makeDefault true, if it is to be set as permanent default
483 * false, if it is to be set for the current session
484 * @since 12306
485 */
486 public static void setProjection(String id, Collection<String> pref, boolean makeDefault) {
487 ProjectionChoice pc = projectionChoicesById.get(id);
488
489 if (pc == null) {
490 JOptionPane.showMessageDialog(
491 Main.parent,
492 tr("The projection {0} could not be activated. Using Mercator", id),
493 tr("Error"),
494 JOptionPane.ERROR_MESSAGE
495 );
496 pref = null;
497 pc = mercator;
498 }
499 id = pc.getId();
500 Config.getPref().putList("projection.sub."+id, pref == null ? null : new ArrayList<>(pref));
501 if (makeDefault) {
502 PROP_PROJECTION_DEFAULT.put(id);
503 PROP_SUB_PROJECTION_DEFAULT.put(pref == null ? null : new ArrayList<>(pref));
504 } else {
505 projectionChoice = id;
506 }
507 pc.setPreferences(pref);
508 Projection proj = pc.getProjection();
509 Main.setProjection(proj);
510 }
511
512 /**
513 * Handles all the work related to update the projection-specific
514 * preferences
515 * @param pc the choice class representing user selection
516 */
517 private void selectedProjectionChanged(final ProjectionChoice pc) {
518 // Don't try to update if we're still starting up
519 int size = projPanel.getComponentCount();
520 if (size < 1)
521 return;
522
523 final ActionListener listener = e -> updateMeta(pc);
524
525 // Replace old panel with new one
526 projSubPrefPanelWrapper.removeAll();
527 projSubPrefPanel = pc.getPreferencePanel(listener);
528 projSubPrefPanelWrapper.add(projSubPrefPanel, projSubPrefPanelGBC);
529 projPanel.revalidate();
530 projSubPrefPanel.repaint();
531 updateMeta(pc);
532 }
533
534 /**
535 * Sets up projection combobox with default values and action listener
536 * @return the choice class for user selection
537 */
538 private ProjectionChoice setupProjectionCombo() {
539 String pcId = getCurrentProjectionChoiceId();
540 ProjectionChoice pc = null;
541 for (int i = 0; i < projectionCombo.getItemCount(); ++i) {
542 ProjectionChoice pc1 = projectionCombo.getItemAt(i);
543 pc1.setPreferences(getSubprojectionPreference(pc1.getId()));
544 if (pc1.getId().equals(pcId)) {
545 projectionCombo.setSelectedIndex(i);
546 selectedProjectionChanged(pc1);
547 pc = pc1;
548 }
549 }
550 // If the ProjectionChoice from the preferences is not available, it
551 // should have been set to Mercator at JOSM start.
552 if (pc == null)
553 throw new JosmRuntimeException("Couldn't find the current projection in the list of available projections!");
554
555 projectionCombo.addActionListener(e -> {
556 ProjectionChoice pc1 = (ProjectionChoice) projectionCombo.getSelectedItem();
557 selectedProjectionChanged(pc1);
558 });
559 return pc;
560 }
561
562 /**
563 * Get the id of the projection choice that is currently set.
564 * @return id of the projection choice that is currently set
565 */
566 public static String getCurrentProjectionChoiceId() {
567 return projectionChoice != null ? projectionChoice : PROP_PROJECTION_DEFAULT.get();
568 }
569
570 /**
571 * Get the preferences that have been selected the last time for the given
572 * projection choice.
573 * @param pcId id of the projection choice
574 * @return projection choice parameters that have been selected by the user
575 * the last time; null if user has never selected the given projection choice
576 */
577 public static Collection<String> getSubprojectionPreference(String pcId) {
578 return Config.getPref().getList("projection.sub."+pcId, null);
579 }
580
581 @Override
582 public boolean isExpert() {
583 return false;
584 }
585
586 @Override
587 public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
588 return gui.getMapPreference();
589 }
590
591 /**
592 * Selects the given projection.
593 * @param projection The projection to select.
594 * @since 5604
595 */
596 public void selectProjection(ProjectionChoice projection) {
597 if (projectionCombo != null && projection != null) {
598 projectionCombo.setSelectedItem(projection);
599 }
600 }
601}
Note: See TracBrowser for help on using the repository browser.