Changeset 32974 in osm for applications/editors/josm/plugins/mapillary
- Timestamp:
- 2016-09-11T13:47:38+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java
r32593 r32974 17 17 * 18 18 */ 19 public class MapillaryAbstractImage implements Comparable<MapillaryAbstractImage> {19 public abstract class MapillaryAbstractImage implements Comparable<MapillaryAbstractImage> { 20 20 /** 21 21 * If two values for field ca differ by less than EPSILON both values are considered equal. … … 291 291 } 292 292 293 @Override293 /*@Override 294 294 public int compareTo(MapillaryAbstractImage mapillaryAbstractImage) { 295 295 return hashCode() - mapillaryAbstractImage.hashCode(); 296 296 } 297 298 @Override 299 public boolean equals(Object obj) { 300 return obj instanceof MapillaryAbstractImage && hashCode() == obj.hashCode(); 301 }*/ 297 302 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java
r32972 r32974 129 129 return this.key.compareTo(((MapillaryImage) image).getKey()); 130 130 } 131 return super.compareTo(image);131 return hashCode() - image.hashCode(); 132 132 } 133 133 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java
r32033 r32974 90 90 @Override 91 91 public int compareTo(MapillaryAbstractImage image) { 92 if (image instanceof MapillaryIm age)92 if (image instanceof MapillaryImportedImage) 93 93 return this.file.compareTo(((MapillaryImportedImage) image).getFile()); 94 return super.compareTo(image);94 return hashCode() - image.hashCode(); 95 95 } 96 96 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r32717 r32974 247 247 @Override 248 248 public boolean isModified() { 249 for (MapillaryAbstractImage image : this.data.getImages()) { 250 if (image.isModified()) 251 return true; 252 } 253 return false; 249 return this.data.getImages().parallelStream().anyMatch(MapillaryAbstractImage::isModified); 254 250 } 255 251 … … 257 253 public void setVisible(boolean visible) { 258 254 super.setVisible(visible); 259 for (MapillaryAbstractImage img : this.data.getImages()) { 260 img.setVisible(visible); 261 } 255 this.data.getImages().parallelStream().forEach(img -> img.setVisible(visible)); 262 256 if (Main.map != null) { 263 257 MapillaryFilterDialog.getInstance().refresh(); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
r32740 r32974 63 63 64 64 /** Cache that stores the pictures the downloaded pictures. */ 65 p ublicstatic CacheAccess<String, BufferedImageCacheEntry> cache;65 private static CacheAccess<String, BufferedImageCacheEntry> cache; 66 66 67 67 private static final MapillaryDownloadAction downloadAction = new MapillaryDownloadAction(); … … 137 137 * Required information of the plugin. Obtained from the jar file. 138 138 */ 139 public MapillaryPlugin(PluginInformation info) {139 public MapillaryPlugin(PluginInformation info) throws IOException { 140 140 super(info); 141 141 142 try{142 if (cache == null) { 143 143 cache = JCSCacheManager.getCache("mapillary", 10, 10000, this.getPluginDir() + "/cache/"); 144 } catch (IOException e) {145 Main.error(e);146 144 } 147 145 … … 286 284 return new ImageProvider(s); 287 285 } 286 287 public static CacheAccess<String, BufferedImageCacheEntry> getCache() { 288 return cache; 289 } 288 290 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillarySequence.java
r32373 r32974 38 38 * Creates a sequence object with the given parameters. 39 39 * 40 * @param key 40 * @param key The unique identifier of the sequence. 41 41 * @param createdAt The date the sequence was created. 42 * 42 43 * @throws IllegalArgumentException if the key is invalid 43 * 44 * according to {@link ValidationUtil#validateSequenceKey(String)} 44 45 */ 45 46 public MapillarySequence(String key, long createdAt) { … … 66 67 */ 67 68 public synchronized void add(List<MapillaryAbstractImage> images) { 68 for (MapillaryAbstractImage image : images) { 69 add(image); 70 } 69 images.forEach(this::add); 71 70 } 72 71 … … 108 107 * 109 108 * @param image The {@link MapillaryAbstractImage} object whose next image is 110 * going to be returned. 109 * going to be returned. 110 * 111 111 * @return The next {@link MapillaryAbstractImage} object in the sequence. 112 * 112 113 * @throws IllegalArgumentException if the given {@link MapillaryAbstractImage} object doesn't belong 113 * 114 * the this sequence. 114 115 */ 115 116 public MapillaryAbstractImage next(MapillaryAbstractImage image) { … … 129 130 * 130 131 * @param image The {@link MapillaryAbstractImage} object whose previous image is 131 * going to be returned. 132 * going to be returned. 133 * 132 134 * @return The previous {@link MapillaryAbstractImage} object in the sequence. 135 * 133 136 * @throws IllegalArgumentException if the given {@link MapillaryAbstractImage} object doesn't belong 134 * 137 * the this sequence. 135 138 */ 136 139 public MapillaryAbstractImage previous(MapillaryAbstractImage image) { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillarySign.java
r32973 r32974 6 6 import java.io.IOException; 7 7 import java.io.InputStreamReader; 8 import java.nio.charset.Charset; 8 9 import java.util.HashMap; 9 10 import java.util.Map; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryExportAction.java
r32373 r32974 98 98 } 99 99 try { 100 Main.worker.submit(new Thread(new MapillaryExportManager(images)));100 Main.worker.submit(new MapillaryExportManager(images)); 101 101 } catch (IOException e1) { 102 102 Main.error(e1); … … 113 113 */ 114 114 public void export(Set<MapillaryAbstractImage> images) { 115 Main.worker.submit(new Thread(newMapillaryExportManager(images,116 this.dialog.chooser.getSelectedFile().toString())) );115 Main.worker.submit(new MapillaryExportManager(images, 116 this.dialog.chooser.getSelectedFile().toString())); 117 117 } 118 118 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportIntoSequenceAction.java
r32593 r32974 8 8 import java.io.File; 9 9 import java.io.IOException; 10 import java.io.Serializable; 10 11 import java.util.ArrayList; 11 12 import java.util.Collections; … … 103 104 */ 104 105 public static class MapillaryEpochComparator implements 105 Comparator<MapillaryAbstractImage> {106 Comparator<MapillaryAbstractImage>, Serializable { 106 107 107 108 @Override -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/MapillaryCache.java
r31815 r32974 44 44 */ 45 45 public MapillaryCache(String key, Type type) { 46 super(MapillaryPlugin. cache, 50000, 50000, new HashMap<String, String>());46 super(MapillaryPlugin.getCache(), 50000, 50000, new HashMap<String, String>()); 47 47 String k = null; 48 48 URL u = null; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/FinishedUploadDialog.java
r32593 r32974 44 44 } 45 45 46 private class WebAction implements ActionListener {46 private static class WebAction implements ActionListener { 47 47 @Override 48 48 public void actionPerformed(ActionEvent e) { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryChangesetDialog.java
r32690 r32974 146 146 } 147 147 148 private class SubmitAction extends AbstractAction {148 private static class SubmitAction extends AbstractAction { 149 149 150 150 private static final long serialVersionUID = -2761935780353053512L; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterDialog.java
r32972 r32974 11 11 import java.util.Arrays; 12 12 import java.util.Calendar; 13 import java.util.function.Predicate; 13 14 import java.util.regex.Pattern; 14 15 … … 72 73 */ 73 74 private static final String[] SIGN_TAGS = {"prohibitory--maximum-speed-limit", 74 75 76 77 78 75 "regulatory|priority--stop", "regulatory|priority--give_way|yield", "warning|mandatory--roundabout", 76 "prohibitory|regulatory--no-entry|no-traffic-both-ways", 77 "crossroads|junction", "mandatory--turn|straight", "uneven|slippery", 78 "no-parking", "no_overtaking", 79 "danger_pedestrian_crossing", "no_*_turn"}; 79 80 /** 80 81 * The {@link JCheckBox} where the respective tag should be searched 81 82 */ 82 83 private final JCheckBox[] SIGN_CHECKBOXES = {this.signFilter.maxSpeed, 83 84 85 86 87 84 this.signFilter.stop, this.signFilter.giveWay, 85 this.signFilter.roundabout, this.signFilter.access, this.signFilter.intersection, 86 this.signFilter.direction, this.signFilter.uneven, 87 this.signFilter.noParking, this.signFilter.noOvertaking, 88 this.signFilter.crossing, this.signFilter.noTurn}; 88 89 89 90 private MapillaryFilterDialog() { 90 91 super(tr("Mapillary filter"), "mapillary-filter.svg", 91 92 93 92 tr("Open Mapillary filter dialog"), Shortcut.registerShortcut( 93 tr("Mapillary filter"), tr("Open Mapillary filter dialog"), 94 KeyEvent.VK_M, Shortcut.NONE), 200); 94 95 95 96 this.signChooser.setEnabled(false); … … 179 180 boolean onlySigns = this.onlySigns.isSelected(); 180 181 181 for (MapillaryAbstractImage img : MapillaryLayer.getInstance().getData().getImages()) { 182 img.setVisible(true); 183 if (img instanceof MapillaryImportedImage) { 184 if (!imported) 185 img.setVisible(false); 186 continue; 187 } else if (img instanceof MapillaryImage) { 188 if (!downloaded) { 189 img.setVisible(false); 190 continue; 191 } 192 if (onlySigns) { 193 if (((MapillaryImage) img).getSigns().isEmpty()) { 194 img.setVisible(false); 195 continue; 196 } 197 if (!checkSigns((MapillaryImage) img)) { 198 img.setVisible(false); 199 continue; 200 } 201 } 202 if (!"".equals(user.getText()) 203 && !this.user.getText().equals(((MapillaryImage) img).getUser())) { 204 img.setVisible(false); 205 continue; 206 } 182 // This predicate returns true is the image should be made invisible 183 Predicate<MapillaryAbstractImage> p = 184 img -> 185 (img instanceof MapillaryImportedImage && !imported) || 186 (img instanceof MapillaryImage && 187 (!downloaded || 188 (onlySigns && (((MapillaryImage) img).getSigns().isEmpty() || !checkSigns((MapillaryImage) img))) || 189 (!user.getText().equals("") && !this.user.getText().equals(((MapillaryImage) img).getUser())))) || 190 checkValidTime(img); 191 192 MapillaryLayer.getInstance().getData().getImages().parallelStream().forEach(img -> img.setVisible(!p.test(img))); 193 194 Main.map.repaint(); 195 } 196 197 private boolean checkValidTime(MapillaryAbstractImage img) { 198 Long currentTime = currentTime(); 199 long[] timeFactor = new long[]{ 200 31_536_000_000L, // = 365 * 24 * 60 * 60 * 1000 = number of ms in a year 201 2_592_000_000L, // = 30 * 24 * 60 * 60 * 1000 = number of ms in a month 202 86_400_000 // = 24 * 60 * 60 * 1000 = number of ms in a day 203 }; 204 for (int i = 1; i <= 3; i++) { 205 if (TIME_LIST[i].equals(time.getSelectedItem()) 206 && img.getCapturedAt() < currentTime - ((Integer) spinner.getValue()).longValue() * timeFactor[i - 1] 207 ) { 208 return true; 207 209 } 208 // Calculates the amount of days since the image was taken 209 Long currentTime = currentTime(); 210 long[] timeFactor = new long[]{ 211 31_536_000_000L, // = 365 * 24 * 60 * 60 * 1000 = number of ms in a year 212 2_592_000_000L, // = 30 * 24 * 60 * 60 * 1000 = number of ms in a month 213 86_400_000 // = 24 * 60 * 60 * 1000 = number of ms in a day 214 }; 215 for (int i = 1; i <= 3; i++) { 216 if (TIME_LIST[i].equals(time.getSelectedItem()) 217 && img.getCapturedAt() < currentTime - ((Integer) spinner.getValue()).longValue() * timeFactor[i - 1] 218 ) { 219 img.setVisible(false); 220 } 221 } 222 } 223 Main.map.repaint(); 210 } 211 return false; 224 212 } 225 213 … … 228 216 * 229 217 * @param img The {@link MapillaryAbstractImage} object that is going to be 230 * checked. 218 * checked. 219 * 231 220 * @return {@code true} if it fulfills the conditions; {@code false} 232 221 * otherwise. … … 245 234 String[] parts = signTag.split("--"); 246 235 if (Pattern.compile(parts[0]).matcher(sign.getCategory()).find() && 247 236 Pattern.compile(parts[1]).matcher(sign.getType()).find()) { 248 237 contains = true; 249 238 } … … 341 330 JPanel dialog = MapillaryFilterChooseSigns.getInstance(); 342 331 JOptionPane pane = new JOptionPane(dialog, JOptionPane.PLAIN_MESSAGE, 343 332 JOptionPane.OK_CANCEL_OPTION); 344 333 JDialog dlg = pane.createDialog(Main.parent, tr("Choose signs")); 345 334 dlg.setVisible(true); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java
r32690 r32974 185 185 * 186 186 */ 187 private class LoginAction extends AbstractAction {187 private static class LoginAction extends AbstractAction { 188 188 private static final long serialVersionUID = -3908477563072057344L; 189 189 private final transient MapillaryLoginListener callback; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java
r32740 r32974 53 53 MapillaryAbstractImage closest = getClosest(e.getPoint()); 54 54 if (!(Main.getLayerManager().getActiveLayer() instanceof MapillaryLayer) 55 55 && closest != null && Main.map.mapMode == Main.map.mapModeSelect) { 56 56 this.lastClicked = this.closest; 57 57 this.data.setSelectedImage(closest); … … 62 62 // Double click 63 63 if (e.getClickCount() == 2 && this.data.getSelectedImage() != null && closest != null) { 64 for (MapillaryAbstractImage img : closest.getSequence().getImages()) { 65 this.data.addMultiSelectedImage(img); 66 } 64 closest.getSequence().getImages().forEach(data::addMultiSelectedImage); 67 65 } 68 66 this.lastClicked = this.closest; … … 76 74 // shift + click 77 75 } else if ( 78 76 e.getModifiers() == (InputEvent.BUTTON1_MASK | InputEvent.SHIFT_MASK) 79 77 && this.lastClicked instanceof MapillaryImage 80 ) {81 if (this.closest != null && this.lastClicked != null82 78 ) { 79 if (this.closest != null 80 && this.closest.getSequence() == (this.lastClicked).getSequence()) { 83 81 int i = this.closest.getSequence().getImages().indexOf(this.closest); 84 82 int j = this.lastClicked.getSequence().getImages().indexOf(this.lastClicked); 85 83 this.data.addMultiSelectedImage( 86 84 i < j 87 85 ? new ConcurrentSkipListSet<>(this.closest.getSequence().getImages().subList(i, j + 1)) 88 86 : new ConcurrentSkipListSet<>(this.closest.getSequence().getImages().subList(j, i + 1)) … … 100 98 if ( 101 99 Main.getLayerManager().getActiveLayer() == MapillaryLayer.getInstance() 102 && SwingUtilities.isLeftMouseButton(e)103 && highlightImg != null && highlightImg.getLatLon() != null104 ) {100 && SwingUtilities.isLeftMouseButton(e) 101 && highlightImg != null && highlightImg.getLatLon() != null 102 ) { 105 103 Point highlightImgPoint = Main.map.mapView.getPoint(highlightImg.getTempLatLon()); 106 104 if (e.isShiftDown()) { // turn 107 for (MapillaryAbstractImage img : data.getMultiSelectedImages()) { 108 if (!(img instanceof MapillaryImage)) { 109 img.turn(Math.toDegrees(Math.atan2(e.getX() - highlightImgPoint.getX(), -e.getY() + highlightImgPoint.getY())) - highlightImg.getTempCa()); 110 } 111 } 105 this.data.getMultiSelectedImages().parallelStream().filter(img -> !(img instanceof MapillaryImage)) 106 .forEach(img -> img.turn(Math.toDegrees(Math.atan2(e.getX() - highlightImgPoint.getX(), -e.getY() + highlightImgPoint.getY())) - highlightImg.getTempCa())); 112 107 } else { // move 113 for (MapillaryAbstractImage img : this.data.getMultiSelectedImages()) { 114 if (!(img instanceof MapillaryImage)) { 115 LatLon eventLatLon = Main.map.mapView.getLatLon(e.getX(), e.getY()); 116 LatLon imgLatLon = Main.map.mapView.getLatLon(highlightImgPoint.getX(), highlightImgPoint.getY()); 117 img.move(eventLatLon.getX() - imgLatLon.getX(), eventLatLon.getY() - imgLatLon.getY()); 118 } 119 } 108 LatLon eventLatLon = Main.map.mapView.getLatLon(e.getX(), e.getY()); 109 LatLon imgLatLon = Main.map.mapView.getLatLon(highlightImgPoint.getX(), highlightImgPoint.getY()); 110 this.data.getMultiSelectedImages().parallelStream().filter(img -> !(img instanceof MapillaryImage)) 111 .forEach(img -> img.move(eventLatLon.getX() - imgLatLon.getX(), eventLatLon.getY() - imgLatLon.getY())); 120 112 } 121 113 Main.map.repaint(); … … 131 123 double to = this.data.getSelectedImage().getMovingCa(); 132 124 this.record.addCommand(new CommandTurn(this.data.getMultiSelectedImages(), to 133 125 - from)); 134 126 } else if (this.data.getSelectedImage().getTempLatLon() != this.data 135 127 .getSelectedImage().getMovingLatLon()) { 136 128 LatLon from = this.data.getSelectedImage().getTempLatLon(); 137 129 LatLon to = this.data.getSelectedImage().getMovingLatLon(); 138 130 this.record.addCommand(new CommandMove(this.data.getMultiSelectedImages(), to 139 131 .getX() - from.getX(), to.getY() - from.getY())); 140 132 } 141 for (MapillaryAbstractImage img : this.data.getMultiSelectedImages()) { 142 if (img != null) 143 img.stopMoving(); 144 } 133 this.data.getMultiSelectedImages().parallelStream().filter(img -> img != null).forEach(MapillaryAbstractImage::stopMoving); 145 134 } 146 135 … … 151 140 public void mouseMoved(MouseEvent e) { 152 141 if (Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer 153 142 && Main.map.mapMode != Main.map.mapModeSelect) { 154 143 return; 155 144 } … … 161 150 162 151 if (closestTemp != null 163 164 152 && Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer 153 && !this.imageHighlighted) { 165 154 Main.map.mapMode.putValue("active", Boolean.FALSE); 166 155 this.imageHighlighted = true; 167 156 168 157 } else if (closestTemp == null 169 170 158 && Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer 159 && this.imageHighlighted && this.nothingHighlighted) { 171 160 this.nothingHighlighted = false; 172 161 Main.map.mapMode.putValue("active", Boolean.TRUE); 173 162 174 163 } else if (this.imageHighlighted && !this.nothingHighlighted 175 176 164 && Main.getLayerManager().getEditLayer().data != null 165 && Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer) { 177 166 178 167 for (OsmPrimitive primivitive : Main.getLayerManager().getEditLayer().data 179 168 .allPrimitives()) { 180 169 primivitive.setHighlighted(false); 181 170 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/UploadUtils.java
r32593 r32974 273 273 } 274 274 } 275 file.delete(); 275 if (!file.delete()) { 276 Main.error("MapillaryPlugin: File could not be deleted during upload"); 277 } 276 278 MapillaryUtils.updateHelpText(); 277 279 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/ImageUtil.java
r32642 r32974 48 48 for (File child : f.listFiles()) { 49 49 try { 50 images.addAll(readImagesFrom(child, defaultLL));50 assert images.addAll(readImagesFrom(child, defaultLL)); 51 51 } catch (IOException e) { 52 52 // Don't throw an exception here to allow other files that might be readable to be read.
Note:
See TracChangeset
for help on using the changeset viewer.