Search in sources :

Example 1 with CoordinateSystemField

use of com.revolsys.swing.map.component.CoordinateSystemField in project com.revolsys.open by revolsys.

the class MapPanel method promptCoordinateSystem.

/**
 * Prompt for a coordinate system if the geometry factory does not have a coordinate system.
 * @author Paul Austin <paul.austin@revolsys.com>
 * @param geometryFactoryProxy
 * @param action
 */
public static <GFP extends GeometryFactoryProxy> void promptCoordinateSystem(final String title, final GFP geometryFactoryProxy, final Consumer<GeometryFactory> action) {
    if (geometryFactoryProxy.isHasCoordinateSystem()) {
        final GeometryFactory geometryFactory = geometryFactoryProxy.getGeometryFactory();
        action.accept(geometryFactory);
    } else {
        Invoke.later(() -> {
            final Project project = Project.get();
            final MapPanel mapPanel = project.getMapPanel();
            final int mapCoordinateSystemId = mapPanel.getCoordinateSystemId();
            final CoordinateSystemField coordinateSystemField = new CoordinateSystemField("coordinateSystem");
            coordinateSystemField.setSelectedItem(mapCoordinateSystemId);
            final JPanel fieldPanel = new BasePanel(new JLabel("Coordinate System"), coordinateSystemField);
            GroupLayouts.makeColumns(fieldPanel, 2, true);
            final ValueField valueField = new ValueField(fieldPanel);
            valueField.add(fieldPanel);
            valueField.showDialog();
            if (valueField.isSaved()) {
                final GeometryFactory geometryFactory = coordinateSystemField.getGeometryFactory();
                if (geometryFactory.isHasCoordinateSystem()) {
                    Invoke.background(title, () -> action.accept(geometryFactory));
                }
            }
        });
    }
}
Also used : Project(com.revolsys.swing.map.layer.Project) JPanel(javax.swing.JPanel) BasePanel(com.revolsys.swing.component.BasePanel) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) CoordinateSystemField(com.revolsys.swing.map.component.CoordinateSystemField) JLabel(javax.swing.JLabel) Point(com.revolsys.geometry.model.Point) ValueField(com.revolsys.swing.component.ValueField)

Aggregations

GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 Point (com.revolsys.geometry.model.Point)1 BasePanel (com.revolsys.swing.component.BasePanel)1 ValueField (com.revolsys.swing.component.ValueField)1 CoordinateSystemField (com.revolsys.swing.map.component.CoordinateSystemField)1 Project (com.revolsys.swing.map.layer.Project)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1