Changeset 31983 in osm for applications/editors/josm/plugins/mapillary
- Timestamp:
- 2016-01-13T16:35:59+01:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java
r31972 r31983 196 196 /** 197 197 * If the MapillaryImage belongs to a MapillarySequence, returns the next 198 * MapillarySequence in it.198 * image in the sequence. 199 199 * 200 200 * @return The following MapillaryImage, or null if there is none. … … 210 210 /** 211 211 * If the MapillaryImage belongs to a MapillarySequence, returns the previous 212 * MapillarySequence in it.212 * image in the sequence. 213 213 * 214 214 * @return The previous MapillaryImage, or null if there is none. -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
r31974 r31983 3 3 4 4 import java.util.Collections; 5 import java.util.HashSet; 5 6 import java.util.List; 6 7 import java.util.Set; … … 219 220 220 221 /** 221 * Returns a List containing all images.222 * 223 * @return A List object containing all images.222 * Returns a Set containing all images. 223 * 224 * @return A Set object containing all images. 224 225 */ 225 226 public synchronized Set<MapillaryAbstractImage> getImages() { 226 227 return this.images; 228 } 229 230 /** 231 * Returns a Set of all sequences, that the images are part of. 232 * @return 233 */ 234 public synchronized Set<MapillarySequence> getSequences() { 235 Set<MapillarySequence> result = new HashSet<>(); 236 for (MapillaryAbstractImage img : getImages()) { 237 result.add(img.getSequence()); 238 } 239 return result; 227 240 } 228 241 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31974 r31983 6 6 7 7 import java.awt.AlphaComposite; 8 import java.awt.BasicStroke; 8 9 import java.awt.Color; 9 10 import java.awt.Composite; … … 12 13 import java.awt.Point; 13 14 import java.awt.Rectangle; 15 import java.awt.RenderingHints; 16 import java.awt.Shape; 14 17 import java.awt.TexturePaint; 15 18 import java.awt.event.ActionEvent; 16 19 import java.awt.geom.AffineTransform; 17 import java.awt.geom. Area;20 import java.awt.geom.Line2D; 18 21 import java.awt.image.AffineTransformOp; 19 22 import java.awt.image.BufferedImage; … … 59 62 import org.openstreetmap.josm.plugins.mapillary.mode.JoinMode; 60 63 import org.openstreetmap.josm.plugins.mapillary.mode.SelectMode; 64 import org.openstreetmap.josm.plugins.mapillary.utils.MapViewGeometryUtil; 61 65 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils; 62 66 … … 230 234 @Override 231 235 public boolean isModified() { 232 for (MapillaryAbstractImage image : this.data.getImages()) 236 for (MapillaryAbstractImage image : this.data.getImages()) { 233 237 if (image.isModified()) 234 238 return true; 239 } 235 240 return false; 236 241 } … … 280 285 281 286 @Override 282 public synchronized void paint(Graphics2D g, MapView mv, Bounds box) { 287 public synchronized void paint(final Graphics2D g, final MapView mv, final Bounds box) { 288 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 283 289 if (Main.map.mapView.getActiveLayer() == this) { 284 Rectangle b = mv.getBounds();285 // on some platforms viewport bounds seem to be offset from the left,286 // over-grow it just to be sure287 b.grow(100, 100);288 Area a = new Area(b);289 // now successively subtract downloaded areas290 for (Bounds bounds : this.data.bounds) {291 Point p1 = mv.getPoint(bounds.getMin());292 Point p2 = mv.getPoint(bounds.getMax());293 Rectangle r = new Rectangle(Math.min(p1.x, p2.x), Math.min(p1.y, p2.y),294 Math.abs(p2.x - p1.x), Math.abs(p2.y - p1.y));295 a.subtract(new Area(r));296 }297 290 // paint remainder 298 291 g.setPaint(this.hatched); 299 g.fill( a);292 g.fill(MapViewGeometryUtil.getNonDownloadedArea(mv, this.data.bounds)); 300 293 } 301 294 302 295 // Draw colored lines 296 MapillaryMainDialog.getInstance().blueButton.setEnabled(false); 297 MapillaryMainDialog.getInstance().redButton.setEnabled(false); 303 298 blue = null; 304 299 red = null; 305 MapillaryMainDialog.getInstance().blueButton.setEnabled(false); 306 MapillaryMainDialog.getInstance().redButton.setEnabled(false); 307 308 // Sets blue and red lines and enables/disables the buttons 300 301 // Draw the blue and red line and enable/disable the buttons 309 302 if (this.data.getSelectedImage() != null) { 310 303 MapillaryImage[] closestImages = getClosestImagesFromDifferentSequences(); … … 313 306 blue = closestImages[0]; 314 307 g.setColor(Color.BLUE); 315 g.drawLine(mv.getPoint(closestImages[0].getLatLon()).x,316 mv.getPoint(closestImages[0].getLatLon()).y, selected.x, selected.y);308 final Point p = mv.getPoint(closestImages[0].getLatLon()); 309 g.draw(new Line2D.Double(p.getX(), p.getY(), selected.getX(), selected.getY())); 317 310 MapillaryMainDialog.getInstance().blueButton.setEnabled(true); 318 311 } … … 320 313 red = closestImages[1]; 321 314 g.setColor(Color.RED); 322 g.drawLine(mv.getPoint(closestImages[1].getLatLon()).x,323 mv.getPoint(closestImages[1].getLatLon()).y, selected.x, selected.y);315 final Point p = mv.getPoint(closestImages[1].getLatLon()); 316 g.draw(new Line2D.Double(p.getX(), p.getY(), selected.getX(), selected.getY())); 324 317 MapillaryMainDialog.getInstance().redButton.setEnabled(true); 325 318 } 326 319 } 320 // Draw sequence line 327 321 g.setColor(Color.WHITE); 322 g.setStroke(new BasicStroke(this == Main.map.mapView.getActiveLayer() ? 3 : 1)); 323 for (MapillarySequence seq : getData().getSequences()) { 324 g.draw(MapViewGeometryUtil.getSequencePath(mv, seq)); 325 } 328 326 for (MapillaryAbstractImage imageAbs : this.data.getImages()) { 329 if (!imageAbs.isVisible()) 330 continue; 331 Point p = mv.getPoint(imageAbs.getLatLon()); 332 Point nextp = null; 333 // Draw sequence line 334 if (imageAbs.getSequence() != null) { 335 MapillaryAbstractImage tempImage = imageAbs.next(); 336 while (tempImage != null) { 337 if (tempImage.isVisible()) { 338 nextp = mv.getPoint(tempImage.getLatLon()); 339 break; 340 } 341 tempImage = tempImage.next(); 327 if (imageAbs.isVisible()) { 328 final Point p = mv.getPoint(imageAbs.getLatLon()); 329 if (getData().getMultiSelectedImages().contains(imageAbs)) { 330 draw(g, imageAbs, MapillaryPlugin.MAP_ICON_SELECTED, p); 331 } else { 332 draw(g, imageAbs, imageAbs instanceof MapillaryImage ? MapillaryPlugin.MAP_ICON : MapillaryPlugin.MAP_ICON_IMPORTED, p); 342 333 } 343 if (nextp != null) 344 g.drawLine(p.x, p.y, nextp.x, nextp.y); 345 } 346 // Draws icons 347 if (imageAbs instanceof MapillaryImage) { 348 MapillaryImage image = (MapillaryImage) imageAbs; 349 ImageIcon icon; 350 icon = this.data.getMultiSelectedImages().contains(image) ? MapillaryPlugin.MAP_ICON_SELECTED : MapillaryPlugin.MAP_ICON; 351 draw(g, image, icon, p); 352 if (!image.getSigns().isEmpty()) { 353 g.drawImage(MapillaryPlugin.MAP_SIGN.getImage(), 354 p.x + icon.getIconWidth() / 2, p.y - icon.getIconHeight() / 2, 355 Main.map.mapView); 334 if (imageAbs instanceof MapillaryImage && !((MapillaryImage) imageAbs).getSigns().isEmpty()) { 335 g.drawImage( 336 MapillaryPlugin.MAP_SIGN.getImage(), 337 p.x - MapillaryPlugin.MAP_SIGN.getIconWidth() / 2, 338 p.y - MapillaryPlugin.MAP_SIGN.getIconHeight() / 2, 339 Main.map.mapView 340 ); 356 341 } 357 } else if (imageAbs instanceof MapillaryImportedImage) {358 MapillaryImportedImage image = (MapillaryImportedImage) imageAbs;359 ImageIcon icon = this.data.getMultiSelectedImages().contains(image)360 ? MapillaryPlugin.MAP_ICON_SELECTED361 : MapillaryPlugin.MAP_ICON_IMPORTED;362 draw(g, image, icon, p);363 342 } 364 343 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
r31976 r31983 97 97 98 98 static { 99 if (Main.main != null) { 99 if (Main.main == null) { 100 exportMenu = null; 101 downloadMenu = null; 102 importMenu = null; 103 zoomMenu = null; 104 downloadViewMenu = null; 105 importIntoSequenceMenu = null; 106 joinMenu = null; 107 walkMenu = null; 108 uploadMenu = null; 109 } else { 100 110 exportMenu = MainMenu.add(Main.main.menu.fileMenu, exportAction, false, 14); 101 111 exportMenu.setEnabled(false); … … 116 126 uploadMenu = MainMenu.add(Main.main.menu.fileMenu, uploadAction, false, 14); 117 127 uploadMenu.setEnabled(false); 118 } else {119 exportMenu = null;120 downloadMenu = null;121 importMenu = null;122 zoomMenu = null;123 downloadViewMenu = null;124 importIntoSequenceMenu = null;125 joinMenu = null;126 walkMenu = null;127 uploadMenu = null;128 128 } 129 129 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/UploadUtils.java
r31974 r31983 56 56 */ 57 57 public class UploadUtils { 58 /** 59 * Required keys for POST 60 */ 61 private static final String[] keys = {"key", "AWSAccessKeyId", "acl", "policy", "signature", "Content-Type"}; 62 63 /** 64 * Mapillary upload URL 65 */ 66 private static final String UPLOAD_URL = "https://s3-eu-west-1.amazonaws.com/mapillary.uploads.manual.images"; 67 68 /** 69 * Count to name temporal files. 70 */ 71 private static int c; 58 72 59 73 private UploadUtils() { 60 74 // Private constructor to avoid instantiation. 61 75 } 62 63 /**64 * Required keys for POST65 */66 private static final String[] keys = {"key", "AWSAccessKeyId", "acl",67 "policy", "signature", "Content-Type"};68 69 /**70 * Mapillary upload URL71 */72 private static final String UPLOAD_URL = "https://s3-eu-west-1.amazonaws.com/mapillary.uploads.manual.images";73 74 /**75 * Count to name temporal files.76 */77 private static int c;78 76 79 77 private static class SequenceUploadThread extends Thread { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtils.java
r31974 r31983 5 5 6 6 import java.awt.Desktop; 7 import java.awt.Point; 8 import java.awt.Rectangle; 9 import java.awt.geom.Area; 7 10 import java.io.File; 8 11 import java.io.IOException; … … 11 14 import java.text.ParseException; 12 15 import java.text.SimpleDateFormat; 13 import java.util.*; 16 import java.util.ArrayList; 17 import java.util.Calendar; 18 import java.util.Locale; 19 import java.util.Set; 14 20 15 21 import javax.swing.SwingUtilities; … … 26 32 import org.openstreetmap.josm.data.Bounds; 27 33 import org.openstreetmap.josm.data.coor.LatLon; 34 import org.openstreetmap.josm.gui.MapView; 28 35 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage; 29 36 import org.openstreetmap.josm.plugins.mapillary.MapillaryData; … … 129 136 throw new IllegalArgumentException("Array's length must be 3."); 130 137 } 131 for (int i = 0; i < 3; i++) 138 for (int i = 0; i < 3; i++) { 132 139 if (degMinSec[i] == null) 133 140 throw new IllegalArgumentException("Null value in array."); 141 } 134 142 135 143 switch (ref) {
Note:
See TracChangeset
for help on using the changeset viewer.