Changeset 16920 in josm for trunk


Ignore:
Timestamp:
2020-08-23T21:02:52+02:00 (4 years ago)
Author:
simon04
Message:

fix #7638 - Download dialog: add status bar with lat/lon of mouse cursor and selected download area (for experts)

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java

    r16913 r16920  
    6969    private static final StringProperty PROP_MAPSTYLE = new StringProperty("slippy_map_chooser.mapstyle", "Mapnik");
    7070    private static final BooleanProperty PROP_SHOWDLAREA = new BooleanProperty("slippy_map_chooser.show_downloaded_area", true);
     71
    7172    /**
    7273     * The property name used for the resize button.
     
    7475     */
    7576    public static final String RESIZE_PROP = SlippyMapBBoxChooser.class.getName() + ".resize";
     77
     78    /**
     79     * The property name used for the {@link org.openstreetmap.josm.data.coor.ILatLon} of the mouse cursor on the map.
     80     * @see #addPropertyChangeListener(java.beans.PropertyChangeListener)
     81     */
     82    public static final String CURSOR_COORDINATE_PROP = SlippyMapBBoxChooser.class.getName() + ".coordinate";
    7683
    7784    private final SizeButton iSizeButton;
     
    236243        PROP_SHOWDLAREA.put(this.showDownloadAreaButtonModel.isSelected());
    237244        this.repaint();
     245    }
     246
     247    /**
     248     * Handles a {@link SlippyMapControler#mouseMoved} event
     249     * @param point The point in the view
     250     */
     251    public void handleMouseMoved(Point point) {
     252        final ICoordinate coordinate = getPosition(point);
     253        final LatLon latLon = new LatLon(coordinate.getLat(), coordinate.getLon());
     254        firePropertyChange(CURSOR_COORDINATE_PROP, null, latLon);
    238255    }
    239256
  • trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapControler.java

    r16913 r16920  
    162162    @Override
    163163    public void mouseMoved(MouseEvent e) {
     164        iSlippyMapChooser.handleMouseMoved(e.getPoint());
    164165        iSlippyMapChooser.handleAttribution(e.getPoint(), false);
    165166    }
  • trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java

    r16918 r16920  
    66
    77import java.awt.BorderLayout;
     8import java.awt.Color;
    89import java.awt.Component;
    910import java.awt.Dimension;
     
    2425
    2526import javax.swing.AbstractAction;
     27import javax.swing.BorderFactory;
    2628import javax.swing.Box;
    2729import javax.swing.Icon;
     
    4042import org.openstreetmap.josm.actions.ExpertToggleAction;
    4143import org.openstreetmap.josm.data.Bounds;
     44import org.openstreetmap.josm.data.coor.ILatLon;
     45import org.openstreetmap.josm.data.coor.LatLon;
     46import org.openstreetmap.josm.data.coor.conversion.CoordinateFormatManager;
     47import org.openstreetmap.josm.data.coor.conversion.DMSCoordinateFormat;
     48import org.openstreetmap.josm.data.coor.conversion.ICoordinateFormat;
    4249import org.openstreetmap.josm.data.preferences.BooleanProperty;
    4350import org.openstreetmap.josm.data.preferences.IntegerProperty;
     
    5259import org.openstreetmap.josm.gui.util.GuiHelper;
    5360import org.openstreetmap.josm.gui.util.WindowGeometry;
     61import org.openstreetmap.josm.gui.widgets.ImageLabel;
    5462import org.openstreetmap.josm.io.NetworkManager;
    5563import org.openstreetmap.josm.io.OnlineResource;
     
    101109    protected final DownloadSourceTabs downloadSourcesTab = new DownloadSourceTabs();
    102110
     111    private final ImageLabel latText;
     112    private final ImageLabel lonText;
     113    private final ImageLabel bboxText;
     114    {
     115        final LatLon sample = new LatLon(90, 180);
     116        final ICoordinateFormat sampleFormat = DMSCoordinateFormat.INSTANCE;
     117        final Color background = new JPanel().getBackground();
     118        latText = new ImageLabel("lat", null, sampleFormat.latToString(sample).length(), background);
     119        lonText = new ImageLabel("lon", null, sampleFormat.lonToString(sample).length(), background);
     120        bboxText = new ImageLabel("name", null, sampleFormat.toString(sample, "").length() * 2, background);
     121    }
     122
    103123    protected JCheckBox cbStartup;
    104124    protected JCheckBox cbZoomToDownloadedData;
     
    158178
    159179        mainPanel.add(dialogSplit, GBC.eol().fill());
     180
     181        JPanel statusBarPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
     182        statusBarPanel.setBorder(BorderFactory.createLineBorder(Color.GRAY));
     183        statusBarPanel.add(latText);
     184        statusBarPanel.add(lonText);
     185        statusBarPanel.add(bboxText);
     186        mainPanel.add(statusBarPanel, GBC.eol().fill(GBC.HORIZONTAL));
     187        ExpertToggleAction.addVisibilitySwitcher(statusBarPanel);
    160188
    161189        cbStartup = new JCheckBox(tr("Open this dialog on startup"));
     
    283311            ds.boundingBoxChanged(b);
    284312        }
     313
     314        bboxText.setText(b == null ? "" : String.join("  ",
     315                CoordinateFormatManager.getDefaultFormat().toString(b.getMin(), " "),
     316                CoordinateFormatManager.getDefaultFormat().toString(b.getMax(), " ")));
     317    }
     318
     319    /**
     320     * Updates the coordinates after moving the mouse cursor
     321     * @param latLon the coordinates under the mouse cursor
     322     */
     323    public void mapCursorChanged(ILatLon latLon) {
     324        latText.setText(CoordinateFormatManager.getDefaultFormat().latToString(latLon));
     325        lonText.setText(CoordinateFormatManager.getDefaultFormat().lonToString(latLon));
    285326    }
    286327
  • trunk/src/org/openstreetmap/josm/gui/download/SlippyMapChooser.java

    r16892 r16920  
    1111
    1212import org.openstreetmap.josm.data.Bounds;
     13import org.openstreetmap.josm.data.coor.ILatLon;
    1314import org.openstreetmap.josm.gui.bbox.BBoxChooser;
    1415import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser;
     
    7374            // resize and center the DownloadDialog
    7475            iGui.setBounds((iScreenSize.width - w) / 2, (iScreenSize.height - h) / 2, w, h);
     76        } else if (evt.getPropertyName().equals(SlippyMapBBoxChooser.CURSOR_COORDINATE_PROP)) {
     77            iGui.mapCursorChanged((ILatLon) evt.getNewValue());
    7578        }
    7679    }
Note: See TracChangeset for help on using the changeset viewer.