Ignore:
Timestamp:
2015-06-15T13:07:24+02:00 (9 years ago)
Author:
nokutu
Message:

Button to center view on selected image, and if you click with center button in the picture zooms changes to 1:1 and then alternates between 1:1 and best fit

Location:
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java

    r31263 r31266  
    178178         */
    179179        public void setSelectedImage(MapillaryAbstractImage image, boolean zoom) {
     180                MapillaryAbstractImage oldImage = selectedImage;
    180181                selectedImage = image;
    181182                multiSelectedImages.clear();
     
    208209                        Main.map.mapView.repaint();
    209210                }
    210                 fireSelectedImageChanged();
    211         }
    212 
    213         private void fireSelectedImageChanged() {
     211                fireSelectedImageChanged(oldImage, selectedImage);
     212        }
     213
     214        private void fireSelectedImageChanged(MapillaryAbstractImage oldImage, MapillaryAbstractImage newImage) {
    214215                if (listeners.isEmpty())
    215216                        return;
    216217                for (MapillaryDataListener lis : listeners)
    217                         lis.selectedImageChanged();
     218                        lis.selectedImageChanged(oldImage, newImage);
    218219        }
    219220
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryDataListener.java

    r31263 r31266  
    66         * manually clicking on the icon.
    77         */
    8         public void selectedImageChanged();
     8        public void selectedImageChanged(MapillaryAbstractImage oldImage, MapillaryAbstractImage newImage);
    99
    1010}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java

    r31261 r31266  
    109109                MapillaryPlugin.setMenuEnabled(MapillaryPlugin.EXPORT_MENU, true);
    110110                MapillaryPlugin.setMenuEnabled(MapillaryPlugin.SIGNAL_MENU, true);
    111                 download();
    112111                Main.map.mapView.setActiveLayer(this);
    113112                Main.map.repaint();
     
    127126         * Downloads all images of the area covered by the OSM data.
    128127         */
    129         protected void download() {
     128        public void download() {
    130129                for (Bounds bounds : Main.map.mapView.getEditLayer().data
    131130                                .getDataSourceBounds()) {
     
    156155                                .setImage(null);
    157156                MapillaryLayer.INSTANCE = null;
     157                MapillaryData.INSTANCE = null;
    158158                MapillaryPlugin.setMenuEnabled(MapillaryPlugin.EXPORT_MENU, false);
    159159                MapillaryPlugin.setMenuEnabled(MapillaryPlugin.SIGNAL_MENU, false);
    160                 MapillaryData.INSTANCE = null;
     160                MapillaryPlugin.setMenuEnabled(MapillaryPlugin.ZOOM_MENU, false);
    161161                Main.map.mapView.removeMouseListener(mouseAdapter);
    162162                Main.map.mapView.removeMouseMotionListener(mouseAdapter);
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java

    r31261 r31266  
    5151        private final MapillaryImportAction importAction;
    5252        private final MapillarySignalAction signalAction;
     53        private final MapillaryZoomAction zoomAction;
    5354
    5455        public static JMenuItem DOWNLOAD_MENU;
     
    5657        public static JMenuItem IMPORT_MENU;
    5758        public static JMenuItem SIGNAL_MENU;
     59        public static JMenuItem ZOOM_MENU;
    5860
    5961        public MapillaryPlugin(PluginInformation info) {
     
    6365                importAction = new MapillaryImportAction();
    6466                signalAction = new MapillarySignalAction();
     67                zoomAction = new MapillaryZoomAction();
    6568
    6669                DOWNLOAD_MENU = MainMenu.add(Main.main.menu.imageryMenu,
     
    7275                SIGNAL_MENU = MainMenu.add(Main.main.menu.dataMenu, signalAction,
    7376                                false);
     77                ZOOM_MENU = MainMenu.add(Main.main.menu.viewMenu, zoomAction,
     78                                false);
    7479
    7580                EXPORT_MENU.setEnabled(false);
     
    7782                IMPORT_MENU.setEnabled(false);
    7883                SIGNAL_MENU.setEnabled(false);
     84                ZOOM_MENU.setEnabled(false);
    7985
    8086                MapView.addEditLayerChangeListener(this);
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryDownloadAction.java

    r31264 r31266  
    3131                                                KeyEvent.VK_M, Shortcut.ALT_CTRL_SHIFT), false,
    3232                                "mapillaryDownload", false);
     33                this.setEnabled(false);
    3334        }
    3435
     
    3637        public void actionPerformed(ActionEvent arg0) {
    3738                this.layer = null;
    38                 if (Main.map == null || Main.map.mapView == null
    39                                 || Main.map.mapView.getEditLayer() == null)
    40                         return;
    4139                for (Layer layer : Main.map.mapView.getAllLayers())
    4240                        if (layer instanceof MapillaryLayer)
    4341                                this.layer = (MapillaryLayer) layer;
    4442
    45                 if (this.layer == null)
     43                if (this.layer == null) {
    4644                        layer = new MapillaryLayer();
    47                 else {
     45                        layer.download();
     46                } else {
    4847                        if (Main.map.mapView.getActiveLayer() != layer)
    4948                                Main.map.mapView.setActiveLayer(layer);
     
    5352                }
    5453        }
    55 
    5654}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryExportAction.java

    r31264 r31266  
    3939                                                "Export Mapillary", tr("Export Mapillary pictures"),
    4040                                                KeyEvent.VK_M, Shortcut.NONE), false, "mapillaryExport", false);
     41                this.setEnabled(false);
    4142        }
    4243
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java

    r31261 r31266  
    4040                                                KeyEvent.VK_M, Shortcut.NONE), false,
    4141                                "mapillaryImport", false);
     42                this.setEnabled(false);
    4243        }
    4344
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillarySignalAction.java

    r31263 r31266  
    2323                super(tr("Switch signal mode"), new ImageProvider("icon24signal.png"),
    2424                                tr("Switch signal mode"), Shortcut.registerShortcut(
    25                                                 "Mapillary signal", tr("Switch signal mode on/off"),
     25                                                "Mapillary signal", tr("Switch Mapillary plugin's signal mode on/off"),
    2626                                                KeyEvent.VK_M, Shortcut.NONE), false,
    2727                                "mapillarySignal", false);
     28                this.setEnabled(false);
    2829        }
    2930
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryImageDisplay.java

    r31256 r31266  
    3232
    3333        private static final int DRAG_BUTTON = 3;
     34        private static final int OPTION_BUTTON = 2;
    3435        private static final int ZOOM_BUTTON = 1;
    3536
     
    138139                        if (image == null)
    139140                                return;
    140                         if (e.getButton() != DRAG_BUTTON)
     141                        if (e.getButton() == OPTION_BUTTON) {
     142                                if (!MapillaryImageDisplay.this.visibleRect
     143                                                .equals(new Rectangle(0, 0, image.getWidth(null), image
     144                                                                .getHeight(null))))
     145                                        // Zooms to 1:1
     146                                        MapillaryImageDisplay.this.visibleRect = new Rectangle(0,
     147                                                        0, image.getWidth(null), image.getHeight(null));
     148                                else
     149                                        // Zooms to best fit.
     150                                        MapillaryImageDisplay.this.visibleRect = new Rectangle(
     151                                                        0,
     152                                                        (image.getHeight(null) - (image.getWidth(null) * getHeight())
     153                                                                        / getWidth()) / 2, image.getWidth(null),
     154                                                        (image.getWidth(null) * getHeight()) / getWidth());
     155                                MapillaryImageDisplay.this.repaint();
     156                                return;
     157                        } else if (e.getButton() != DRAG_BUTTON)
    141158                                return;
    142159                        // Calculate the translation to set the clicked point the center of
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryToggleDialog.java

    r31264 r31266  
    382382
    383383        @Override
    384         public void selectedImageChanged() {
     384        public void selectedImageChanged(MapillaryAbstractImage oldImage, MapillaryAbstractImage newImage) {
    385385                setImage(MapillaryData.getInstance().getSelectedImage());
    386386                updateImage();
Note: See TracChangeset for help on using the changeset viewer.