Search in sources :

Example 21 with MapPanel

use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.

the class ZoomOverlay method panClear.

protected void panClear() {
    this.panImage = null;
    this.panX1 = -1;
    this.panY1 = -1;
    this.panX2 = -1;
    this.panY2 = -1;
    clearOverlayAction(ACTION_PAN);
    final MapPanel map = getMap();
    map.clearVisibleOverlay(this);
}
Also used : MapPanel(com.revolsys.swing.map.MapPanel)

Example 22 with MapPanel

use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.

the class GridLayer method zoomToSheet.

public void zoomToSheet() {
    final LayerGroup project = getProject();
    if (project != null) {
        final MapPanel map = getMapPanel();
        final RectangularMapGrid grid = getGrid();
        final String gridName = grid.getName();
        final String preferenceName = CaseConverter.toCapitalizedWords(gridName) + "Mapsheet";
        String mapsheet = PreferencesUtil.getString(getClass(), preferenceName);
        final String title = "Zoom to Mapsheet: " + getName();
        mapsheet = (String) JOptionPane.showInputDialog(map, new JLabel("<html><p>" + gridName + "</p><p>Enter mapsheet to zoom to.</p></html>"), title, JOptionPane.QUESTION_MESSAGE, null, null, mapsheet);
        zoomToSheet(mapsheet);
    }
}
Also used : MapPanel(com.revolsys.swing.map.MapPanel) JLabel(javax.swing.JLabel) LayerGroup(com.revolsys.swing.map.layer.LayerGroup) RectangularMapGrid(com.revolsys.gis.grid.RectangularMapGrid)

Example 23 with MapPanel

use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.

the class Project method saveSettingsWithPrompt.

public boolean saveSettingsWithPrompt() {
    if (isReadOnly()) {
        return true;
    } else {
        final MapPanel mapPanel = getMapPanel();
        final JLabel message = new JLabel("<html><body><p><b>Save changes to project?</b></p></body></html>");
        final int option = JOptionPane.showConfirmDialog(mapPanel, message, "Save Changes", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
        if (option == JOptionPane.CANCEL_OPTION) {
            return false;
        } else if (option == JOptionPane.NO_OPTION) {
            return true;
        } else {
            if (saveAllSettings()) {
                return true;
            } else {
                final JLabel message2 = new JLabel("<html><body><p>Saving project failed.</b></p>" + "<p><b>Do you want to ignore any changes and continue?</b></p></body></html>");
                final int option2 = JOptionPane.showConfirmDialog(mapPanel, message2, "Ignore Changes", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
                if (option2 == JOptionPane.CANCEL_OPTION) {
                    return false;
                } else {
                    return true;
                }
            }
        }
    }
}
Also used : MapPanel(com.revolsys.swing.map.MapPanel) JLabel(javax.swing.JLabel)

Example 24 with MapPanel

use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.

the class SelectMapScale method itemStateChanged.

@Override
public void itemStateChanged(final ItemEvent e) {
    final MapPanel map = getMap();
    if (map != null) {
        if (e.getStateChange() == ItemEvent.SELECTED) {
            double scale = map.getScale();
            final Object value = e.getItem();
            if (value instanceof Double) {
                scale = (Double) value;
            }
            map.setScale(scale);
        }
    }
}
Also used : MapPanel(com.revolsys.swing.map.MapPanel)

Example 25 with MapPanel

use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.

the class SelectMapScale method propertyChange.

@Override
public void propertyChange(final PropertyChangeEvent event) {
    final MapPanel map = getMap();
    if (map != null) {
        final String propertyName = event.getPropertyName();
        if ("scale".equals(propertyName)) {
            final double scale = map.getScale();
            double currentScale = 0;
            final Object currentValue = getSelectedItem();
            if (currentValue instanceof Number) {
                currentScale = ((Number) currentValue).doubleValue();
            } else if (Property.hasValue(currentValue)) {
                final String scaleString = currentValue.toString().replaceAll("1:", "").replaceAll("[^0-9\\.]+", "");
                if (Property.hasValue(scaleString)) {
                    try {
                        currentScale = Double.valueOf(scaleString);
                    } catch (final Throwable t) {
                    }
                }
            }
            final Number newValue = (Number) event.getNewValue();
            if (scale > 0 && Double.isFinite(scale)) {
                if (currentScale != newValue.doubleValue()) {
                    Invoke.later(() -> setSelectedItem(scale));
                }
            }
        }
    }
}
Also used : MapPanel(com.revolsys.swing.map.MapPanel)

Aggregations

MapPanel (com.revolsys.swing.map.MapPanel)32 Point (com.revolsys.geometry.model.Point)6 Viewport2D (com.revolsys.swing.map.Viewport2D)6 BoundingBox (com.revolsys.geometry.model.BoundingBox)4 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)4 LineString (com.revolsys.geometry.model.LineString)4 RecordDefinition (com.revolsys.record.schema.RecordDefinition)4 CloseLocation (com.revolsys.swing.map.overlay.CloseLocation)4 ArrayList (java.util.ArrayList)4 DataType (com.revolsys.datatype.DataType)3 FieldDefinition (com.revolsys.record.schema.FieldDefinition)3 Project (com.revolsys.swing.map.layer.Project)3 Set (java.util.Set)3 TreeMap (java.util.TreeMap)3 JLabel (javax.swing.JLabel)3 Geometry (com.revolsys.geometry.model.Geometry)2 RectangularMapGrid (com.revolsys.gis.grid.RectangularMapGrid)2 EnableCheck (com.revolsys.swing.action.enablecheck.EnableCheck)2 TabbedValuePanel (com.revolsys.swing.component.TabbedValuePanel)2 Layer (com.revolsys.swing.map.layer.Layer)2