Changeset 31358 in osm for applications/editors/josm/plugins/mapillary
- Timestamp:
- 2015-07-09T11:57:53+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
r31357 r31358 163 163 */ 164 164 public void selectNext() { 165 if (getSelectedImage() instanceof MapillaryImage) { 166 if (getSelectedImage() == null) 167 return; 168 if (((MapillaryImage) getSelectedImage()).getSequence() == null) 169 return; 170 if (selectedImage instanceof MapillaryImage 171 && ((MapillaryImage) selectedImage).getSequence() != null) { 172 MapillaryAbstractImage tempImage = selectedImage; 173 while (tempImage.next() != null) { 174 tempImage = tempImage.next(); 175 if (tempImage.isVisible()) { 176 setSelectedImage(tempImage, 177 Main.pref.getBoolean("mapillary.move-to-picture", true)); 178 break; 179 } 180 } 165 if (getSelectedImage() == null) 166 return; 167 if (getSelectedImage().getSequence() == null) 168 return; 169 MapillaryAbstractImage tempImage = selectedImage; 170 while (tempImage.next() != null) { 171 tempImage = tempImage.next(); 172 if (tempImage.isVisible()) { 173 setSelectedImage(tempImage, Main.pref.getBoolean("mapillary.move-to-picture", true)); 174 break; 181 175 } 182 176 } … … 189 183 */ 190 184 public void selectPrevious() { 191 if (getSelectedImage() instanceof MapillaryImage) { 192 if (getSelectedImage() == null) 193 return; 194 if (((MapillaryImage) getSelectedImage()).getSequence() == null) 195 throw new IllegalStateException(); 196 if (selectedImage instanceof MapillaryImage 197 && ((MapillaryImage) selectedImage).getSequence() != null) { 198 MapillaryAbstractImage tempImage = selectedImage; 199 while (tempImage.previous() != null) { 200 tempImage = tempImage.previous(); 201 if (tempImage.isVisible()) { 202 setSelectedImage(tempImage, 203 Main.pref.getBoolean("mapillary.move-to-picture", true)); 204 break; 205 } 206 } 185 if (getSelectedImage() == null) 186 return; 187 if (getSelectedImage().getSequence() == null) 188 throw new IllegalStateException(); 189 MapillaryAbstractImage tempImage = selectedImage; 190 while (tempImage.previous() != null) { 191 tempImage = tempImage.previous(); 192 if (tempImage.isVisible()) { 193 setSelectedImage(tempImage, Main.pref.getBoolean("mapillary.move-to-picture", true)); 194 break; 207 195 } 208 196 } … … 242 230 // Donwloadins thumbnails of surrounding pictures. 243 231 if (mapillaryImage.next() != null) { 244 new MapillaryCache(((MapillaryImage) mapillaryImage.next()).getKey(), 245 MapillaryCache.Type.THUMBNAIL).submit(this, false);232 new MapillaryCache(((MapillaryImage) mapillaryImage.next()).getKey(), MapillaryCache.Type.THUMBNAIL).submit( 233 this, false); 246 234 if (mapillaryImage.next().next() != null) 247 new MapillaryCache(((MapillaryImage) mapillaryImage.next().next()).getKey(), 248 MapillaryCache.Type.THUMBNAIL).submit(this, false);235 new MapillaryCache(((MapillaryImage) mapillaryImage.next().next()).getKey(), MapillaryCache.Type.THUMBNAIL) 236 .submit(this, false); 249 237 } 250 238 if (mapillaryImage.previous() != null) { 251 new MapillaryCache(((MapillaryImage) mapillaryImage.previous()).getKey(), 252 MapillaryCache.Type.THUMBNAIL).submit(this, false);239 new MapillaryCache(((MapillaryImage) mapillaryImage.previous()).getKey(), MapillaryCache.Type.THUMBNAIL) 240 .submit(this, false); 253 241 if (mapillaryImage.previous().previous() != null) 254 242 new MapillaryCache(((MapillaryImage) mapillaryImage.previous().previous()).getKey(), … … 258 246 } 259 247 if (zoom) 260 Main.map.mapView.zoomTo(MapillaryData.getInstance().getSelectedImage() 261 .getLatLon()); 248 Main.map.mapView.zoomTo(MapillaryData.getInstance().getSelectedImage().getLatLon()); 262 249 if (Main.map != null) 263 250 Main.map.mapView.repaint(); … … 265 252 } 266 253 267 private void fireSelectedImageChanged(MapillaryAbstractImage oldImage, 268 MapillaryAbstractImage newImage) { 254 private void fireSelectedImageChanged(MapillaryAbstractImage oldImage, MapillaryAbstractImage newImage) { 269 255 if (listeners.isEmpty()) 270 256 return; … … 323 309 */ 324 310 @Override 325 public void loadingFinished(CacheEntry data, CacheEntryAttributes attributes, 326 LoadResult result) { 311 public void loadingFinished(CacheEntry data, CacheEntryAttributes attributes, LoadResult result) { 327 312 // DO NOTHING 328 313 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31357 r31358 124 124 Main.map.mapView.removeMouseMotionListener(this.mode); 125 125 this.mode = mode; 126 Main.map.mapView.setNewCursor(mode.cursor, this); 126 127 Main.map.mapView.addMouseListener(mode); 127 128 Main.map.mapView.addMouseMotionListener(mode); 129 updateHelpText(); 128 130 } 129 131 … … 552 554 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 553 555 if (newLayer == this) { 554 if (data.size() > 0) 555 Main.map.statusLine.setHelpText(tr("Total images: {0}", data.size())); 556 else 557 Main.map.statusLine.setHelpText(tr("No images found")); 556 updateHelpText(); 558 557 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.JOIN_MENU, true); 559 558 } else … … 568 567 public void layerRemoved(Layer oldLayer) { 569 568 } 569 570 public void updateHelpText() { 571 String ret = ""; 572 if (data.size() > 0) 573 ret += tr("Total images: {0}", data.size()); 574 else 575 ret += tr("No images found"); 576 ret += " -- " + tr(mode.toString()); 577 578 Main.map.statusLine.setHelpText(ret); 579 } 570 580 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java
r31352 r31358 39 39 @Override 40 40 public void run() { 41 Main.map.statusLine.setHelpText( "Downloading images from Mapillary");41 Main.map.statusLine.setHelpText(tr("Downloading images from Mapillary")); 42 42 try { 43 43 downloadSequences(); 44 44 if (imagesAdded) { 45 Main.map.statusLine.setHelpText( "Downloading image's information");45 Main.map.statusLine.setHelpText(tr("Downloading image's information")); 46 46 completeImages(); 47 47 MapillaryMainDialog.getInstance().updateTitle(); 48 Main.map.statusLine.setHelpText( "Downloading signs");48 Main.map.statusLine.setHelpText(tr("Downloading signs")); 49 49 downloadSigns(); 50 50 } … … 52 52 Main.error(e); 53 53 } 54 if (layer.data.getImages().size() > 0) 55 Main.map.statusLine.setHelpText(tr("Total images: ") + layer.data.getImages().size()); 56 else 57 Main.map.statusLine.setHelpText(tr("No images found")); 54 layer.updateHelpText(); 58 55 layer.data.dataUpdated(); 59 56 MapillaryFilterDialog.getInstance().refresh(); … … 62 59 63 60 private void downloadSequences() throws InterruptedException { 64 ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5)); 61 ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS, 62 new ArrayBlockingQueue<Runnable>(5)); 65 63 int page = 0; 66 64 while (!ex.isShutdown()) { 67 ex.execute(new MapillarySequenceDownloadThread(ex, urlSequences + "&page=" + page + "&limit=10", layer, this)); 65 ex.execute(new MapillarySequenceDownloadThread(ex, urlSequences 66 + "&page=" + page + "&limit=10", layer, this)); 68 67 while (ex.getQueue().remainingCapacity() == 0) 69 68 Thread.sleep(500); … … 75 74 76 75 private void completeImages() throws InterruptedException { 77 ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5)); 76 ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS, 77 new ArrayBlockingQueue<Runnable>(5)); 78 78 int page = 0; 79 79 while (!ex.isShutdown()) { 80 ex.execute(new MapillaryImageInfoDownloaderThread(ex, urlImages + "&page=" + page + "&limit=20", layer)); 80 ex.execute(new MapillaryImageInfoDownloaderThread(ex, urlImages 81 + "&page=" + page + "&limit=20", layer)); 81 82 while (ex.getQueue().remainingCapacity() == 0) 82 83 Thread.sleep(100); … … 87 88 88 89 private void downloadSigns() throws InterruptedException { 89 ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5)); 90 ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS, 91 new ArrayBlockingQueue<Runnable>(5)); 90 92 int page = 0; 91 93 while (!ex.isShutdown()) { 92 ex.execute(new MapillarySignDownloaderThread(ex, urlSigns + "&page=" + page + "&limit=20", layer)); 94 ex.execute(new MapillarySignDownloaderThread(ex, urlSigns + "&page=" 95 + page + "&limit=20", layer)); 93 96 while (ex.getQueue().remainingCapacity() == 0) 94 97 Thread.sleep(100); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java
r31355 r31358 137 137 return; 138 138 } 139 // Enables/disables next/previous buttons 140 this.nextButton.setEnabled(false); 141 this.previousButton.setEnabled(false); 142 if (image.getSequence() != null) { 143 MapillaryAbstractImage tempImage = image; 144 while (tempImage.next() != null) { 145 tempImage = tempImage.next(); 146 if (tempImage.isVisible()) { 147 this.nextButton.setEnabled(true); 148 break; 149 } 150 } 151 } 152 if (image.getSequence() != null) { 153 MapillaryAbstractImage tempImage = image; 154 while (tempImage.previous() != null) { 155 tempImage = tempImage.previous(); 156 if (tempImage.isVisible()) { 157 this.previousButton.setEnabled(true); 158 break; 159 } 160 } 161 } 139 162 if (image instanceof MapillaryImage) { 140 163 mapillaryImageDisplay.hyperlink.setVisible(true); 141 164 MapillaryImage mapillaryImage = (MapillaryImage) this.image; 142 165 updateTitle(); 143 // Enables/disables next/previous buttons144 this.nextButton.setEnabled(false);145 this.previousButton.setEnabled(false);146 if (((MapillaryImage) image).getSequence() != null) {147 MapillaryAbstractImage tempImage = image;148 while (tempImage.next() != null) {149 tempImage = tempImage.next();150 if (tempImage.isVisible()) {151 this.nextButton.setEnabled(true);152 break;153 }154 }155 }156 if (((MapillaryImage) image).getSequence() != null) {157 MapillaryAbstractImage tempImage = image;158 while (tempImage.previous() != null) {159 tempImage = tempImage.previous();160 if (tempImage.isVisible()) {161 this.previousButton.setEnabled(true);162 break;163 }164 }165 }166 166 167 167 mapillaryImageDisplay.hyperlink.setURL(mapillaryImage.getKey()); … … 182 182 } else if (image instanceof MapillaryImportedImage) { 183 183 mapillaryImageDisplay.hyperlink.setVisible(false); 184 this.nextButton.setEnabled(false);185 this.previousButton.setEnabled(false);186 184 MapillaryImportedImage mapillaryImage = (MapillaryImportedImage) this.image; 187 185 try { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/AbstractMode.java
r31357 r31358 1 1 package org.openstreetmap.josm.plugins.mapillary.mode; 2 2 3 import java.awt.Cursor; 3 4 import java.awt.Graphics2D; 4 5 import java.awt.Point; … … 14 15 15 16 protected MapillaryData data = MapillaryData.getInstance(); 17 18 public int cursor = Cursor.DEFAULT_CURSOR; 16 19 17 20 public AbstractMode() { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java
r31357 r31358 2 2 3 3 import java.awt.Color; 4 import java.awt.Cursor; 4 5 import java.awt.Graphics2D; 5 6 import java.awt.Point; 6 7 import java.awt.event.MouseEvent; 8 import java.util.ArrayList; 7 9 8 10 import org.openstreetmap.josm.Main; … … 18 20 public MapillaryImportedImage lastClick; 19 21 public MouseEvent lastPos; 22 23 public JoinMode() { 24 cursor = Cursor.CROSSHAIR_CURSOR; 25 } 20 26 21 27 @Override … … 24 30 return; 25 31 if (lastClick == null && data.getHighlighted() instanceof MapillaryImportedImage) { 26 if (data.getHighlighted().previous() == null || data.getHighlighted().next() == null) 27 lastClick = (MapillaryImportedImage) data.getHighlighted(); 32 lastClick = (MapillaryImportedImage) data.getHighlighted(); 28 33 } else if (lastClick != null && data.getHighlighted() instanceof MapillaryImportedImage) { 29 if ((data.getHighlighted().previous() == null && lastClick.next() == null) 30 || (data.getHighlighted().next() == null && lastClick.previous() == null)) { 34 if (((data.getHighlighted().previous() == null && lastClick.next() == null) || (data.getHighlighted().next() == null && lastClick 35 .previous() == null)) 36 && (data.getHighlighted().getSequence() != lastClick.getSequence() || lastClick.getSequence() == null)) { 31 37 join(lastClick, (MapillaryImportedImage) data.getHighlighted()); 32 38 } else if (lastClick.next() == data.getHighlighted() || lastClick.previous() == data.getHighlighted()) … … 81 87 82 88 private void unjoin(MapillaryImportedImage img1, MapillaryImportedImage img2) { 83 // TODO 89 if (img1.next() != img2) { 90 MapillaryImportedImage temp = img1; 91 img1 = img2; 92 img2 = temp; 93 } 94 95 ArrayList<MapillaryAbstractImage> firstHalf = new ArrayList<>(img1.getSequence().getImages() 96 .subList(0, img1.getSequence().getImages().indexOf(img2))); 97 ArrayList<MapillaryAbstractImage> secondHalf = new ArrayList<>(img1.getSequence().getImages() 98 .subList(img1.getSequence().getImages().indexOf(img2), img1.getSequence().getImages().size())); 99 100 MapillarySequence seq1 = new MapillarySequence(); 101 MapillarySequence seq2 = new MapillarySequence(); 102 103 for (MapillaryAbstractImage img : firstHalf) { 104 img.setSequence(seq1); 105 seq1.add(img); 106 } 107 for (MapillaryAbstractImage img : secondHalf) { 108 img.setSequence(seq2); 109 seq2.add(img); 110 } 111 } 112 113 @Override 114 public String toString() { 115 return "Join mode"; 84 116 } 85 117 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java
r31357 r31358 196 196 public void paint(Graphics2D g, MapView mv, Bounds box) { 197 197 } 198 199 @Override 200 public String toString() { 201 return "Select mode"; 202 } 198 203 }
Note:
See TracChangeset
for help on using the changeset viewer.