Changeset 31404 in osm for applications/editors/josm/plugins/mapillary
- Timestamp:
- 2015-07-24T21:55:14+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/build.gradle
r31395 r31404 138 138 139 139 task runJosm(type: Exec) { 140 commandLine 'j osm'140 commandLine 'java', '-jar', '/home/nokutu/josm/core/dist/josm-custom.jar' 141 141 } 142 142 runJosm.dependsOn installPluginToJosm -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
r31401 r31404 29 29 private final List<MapillaryAbstractImage> multiSelectedImages; 30 30 31 private List<MapillaryDataListener> listeners = new CopyOnWriteArrayList<>();31 private CopyOnWriteArrayList<MapillaryDataListener> listeners = new CopyOnWriteArrayList<>(); 32 32 33 33 /** … … 52 52 } 53 53 return INSTANCE; 54 } 55 56 /** 57 * Destroys the unique instance. 58 */ 59 public void destroy() { 60 INSTANCE = null; 54 61 } 55 62 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31401 r31404 54 54 import java.util.List; 55 55 import java.util.ArrayList; 56 import java.util.concurrent.CopyOnWriteArrayList; 56 57 57 58 /** … … 83 84 84 85 /** The bounds of the areas for which the pictures have been downloaded */ 85 public ArrayList<Bounds> bounds;86 public CopyOnWriteArrayList<Bounds> bounds; 86 87 87 88 /** Mode of the layer */ … … 98 99 super(tr("Mapillary Images")); 99 100 data = MapillaryData.getInstance(); 100 bounds = new ArrayList<>();101 bounds = new CopyOnWriteArrayList<>(); 101 102 init(); 102 103 } … … 120 121 MapillaryMainDialog.getInstance().getButton().doClick(); 121 122 } 122 123 123 createHatchTexture(); 124 124 data.dataUpdated(); … … 138 138 } 139 139 this.mode = mode; 140 Main.map.mapView.setNewCursor(mode.cursor, this); 141 Main.map.mapView.addMouseListener(mode); 142 Main.map.mapView.addMouseMotionListener(mode); 143 NavigatableComponent.addZoomChangeListener(mode); 144 updateHelpText(); 140 if (mode != null) { 141 Main.map.mapView.setNewCursor(mode.cursor, this); 142 Main.map.mapView.addMouseListener(mode); 143 Main.map.mapView.addMouseMotionListener(mode); 144 NavigatableComponent.addZoomChangeListener(mode); 145 updateHelpText(); 146 } 145 147 } 146 148 … … 168 170 @Override 169 171 public void destroy() { 172 setMode(null); 173 MapillaryDownloader.stopAll(); 170 174 MapillaryMainDialog.getInstance().setImage(null); 171 175 MapillaryMainDialog.getInstance().updateImage(); 172 data.getImages().clear();173 MapillaryLayer.INSTANCE = null;174 MapillaryData.INSTANCE = null;175 176 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.EXPORT_MENU, false); 176 177 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.ZOOM_MENU, false); … … 180 181 if (Main.map.mapView.getEditLayer() != null) 181 182 Main.map.mapView.getEditLayer().data.removeDataSetListener(this); 183 MapillaryLayer.INSTANCE = null; 182 184 super.destroy(); 183 185 } … … 593 595 else 594 596 ret += tr("No images found"); 595 ret += " -- " + tr(mode.toString());596 597 if (mode != null) 598 ret += " -- " + tr(mode.toString()); 597 599 Main.map.statusLine.setHelpText(ret); 598 600 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java
r31401 r31404 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.util.concurrent.ArrayBlockingQueue; 5 6 import java.util.concurrent.ConcurrentHashMap; 6 import java.util.concurrent. Executor;7 import java.util.concurrent. Executors;7 import java.util.concurrent.ThreadPoolExecutor; 8 import java.util.concurrent.TimeUnit; 8 9 9 10 import javax.swing.JOptionPane; … … 34 35 public final static String CLIENT_ID = "NzNRM2otQkR2SHJzaXJmNmdQWVQ0dzo1YTA2NmNlODhlNWMwOTBm"; 35 36 /** Executor that will run the petitions */ 36 public final static Executor EXECUTOR = Executors.newSingleThreadExecutor(); 37 public final static ThreadPoolExecutor EXECUTOR = new ThreadPoolExecutor(1, 38 1, 100, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(50)); 37 39 38 40 /** … … 51 53 queryStringParts.put("max_lat", maxLatLon.lat()); 52 54 queryStringParts.put("max_lon", maxLatLon.lon()); 55 run(new MapillarySquareDownloadManagerThread(queryStringParts, 56 MapillaryLayer.getInstance())); 57 } 53 58 54 try { 55 EXECUTOR.execute(new MapillarySquareDownloadManagerThread( 56 queryStringParts, MapillaryLayer.getInstance())); 57 } catch (Exception e) { 58 Main.error(e); 59 } 59 private static void run(Thread t) { 60 EXECUTOR.execute(t); 60 61 } 61 62 … … 130 131 } 131 132 } 133 134 /** 135 * Stops all running threads. 136 */ 137 public static void stopAll() { 138 EXECUTOR.shutdownNow(); 139 } 132 140 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java
r31401 r31404 83 83 } 84 84 } catch (InterruptedException e) { 85 Main.error( e);85 Main.error("Mapillary download interrupted (probably because of closing the layer)."); 86 86 } 87 87 layer.updateHelpText(); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/AbstractMode.java
r31401 r31404 27 27 28 28 protected MapillaryData data = MapillaryData.getInstance(); 29 30 /** If in semiautomatic mode, the last Epoch time when there was a download */ 31 private long lastDownload; 29 private static final SemiautomaticThread semiautomaticThread = new SemiautomaticThread(); 32 30 33 31 /** … … 63 61 64 62 @Override 65 public synchronizedvoid zoomChanged() {63 public void zoomChanged() { 66 64 if (Main.pref.get("mapillary.download-mode").equals( 67 65 MapillaryDownloader.MODES[1]) 68 66 || MapillaryLayer.getInstance().TEMP_SEMIAUTOMATIC) { 69 if (Calendar.getInstance().getTimeInMillis() - lastDownload >= 2000) { 70 lastDownload = Calendar.getInstance().getTimeInMillis(); 71 MapillaryDownloader.completeView(); 72 } else { 73 new Thread() { 74 @Override 75 public synchronized void run() { 76 try { 77 wait(100); 78 } catch (InterruptedException e) { 79 } 80 zoomChanged(); 67 if (!semiautomaticThread.isAlive()) 68 semiautomaticThread.start(); 69 semiautomaticThread.moved(); 70 } 71 } 72 73 private static class SemiautomaticThread extends Thread { 74 75 /** If in semiautomatic mode, the last Epoch time when there was a download */ 76 private long lastDownload; 77 78 private boolean moved = false; 79 80 @Override 81 public void run() { 82 while (true) { 83 if (moved 84 && Calendar.getInstance().getTimeInMillis() - lastDownload >= 2000) { 85 lastDownload = Calendar.getInstance().getTimeInMillis(); 86 MapillaryDownloader.completeView(); 87 moved = false; 88 MapillaryData.getInstance().dataUpdated(); 89 } 90 synchronized (this) { 91 try { 92 wait(100); 93 } catch (InterruptedException e) { 94 Main.error(e); 81 95 } 82 } .start();96 } 83 97 } 98 } 99 100 public void moved() { 101 moved = true; 84 102 } 85 103 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java
r31401 r31404 18 18 import org.openstreetmap.josm.plugins.mapillary.commands.CommandTurnImage; 19 19 import org.openstreetmap.josm.plugins.mapillary.commands.MapillaryRecord; 20 import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryDownloader; 20 21 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog; 21 22 … … 41 42 public SelectMode() { 42 43 record = MapillaryRecord.getInstance(); 44 if (Main.pref.get("mapillary.download-mode").equals( 45 MapillaryDownloader.MODES[1])) 46 zoomChanged(); 43 47 } 44 48
Note:
See TracChangeset
for help on using the changeset viewer.