Changeset 32652 in osm for applications/editors/josm
- Timestamp:
- 2016-07-14T15:18:07+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/mapillary
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/build.gradle
r32631 r32652 176 176 177 177 task debugJosm(type: JavaExec) { 178 classpath = sourceSets.main.runtimeClasspath 179 main = 'JOSM' 180 args '--offline=josm_website' 181 jvmArgs "-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006", "-Djosm.home=$buildDir/.josm" 182 178 classpath = sourceSets.main.runtimeClasspath 179 main = 'JOSM' 180 args '--offline=josm_website' 181 jvmArgs "-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006", "-Djosm.home=$buildDir/.josm" 183 182 } 184 183 debugJosm.dependsOn installPlugin -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r32574 r32652 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.mapillary; 3 4 import static org.openstreetmap.josm.tools.I18n.marktr; 5 import static org.openstreetmap.josm.tools.I18n.tr; 3 6 4 7 import java.awt.AlphaComposite; … … 53 56 import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandDelete; 54 57 import org.openstreetmap.josm.plugins.mapillary.io.download.MapillaryDownloader; 58 import org.openstreetmap.josm.plugins.mapillary.io.download.MapillaryDownloader.DOWNLOAD_MODE; 55 59 import org.openstreetmap.josm.plugins.mapillary.mode.AbstractMode; 56 60 import org.openstreetmap.josm.plugins.mapillary.mode.JoinMode; … … 58 62 import org.openstreetmap.josm.plugins.mapillary.utils.MapViewGeometryUtil; 59 63 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils; 60 61 import static org.openstreetmap.josm.tools.I18n.marktr;62 import static org.openstreetmap.josm.tools.I18n.tr;63 64 64 65 /** … … 110 111 Main.getLayerManager().addLayer(this); 111 112 Main.getLayerManager().addActiveLayerChangeListener(this); 112 if (Main.getLayerManager().getEditLayer() != null) 113 if (Main.getLayerManager().getEditLayer() != null) { 113 114 Main.getLayerManager().getEditLayer().data.addDataSetListener(this); 114 if (MapillaryDownloader.getMode() == MapillaryDownloader.MODES.Automatic) 115 } 116 if (MapillaryDownloader.getMode() == DOWNLOAD_MODE.OSM_AREA) { 115 117 MapillaryDownloader.automaticDownload(); 116 if (MapillaryDownloader.getMode() == MapillaryDownloader.MODES.Semiautomatic) 118 } 119 if (MapillaryDownloader.getMode() == DOWNLOAD_MODE.VISIBLE_AREA) { 117 120 this.mode.zoomChanged(); 121 } 118 122 } 119 123 // Does not execute when in headless mode 120 124 if (MapillaryPlugin.getExportMenu() != null) { 121 125 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getExportMenu(), true); 122 if (!MapillaryMainDialog.getInstance().isShowing()) 126 if (!MapillaryMainDialog.getInstance().isShowing()) { 123 127 MapillaryMainDialog.getInstance().getButton().doClick(); 128 } 124 129 } 125 130 createHatchTexture(); … … 132 137 } 133 138 134 if (Main.main != null) 139 if (Main.main != null) { 135 140 MapillaryData.dataUpdated(); 141 } 136 142 } 137 143 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
r32593 r32652 32 32 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog; 33 33 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryPreferenceSetting; 34 import org.openstreetmap.josm.plugins.mapillary.io.download.MapillaryDownloader ;34 import org.openstreetmap.josm.plugins.mapillary.io.download.MapillaryDownloader.DOWNLOAD_MODE; 35 35 import org.openstreetmap.josm.plugins.mapillary.oauth.MapillaryUser; 36 36 import org.openstreetmap.josm.tools.ImageProvider; 37 import org.openstreetmap.josm.plugins.mapillary.io.download.MapillaryDownloader; 37 38 38 39 /** … … 145 146 } 146 147 147 if (Main.pref.get("mapillary.access-token") == null) 148 if (Main.pref.get("mapillary.access-token") == null) { 148 149 MapillaryUser.setTokenValid(false); 150 } 151 // Normalize download mode preference setting 152 Main.pref.put( 153 "mapillary.download-mode", 154 DOWNLOAD_MODE.fromPrefId(Main.pref.get("mapillary.download-mode")).getPrefId() 155 ); 149 156 } 150 157 … … 225 232 Main.map.addToggleDialog(MapillaryFilterDialog.getInstance(), false); 226 233 setMenuEnabled(downloadMenu, true); 227 if (MapillaryDownloader.getMode() == MapillaryDownloader.MODES.Manual)234 if (MapillaryDownloader.getMode() == DOWNLOAD_MODE.MANUAL_ONLY) 228 235 setMenuEnabled(downloadViewMenu, true); 229 236 setMenuEnabled(importMenu, true); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java
r32591 r32652 29 29 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting; 30 30 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin; 31 import org.openstreetmap.josm.plugins.mapillary.io.download.MapillaryDownloader ;31 import org.openstreetmap.josm.plugins.mapillary.io.download.MapillaryDownloader.DOWNLOAD_MODE; 32 32 import org.openstreetmap.josm.plugins.mapillary.oauth.MapillaryLoginListener; 33 33 import org.openstreetmap.josm.plugins.mapillary.oauth.MapillaryUser; … … 48 48 public class MapillaryPreferenceSetting implements SubPreferenceSetting, MapillaryLoginListener { 49 49 private final JComboBox<String> downloadModeComboBox = new JComboBox<>(new String[]{ 50 MapillaryDownloader.MODES.Automatic.toString(),51 MapillaryDownloader.MODES.Semiautomatic.toString(),52 MapillaryDownloader.MODES.Manual.toString()50 DOWNLOAD_MODE.VISIBLE_AREA.getLabel(), 51 DOWNLOAD_MODE.OSM_AREA.getLabel(), 52 DOWNLOAD_MODE.MANUAL_ONLY.getLabel() 53 53 }); 54 54 private final JCheckBox displayHour = new JCheckBox(I18n.tr("Display hour when the picture was taken")); … … 102 102 mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 103 103 104 // Sets the value of the ComboBox. 105 String downloadMode = Main.pref.get("mapillary.download-mode"); 106 if (MapillaryDownloader.MODES.Automatic.toString().equals(downloadMode) 107 || MapillaryDownloader.MODES.Semiautomatic.toString().equals(downloadMode) 108 || MapillaryDownloader.MODES.Manual.toString().equals(downloadMode)) { 109 downloadModeComboBox.setSelectedItem(Main.pref.get("mapillary.download-mode")); 110 } 104 downloadModeComboBox.setSelectedItem(DOWNLOAD_MODE.fromPrefId(Main.pref.get("mapillary.download-mode")).getLabel()); 105 111 106 JPanel downloadModePanel = new JPanel(); 112 107 downloadModePanel.add(new JLabel(I18n.tr("Download mode"))); … … 170 165 171 166 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getDownloadViewMenu(), false); 172 if (this.downloadModeComboBox.getSelectedItem().equals(MapillaryDownloader.MODES.Automatic.toString())) {173 Main.pref.put("mapillary.download-mode", MapillaryDownloader.MODES.Automatic.toString());174 }175 if (this.downloadModeComboBox.getSelectedItem().equals(MapillaryDownloader.MODES.Semiautomatic.toString())) {176 Main.pref.put("mapillary.download-mode", MapillaryDownloader.MODES.Semiautomatic.toString());177 }178 if (this.downloadModeComboBox.getSelectedItem().equals(MapillaryDownloader.MODES.Manual.toString())) {179 Main.pref.put("mapillary.download-mode", MapillaryDownloader.MODES.Manual.toString());180 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getDownloadViewMenu(), true);181 }167 Main.pref.put( 168 "mapillary.download-mode", 169 DOWNLOAD_MODE.fromLabel(downloadModeComboBox.getSelectedItem().toString()).getPrefId() 170 ); 171 MapillaryPlugin.setMenuEnabled( 172 MapillaryPlugin.getDownloadViewMenu(), 173 DOWNLOAD_MODE.MANUAL_ONLY.getPrefId().equals( 174 Main.pref.get("mapillary.download-mode", DOWNLOAD_MODE.getDefault().getPrefId()) 175 ) 176 ); 182 177 Main.pref.put("mapillary.display-hour", this.displayHour.isSelected()); 183 178 Main.pref.put("mapillary.format-24", this.format24.isSelected()); … … 198 193 * 199 194 */ 200 p ublicclass LoginAction extends AbstractAction {195 private class LoginAction extends AbstractAction { 201 196 private static final long serialVersionUID = -3908477563072057344L; 202 197 private final transient MapillaryLoginListener callback; … … 224 219 * 225 220 */ 226 p ublicclass LogoutAction extends AbstractAction {221 private class LogoutAction extends AbstractAction { 227 222 228 223 private static final long serialVersionUID = 3434780936404707219L; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java
r32378 r32652 18 18 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; 19 19 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin; 20 import org.openstreetmap.josm.tools.I18n; 20 21 21 22 /** … … 29 30 30 31 /** Possible download modes. */ 31 public enum MODES {Automatic, Semiautomatic, Manual} 32 public enum DOWNLOAD_MODE { 33 VISIBLE_AREA("visibleArea", I18n.tr("everything in the visible area")), 34 OSM_AREA("osmArea", I18n.tr("areas with downloaded OSM-data")), 35 MANUAL_ONLY("manualOnly", I18n.tr("only when manually requested")); 36 37 private String prefId; 38 private String label; 39 40 private DOWNLOAD_MODE(String prefId, String label) { 41 this.prefId = prefId; 42 this.label = label; 43 } 44 45 public String getPrefId() { 46 return prefId; 47 } 48 49 public String getLabel() { 50 return label; 51 } 52 53 public static DOWNLOAD_MODE fromPrefId(String prefId) { 54 if (MANUAL_ONLY.getPrefId().equals(prefId) || "Manual".equals(prefId)) { 55 return MANUAL_ONLY; 56 } 57 if (OSM_AREA.getPrefId().equals(prefId) || "Automatic".equals(prefId)) { 58 return OSM_AREA; 59 } 60 if (VISIBLE_AREA.getPrefId().equals(prefId) || "Semiautomatic".equals(prefId)) { 61 return VISIBLE_AREA; 62 } 63 return getDefault(); 64 } 65 public static DOWNLOAD_MODE fromLabel(String label) { 66 if (MANUAL_ONLY.getLabel().equals(label)) { 67 return MANUAL_ONLY; 68 } 69 if (OSM_AREA.getLabel().equals(label)) { 70 return OSM_AREA; 71 } 72 if (VISIBLE_AREA.getLabel().equals(label)) { 73 return VISIBLE_AREA; 74 } 75 return getDefault(); 76 } 77 78 public static DOWNLOAD_MODE getDefault() { 79 return OSM_AREA; 80 } 81 } 32 82 33 83 /** All the Threads that have been run. Used to interrupt them properly. */ … … 73 123 * Returns the current download mode. 74 124 * 75 * @return the currently enabled of the available {@link MODES} 76 */ 77 public static MapillaryDownloader.MODES getMode() { 78 String downloadMode = Main.pref.get("mapillary.download-mode", MODES.Automatic.toString()); 79 boolean isTempSemiautomatic = MapillaryLayer.hasInstance() && MapillaryLayer.getInstance().tempSemiautomatic; 80 if (MODES.Semiautomatic.toString().equals(downloadMode) || isTempSemiautomatic) { 81 return MODES.Semiautomatic; 82 } else if (MODES.Manual.toString().equals(downloadMode)) { 83 return MODES.Manual; 84 } else if (MODES.Automatic.toString().equals(downloadMode)) { 85 return MODES.Automatic; 86 } else { 87 throw new IllegalStateException(); 88 } 125 * @return the currently enabled {@link DOWNLOAD_MODE} 126 */ 127 public static MapillaryDownloader.DOWNLOAD_MODE getMode() { 128 return MapillaryLayer.hasInstance() && MapillaryLayer.getInstance().tempSemiautomatic 129 ? DOWNLOAD_MODE.VISIBLE_AREA 130 : DOWNLOAD_MODE.fromPrefId(Main.pref.get("mapillary.download-mode")); 89 131 } 90 132 … … 98 140 */ 99 141 public static void completeView() { 100 if (getMode() != MODES.Semiautomatic && getMode() != MODES.Manual) 101 throw new IllegalStateException("Must be in semiautomatic or manual mode"); 142 if (getMode() != DOWNLOAD_MODE.VISIBLE_AREA && getMode() != DOWNLOAD_MODE.MANUAL_ONLY) { 143 throw new IllegalStateException("Download mode must be 'visible area' or 'manual only'"); 144 } 102 145 Bounds view = Main.map.mapView.getRealBounds(); 103 if (view.getArea() > MAX_AREA) 104 return; 105 if (isViewDownloaded(view)) 106 return; 146 if (view.getArea() > MAX_AREA) { 147 return; 148 } 149 if (isViewDownloaded(view)) { 150 return; 151 } 107 152 MapillaryLayer.getInstance().getData().getBounds().add(view); 108 153 getImages(view); … … 159 204 return; 160 205 } 161 if (getMode() != MODES.Automatic)206 if (getMode() != DOWNLOAD_MODE.OSM_AREA) 162 207 throw new IllegalStateException("Must be in automatic mode."); 163 208 for (Bounds bounds : Main.getLayerManager().getEditLayer().data -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/AbstractMode.java
r32383 r32652 66 66 @Override 67 67 public void zoomChanged() { 68 if (MapillaryDownloader.getMode() == MapillaryDownloader. MODES.Semiautomatic) {68 if (MapillaryDownloader.getMode() == MapillaryDownloader.DOWNLOAD_MODE.VISIBLE_AREA) { 69 69 if (!semiautomaticThread.isAlive()) 70 70 semiautomaticThread.start(); -
applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSettingTest.java
r32591 r32652 7 7 import java.awt.GraphicsEnvironment; 8 8 import java.lang.reflect.Field; 9 import java.util.HashMap;10 import java.util.Map;11 9 12 10 import javax.swing.JButton; … … 20 18 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 21 19 import org.openstreetmap.josm.plugins.mapillary.AbstractTest; 20 import org.openstreetmap.josm.plugins.mapillary.io.download.MapillaryDownloader.DOWNLOAD_MODE; 22 21 import org.openstreetmap.josm.tools.I18n; 23 22 … … 118 117 ((JComboBox<String>) getPrivateField(settings, "downloadModeComboBox")).setSelectedIndex(i); 119 118 settings.ok(); 120 assertEquals(Main.pref.get("mapillary.download-mode"), 121 ((JComboBox<String>) getPrivateField(settings, "downloadModeComboBox")).getSelectedItem()); 119 assertEquals( 120 Main.pref.get("mapillary.download-mode"), 121 DOWNLOAD_MODE.fromLabel( 122 ((JComboBox<String>) getPrivateField(settings, "downloadModeComboBox")).getSelectedItem().toString() 123 ).getPrefId() 124 ); 122 125 } 123 126 }
Note:
See TracChangeset
for help on using the changeset viewer.