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);
}
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);
}
}
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;
}
}
}
}
}
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);
}
}
}
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));
}
}
}
}
}
Aggregations