Changeset 15733 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2020-01-19T21:21:52+01:00 (5 years ago)
Author:
simon04
Message:

see #17220 - LayerListDialog: show imagery offset in tooltip

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java

    r14866 r15733  
    1515import java.awt.event.KeyEvent;
    1616import java.awt.event.MouseEvent;
    17 import java.util.Formatter;
    1817import java.util.Locale;
    1918
     
    316315        private void updateOffsetIntl() {
    317316            if (layer != null) {
    318                 // Support projections with very small numbers (e.g. 4326)
    319                 int precision = ProjectionRegistry.getProjection().getDefaultZoomInPPD() >= 1.0 ? 2 : 7;
    320                 // US locale to force decimal separator to be '.'
    321                 try (Formatter us = new Formatter(Locale.US)) {
    322                     EastNorth displacement = layer.getDisplaySettings().getDisplacement();
    323                     tOffset.setText(us.format(new StringBuilder()
    324                         .append("%1.").append(precision).append("f; %1.").append(precision).append('f').toString(),
    325                         displacement.east(), displacement.north()).toString());
    326                 }
     317                // ROOT locale to force decimal separator to be '.'
     318                tOffset.setText(layer.getDisplaySettings().getDisplacementString(Locale.ROOT));
    327319            }
    328320        }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    r15651 r15733  
    2121import java.util.Arrays;
    2222import java.util.List;
     23import java.util.Locale;
    2324import java.util.concurrent.CopyOnWriteArrayList;
    2425
     
    7374import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
    7475import org.openstreetmap.josm.gui.layer.NativeScaleLayer;
     76import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings;
    7577import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings.DisplaySettingsChangeEvent;
    7678import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings.DisplaySettingsChangeListener;
     
    651653            Layer layer = (Layer) value;
    652654            if (layer instanceof AbstractTileSourceLayer<?>) {
    653                 if (EastNorth.ZERO.equals(((AbstractTileSourceLayer<?>) layer).getDisplaySettings().getDisplacement())) {
     655                final TileSourceDisplaySettings displaySettings = ((AbstractTileSourceLayer<?>) layer).getDisplaySettings();
     656                if (EastNorth.ZERO.equals(displaySettings.getDisplacement())) {
    654657                    cb.setSelected(false);
    655658                    cb.setEnabled(false); // TODO: allow reselecting checkbox and thereby setting the old offset again
     
    658661                    cb.setSelected(true);
    659662                    cb.setEnabled(true);
    660                     cb.setToolTipText(tr("layer has a user-defined offset (click to remove offset)"));
     663                    cb.setToolTipText(tr("layer has an offset of {0} (click to remove offset)",
     664                            displaySettings.getDisplacementString(Locale.getDefault())));
    661665                }
    662666
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileSourceDisplaySettings.java

    r14532 r15733  
    33
    44import java.util.HashMap;
     5import java.util.Locale;
    56import java.util.Map;
    67import java.util.concurrent.CopyOnWriteArrayList;
     
    197198
    198199    /**
     200     * Gets the displacement of the image formatted as a string
     201     * @param locale the locale used to format the decimals
     202     * @return the displacement string
     203     * @see #getDisplacement()
     204     * @since 15733
     205     */
     206    public String getDisplacementString(final Locale locale) {
     207        // Support projections with very small numbers (e.g. 4326)
     208        int precision = ProjectionRegistry.getProjection().getDefaultZoomInPPD() >= 1.0 ? 2 : 7;
     209        return String.format(locale, "%1." + precision + "f; %1." + precision + "f", getDx(), getDy());
     210    }
     211
     212    /**
    199213     * Sets an offset bookmark to use. Loads the displacement from the bookmark.
    200214     *
Note: See TracChangeset for help on using the changeset viewer.