// License: GPL. For details, see LICENSE file. package org.openstreetmap.josm.gui.preferences.projection; import static org.openstreetmap.josm.tools.I18n.tr; import java.awt.BorderLayout; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionListener; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.LinkedList; import java.util.List; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.plaf.basic.BasicComboBoxEditor; import org.openstreetmap.josm.Main; import org.openstreetmap.josm.data.projection.CustomProjection; import org.openstreetmap.josm.data.projection.Projection; import org.openstreetmap.josm.data.projection.ProjectionConfigurationException; import org.openstreetmap.josm.data.projection.Projections; import org.openstreetmap.josm.gui.ExtendedDialog; import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionListItem; import org.openstreetmap.josm.gui.widgets.AbstractTextComponentValidator; import org.openstreetmap.josm.gui.widgets.HistoryComboBox; import org.openstreetmap.josm.gui.widgets.HtmlPanel; import org.openstreetmap.josm.gui.widgets.JosmTextField; import org.openstreetmap.josm.tools.GBC; import org.openstreetmap.josm.tools.ImageProvider; import org.openstreetmap.josm.tools.Logging; /** * ProjectionChoice where a CRS can be defined using various parameters. *
* The configuration string mimics the syntax of the PROJ.4 project and should
* be mostly compatible.
* @see CustomProjection
*/
public class CustomProjectionChoice extends AbstractProjectionChoice implements SubPrefsOptions {
private String pref;
/**
* Constructs a new {@code CustomProjectionChoice}.
*/
public CustomProjectionChoice() {
super(tr("Custom Projection"), /* NO-ICON */ "core:custom");
}
private static class PreferencePanel extends JPanel {
public JosmTextField input;
private HistoryComboBox cbInput;
PreferencePanel(String initialText, ActionListener listener) {
build(initialText, listener);
}
private void build(String initialText, final ActionListener listener) {
input = new JosmTextField(30);
cbInput = new HistoryComboBox();
cbInput.setPrototypeDisplayValue(new AutoCompletionListItem("xxxx"));
cbInput.setEditor(new BasicComboBoxEditor() {
@Override
protected JosmTextField createEditorComponent() {
return input;
}
});
List
").append(tr("Supported values:")).append(' ')
.append(Projections.listProjs())
.append("
+lat_0=..., +lat_1=..., +lat_2=... - ").append(tr("Projection parameters"))
.append("
+x_0=..., +y_0=... - ").append(tr("False easting and false northing"))
.append("
+lon_0=... - ").append(tr("Central meridian"))
.append("
+k_0=... - ").append(tr("Scaling factor"))
.append("
+ellps=... - ").append(tr("Ellipsoid name"))
.append("
").append(tr("Supported values:")).append(' ')
.append(Projections.listEllipsoids())
.append("
+a=..., +b=..., +rf=..., +f=..., +es=... - ").append(tr("Ellipsoid parameters"))
.append("
+datum=... - ").append(tr("Datum name"))
.append("
").append(tr("Supported values:")).append(' ')
.append(Projections.listDatums())
.append("
+towgs84=... - ").append(tr("3 or 7 term datum transform parameters"))
.append("
+nadgrids=... - ").append(tr("NTv2 grid file"))
.append("
").append(tr("Built-in:")).append(' ')
.append(Projections.listNadgrids())
.append("
+bounds=minlon,minlat,maxlon,maxlat - ").append(tr("Projection bounds (in degrees)"))
.append("
+wmssrs=EPSG:123456 - ").append(tr("Sets the SRS=... parameter in the WMS request"))
.append("
");
return new HtmlPanel(s.toString());
}
}
@Override
public void setPreferences(Collection