Changeset 34349 in osm for applications/editors
- Timestamp:
- 2018-06-24T02:28:09+02:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/MicrosoftStreetside
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/MicrosoftStreetside/gradle.properties
r34320 r34349 9 9 # You can check if the plugin compiles against this version by executing `./gradlew minJosmVersionClasses`. 10 10 plugin.main.version=13860 11 plugin.version=13860 11 12 # Version of JOSM against which the plugin is compiled 12 13 # Please check, if the specified version is available for download from https://josm.openstreetmap.de/download/ . -
applications/editors/josm/plugins/MicrosoftStreetside/ivy.xml
r34329 r34349 1 1 <ivy-module version="2.0"> 2 2 <info organisation="org.openstreetmap.josm.plugins" module="MicrosoftStreetside" revision="0.0.1" /> 3 <configurations defaultconf="default" defaultconfmapping="default->default ,sources">3 <configurations defaultconf="default" defaultconfmapping="default->default"> 4 4 <conf name="default" /> 5 5 </configurations> -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/StreetsideData.java
r34333 r34349 290 290 throw new IllegalStateException(); 291 291 } 292 StreetsideAbstractImage tempImage = this.selectedImage;292 StreetsideAbstractImage tempImage = selectedImage; 293 293 while (tempImage.previous() != null) { 294 294 tempImage = tempImage.previous(); -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/StreetsideImage.java
r34348 r34349 2 2 package org.openstreetmap.josm.plugins.streetside; 3 3 4 import java.util.ArrayList;5 import java.util.Collection;6 import java.util.Collections;7 4 import java.util.List; 8 5 … … 10 7 import org.openstreetmap.josm.plugins.streetside.cubemap.CubemapUtils; 11 8 import org.openstreetmap.josm.plugins.streetside.model.UserProfile; 12 import org.openstreetmap.josm.tools.Logging;13 14 import org.openstreetmap.josm.plugins.streetside.model.ImageDetection;15 9 16 10 /** … … 48 42 private double pi; 49 43 44 // Heading (equivalent to Mapillary cd attribute - not currently supported. 45 private double he; 46 50 47 // Blurring instructions - not currently used by the plugin 51 48 private String bl; … … 62 59 /** 63 60 * Set of traffic signs in the image. 64 */ 61 *//* 65 62 private final List<ImageDetection> detections = Collections.synchronizedList(new ArrayList<>()); 66 63 */ 67 64 /** 68 65 * Main constructor of the class StreetsideImage … … 103 100 } 104 101 105 public List<ImageDetection> getDetections() {102 /*public List<ImageDetection> getDetections() { 106 103 return detections; 107 } 108 109 public void setAllDetections(Collection<ImageDetection> newDetections) {104 }*/ 105 106 /*public void setAllDetections(Collection<ImageDetection> newDetections) { 110 107 Logging.debug("Add {0} detections to image {1}", newDetections.size(), getId()); 111 108 synchronized (detections) { … … 113 110 detections.addAll(newDetections); 114 111 } 115 } 112 }*/ 116 113 117 114 public UserProfile getUser() { … … 122 119 public String toString() { 123 120 return String.format( 121 // TODO: format date cd (Gradle build error command line) 124 122 "Image[id=%s,lat=%f,lon=%f,he=%f,user=%s]", 125 123 id, latLon.lat(), latLon.lon(), he, "null"//, cd -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/StreetsideLayer.java
r34333 r34349 81 81 ) / 3; 82 82 83 private static final DataSetListenerAdapter DATASET_LISTENER = new DataSetListenerAdapter(e -> { 84 if (e instanceof DataChangedEvent && StreetsideDownloader.getMode() == DOWNLOAD_MODE.OSM_AREA) { 85 // When more data is downloaded, a delayed update is thrown, in order to 86 // wait for the data bounds to be set. 87 MainApplication.worker.execute(StreetsideDownloader::downloadOSMArea); 88 } 89 }); 83 private static final DataSetListenerAdapter DATASET_LISTENER = 84 new DataSetListenerAdapter(e -> { 85 if (e instanceof DataChangedEvent && StreetsideDownloader.getMode() == DOWNLOAD_MODE.OSM_AREA) { 86 // When more data is downloaded, a delayed update is thrown, in order to 87 // wait for the data bounds to be set. 88 MainApplication.worker.execute(StreetsideDownloader::downloadOSMArea); 89 } 90 }); 90 91 91 92 /** Unique instance of the class. */ … … 258 259 259 260 260 261 @Override 261 262 public boolean isModified() { 262 263 return data.getImages().parallelStream().anyMatch(StreetsideAbstractImage::isModified); … … 313 314 314 315 // Draw sequence line 315 // TODO: reimplement sequence lines for Streetside316 316 /*g.setStroke(new BasicStroke(2)); 317 317 final StreetsideAbstractImage selectedImage = getData().getSelectedImage(); … … 392 392 393 393 394 if (img instanceof StreetsideImage && !((StreetsideImage) img).getDetections().isEmpty()) {395 Path2D trafficSign = new Path2D.Double();394 /*if (img instanceof StreetsideImage && !((StreetsideImage) img).getDetections().isEmpty()) { 395 final Path2D trafficSign = new Path2D.Double(); 396 396 trafficSign.moveTo(p.getX() - StreetsideLayer.TRAFFIC_SIGN_SIZE / 2d, p.getY() - StreetsideLayer.TRAFFIC_SIGN_HEIGHT_3RD); 397 397 trafficSign.lineTo(p.getX() + StreetsideLayer.TRAFFIC_SIGN_SIZE / 2d, p.getY() - StreetsideLayer.TRAFFIC_SIGN_HEIGHT_3RD); … … 403 403 g.setColor(Color.RED); 404 404 g.draw(trafficSign); 405 } 405 }*/ 406 406 } 407 407 -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/StreetsidePlugin.java
r34333 r34349 26 26 import org.openstreetmap.josm.tools.ImageProvider; 27 27 28 import org.openstreetmap.josm.plugins.streetside.gui.StreetsideChangesetDialog;29 30 28 /** 31 29 * This is the main class of the Streetside plugin. … … 50 48 MainMenu.add(MainApplication.getMenu().dataMenu, new StreetsideJoinAction(), false); 51 49 MainMenu.add(MainApplication.getMenu().moreToolsMenu, WALK_ACTION, false); 50 //MainMenu.add(MainApplication.getMenu().imagerySubMenu, new MapObjectLayerAction(), false); 52 51 //MainMenu.add(MainApplication.getMenu().imagerySubMenu, new MapObjectLayerAction(), false); 53 52 } … … 76 75 * @return the {@link StreetsideWalkAction} for the plugin 77 76 */ 78 public static StreetsideWalkAction get WalkAction() {77 public static StreetsideWalkAction getStreetsideWalkAction() { 79 78 return WALK_ACTION; 80 79 } … … 92 91 MainApplication.getMap().addToggleDialog(StreetsideViewerDialog.getInstance(), false); 93 92 //MainApplication.getMap().addToggleDialog(StreetsideHistoryDialog.getInstance(), false); 94 MainApplication.getMap().addToggleDialog(StreetsideChangesetDialog.getInstance(), false);93 //MainApplication.getMap().addToggleDialog(StreetsideChangesetDialog.getInstance(), false); 95 94 //MainApplication.getMap().addToggleDialog(StreetsideFilterDialog.getInstance(), false); 96 95 } … … 98 97 StreetsideMainDialog.destroyInstance(); 99 98 //StreetsideHistoryDialog.destroyInstance(); 100 StreetsideChangesetDialog.destroyInstance();99 //StreetsideChangesetDialog.destroyInstance(); 101 100 //StreetsideFilterDialog.destroyInstance(); 102 101 ImageInfoPanel.destroyInstance(); … … 132 131 * @return the {@link StreetsideZoomAction} for the plugin 133 132 */ 134 public static StreetsideZoomAction getZoomAction() {133 /*public static StreetsideZoomAction getZoomAction() { 135 134 return ZOOM_ACTION; 135 }*/ 136 136 } 137 138 } -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/actions/StreetsideDownloadAction.java
r34348 r34349 47 47 @Override 48 48 public void actionPerformed(ActionEvent ae) { 49 if (!StreetsideLayer.hasInstance() || !MainApplication.getLayerManager().containsLayer(StreetsideLayer.getInstance())) { 49 if (!StreetsideLayer.hasInstance()) { 50 // A new streetside layer is created, so the active layer is not changed 51 StreetsideLayer.getInstance(); 52 return; 53 } else if (!MainApplication.getLayerManager().containsLayer(StreetsideLayer.getInstance())) { 50 54 MainApplication.getLayerManager().addLayer(StreetsideLayer.getInstance()); 51 55 return; -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/actions/StreetsideDownloadViewAction.java
r34348 r34349 26 26 27 27 private static final long serialVersionUID = 6738276777802831669L; 28 28 29 private static final String DESCRIPTION = I18n.marktr("Download Streetside images in current view"); 29 30 -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/actions/StreetsideExportAction.java
r34348 r34349 63 63 cancel.addActionListener(e -> pane.setValue(JOptionPane.CANCEL_OPTION)); 64 64 65 this.dialog = new StreetsideExportDialog(ok);66 pane.setMessage( this.dialog);65 dialog = new StreetsideExportDialog(ok); 66 pane.setMessage(dialog); 67 67 pane.setOptions(new JButton[] {ok, cancel}); 68 68 … … 74 74 if (pane.getValue() != null 75 75 && (int) pane.getValue() == JOptionPane.OK_OPTION 76 && this.dialog.chooser != null) {77 if ( this.dialog.group.isSelected(this.dialog.all.getModel())) {76 && dialog.chooser != null) { 77 if (dialog.group.isSelected(dialog.all.getModel())) { 78 78 export(StreetsideLayer.getInstance().getData().getImages()); 79 } else if ( this.dialog.group.isSelected(this.dialog.sequence.getModel())) {79 } else if (dialog.group.isSelected(dialog.sequence.getModel())) { 80 80 Set<StreetsideAbstractImage> images = new ConcurrentSkipListSet<>(); 81 81 for (StreetsideAbstractImage image : StreetsideLayer.getInstance().getData().getMultiSelectedImages()) { … … 89 89 } 90 90 export(images); 91 } else if ( this.dialog.group.isSelected(dialog.selected.getModel())) {91 } else if (dialog.group.isSelected(dialog.selected.getModel())) { 92 92 export(StreetsideLayer.getInstance().getData().getMultiSelectedImages()); 93 93 } 94 94 // This option ignores the selected directory. 95 } else if ( this.dialog.group.isSelected(dialog.rewrite.getModel())) {95 } else if (dialog.group.isSelected(dialog.rewrite.getModel())) { 96 96 ArrayList<StreetsideImportedImage> images = new ArrayList<>(); 97 97 StreetsideLayer.getInstance().getData().getImages().stream().filter(img -> img instanceof StreetsideImportedImage).forEach(img -> images.add((StreetsideImportedImage) img)); … … 113 113 public void export(Set<StreetsideAbstractImage> images) { 114 114 MainApplication.worker.execute(new StreetsideExportManager(images, 115 this.dialog.chooser.getSelectedFile().toString()));115 dialog.chooser.getSelectedFile().toString())); 116 116 } 117 117 -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/actions/StreetsideWalkAction.java
r34348 r34349 55 55 if (pane.getValue() != null 56 56 && (int) pane.getValue() == JOptionPane.OK_OPTION) { 57 th is.thread = new WalkThread((int) dialog.spin.getValue(),57 thread = new WalkThread((int) dialog.spin.getValue(), 58 58 dialog.waitForPicture.isSelected(), 59 59 dialog.followSelection.isSelected(), dialog.goForward.isSelected()); … … 76 76 */ 77 77 public void addListener(WalkListener lis) { 78 this.listeners.add(lis);78 listeners.add(lis); 79 79 } 80 80 … … 86 86 */ 87 87 public void removeListener(WalkListener lis) { 88 this.listeners.remove(lis);88 listeners.remove(lis); 89 89 } 90 90 91 91 private void fireWalkStarted() { 92 if ( this.listeners.isEmpty()) {92 if (listeners.isEmpty()) { 93 93 return; 94 94 } 95 for (WalkListener lis : this.listeners) {96 lis.walkStarted(th is.thread);95 for (WalkListener lis : listeners) { 96 lis.walkStarted(thread); 97 97 } 98 98 } -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/actions/StreetsideZoomAction.java
r34348 r34349 6 6 import java.awt.event.ActionEvent; 7 7 8 import org.openstreetmap.josm.plugins.streetside.StreetsideLayer; 9 8 10 import org.openstreetmap.josm.actions.JosmAction; 9 11 import org.openstreetmap.josm.gui.MainApplication; 10 12 import org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage; 11 13 import org.openstreetmap.josm.plugins.streetside.StreetsideDataListener; 12 import org.openstreetmap.josm.plugins.streetside.StreetsideLayer;13 14 import org.openstreetmap.josm.plugins.streetside.StreetsidePlugin; 14 15 import org.openstreetmap.josm.tools.ImageProvider; -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/actions/WalkThread.java
r34333 r34349 2 2 package org.openstreetmap.josm.plugins.streetside.actions; 3 3 4 import java.awt.image.BufferedImage; 5 4 6 import javax.swing.SwingUtilities; 5 7 6 import org.openstreetmap.josm.gui.Notification;7 8 import org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage; 8 9 import org.openstreetmap.josm.plugins.streetside.StreetsideData; 9 10 import org.openstreetmap.josm.plugins.streetside.StreetsideDataListener; 11 import org.openstreetmap.josm.plugins.streetside.StreetsideImage; 10 12 import org.openstreetmap.josm.plugins.streetside.StreetsideLayer; 11 import org.openstreetmap.josm.plugins.streetside.StreetsidePlugin;12 13 import org.openstreetmap.josm.plugins.streetside.cache.CacheUtils; 13 import org.openstreetmap.josm.plugins.streetside.cache.StreetsideCache;14 14 import org.openstreetmap.josm.plugins.streetside.gui.StreetsideMainDialog; 15 import org.openstreetmap.josm.tools.I18n; 16 import org.openstreetmap.josm.tools.Logging; 17 18 import org.openstreetmap.josm.plugins.streetside.StreetsideImage; 15 19 16 20 17 /** … … 30 27 private final boolean followSelected; 31 28 private final boolean goForward; 29 private BufferedImage lastImage; 32 30 private volatile boolean paused; 33 31 … … 54 52 public void run() { 55 53 try { 56 StreetsideAbstractImage curSelection; 57 StreetsideImage curImage; 58 while ( 59 !end && 60 (curSelection = data.getSelectedImage().next()) != null && 61 (curImage = curSelection instanceof StreetsideImage ? (StreetsideImage) curSelection : null) != null 62 ) { 63 // Predownload next 10 thumbnails. 64 preDownloadImages(curImage, 10, CacheUtils.PICTURE.THUMBNAIL, goForward); 65 if (waitForFullQuality) { 66 // Start downloading 3 next full images. 67 preDownloadImages(curImage, 3, CacheUtils.PICTURE.FULL_IMAGE, goForward); 54 while (!end && data.getSelectedImage().next() != null) { 55 StreetsideAbstractImage image = data.getSelectedImage(); 56 if (image != null && image.next() instanceof StreetsideImage) { 57 // Predownload next 10 thumbnails. 58 preDownloadImages((StreetsideImage) image.next(), 10, CacheUtils.PICTURE.THUMBNAIL); 59 // TODO: WalkThread for cubemaps? @rrh 60 //preDownloadCubemaps((StreetsideImage) image.next(), 10, CacheUtils.PICTURE.CUBEMAP); 61 if (waitForFullQuality) { 62 // Start downloading 3 next full images. 63 StreetsideAbstractImage currentImage = image.next(); 64 preDownloadImages((StreetsideImage) currentImage, 3, CacheUtils.PICTURE.FULL_IMAGE); 65 // TODO: WalkThread for cubemaps? @rrh 66 /*if (StreetsideProperties.PREDOWNLOAD_CUBEMAPS.get().booleanValue()) { 67 preDownloadCubemaps((StreetsideImage) currentImage, 3, CacheUtils.PICTURE.CUBEMAP); 68 }*/ 69 } 68 70 } 69 71 try { 70 // Wait for picture for 1 minute. 71 final StreetsideCache cache = new StreetsideCache(curImage.getId(), waitForFullQuality ? StreetsideCache.Type.FULL_IMAGE : StreetsideCache.Type.THUMBNAIL); 72 int limit = 240; // 240 * 250 = 60000 ms 73 while (cache.get() == null) { 74 Thread.sleep(250); 75 if (limit-- < 0) { 76 new Notification(I18n.tr("Walk mode: Waiting for next image takes too long! Exiting walk mode…")) 77 .setIcon(StreetsidePlugin.LOGO.get()) 78 .show(); 79 end(); 80 return; 72 // Waits for full quality picture. 73 final BufferedImage displayImage = StreetsideMainDialog.getInstance().getStreetsideImageDisplay().getImage(); 74 if (waitForFullQuality && image instanceof StreetsideImage) { 75 while (displayImage == lastImage || displayImage == null || displayImage.getWidth() < 2048) { 76 Thread.sleep(100); 77 } 78 } else { // Waits for thumbnail. 79 while (displayImage == lastImage || displayImage == null || displayImage.getWidth() < 320) { 80 Thread.sleep(100); 81 81 } 82 82 } … … 84 84 Thread.sleep(100); 85 85 } 86 Thread.sleep(interval);86 wait(interval); 87 87 while (paused) { 88 88 Thread.sleep(100); 89 89 } 90 lastImage = StreetsideMainDialog.getInstance().getStreetsideImageDisplay().getImage(); 90 91 if (goForward) { 91 92 data.selectNext(followSelected); … … 94 95 } 95 96 } catch (InterruptedException e) { 96 end();97 97 return; 98 98 } 99 100 99 } 100 101 // TODO: WalkThread for cubemaps? @rrh 102 /*while (!end && data.getSelectedImage().next() != null) { 103 StreetsideAbstractImage cubemap = data.getSelectedImage(); 104 if (cubemap != null && cubemap.next() instanceof StreetsideCubemap) { 105 if (waitForFullQuality) { 106 // Start downloading 3 next full images. 107 108 // TODO: cubemap handling @rrh 109 preDownloadCubemaps((StreetsideCubemap) cubemap.next(), 6, CacheUtils.PICTURE.CUBEMAP); 110 } 111 } 112 try { 113 // Waits for full quality picture. 114 final BufferedImage[] displayCubemap = StreetsideMainDialog.getInstance().streetsideViewerDisplay.getCubemap(); 115 if (waitForFullQuality && cubemap instanceof StreetsideCubemap) { 116 // TODO: handle cubemap width? @rrh 117 while (displayCubemap == lastCubemap || displayCubemap == null || displayCubemap.getWidth() < 2048) { 118 Thread.sleep(100); 119 } 120 } else { // Waits for thumbnail. 121 // TODO: handle cubemap width? @rrh 122 while (displayCubemap == lastCubemap || displayCubemap == null || displayCubemap.getWidth() < 320) { 123 Thread.sleep(100); 124 } 125 } 126 while (paused) { 127 Thread.sleep(100); 128 } 129 wait(interval); 130 while (paused) { 131 Thread.sleep(100); 132 } 133 lastCubemap = StreetsideMainDialog.getInstance().streetsideViewerDisplay.getCubemap(); 134 // TODO: forward / previous for cubemap? @rrh 135 if (goForward) { 136 data.selectNext(followSelected); 137 } else { 138 data.selectPrevious(followSelected); 139 } 140 } catch (InterruptedException e) { 141 return; 142 } 143 }*/ 101 144 } catch (NullPointerException e) { 102 Logging.warn(e);103 end();104 145 // TODO: Avoid NPEs instead of waiting until they are thrown and then catching them 105 146 return; … … 108 149 } 109 150 110 /** 151 private void preDownloadCubemaps(StreetsideImage startImage, int n, CacheUtils.PICTURE type) { 152 if (n >= 1 && startImage != null) { 153 154 for (int i = 0; i < 6; i++) { 155 for (int j = 0; j < 4; j++) { 156 for (int k = 0; k < 4; k++) { 157 158 CacheUtils.downloadPicture(startImage, type); 159 if (startImage.next() instanceof StreetsideImage && n >= 2) { 160 preDownloadImages((StreetsideImage) startImage.next(), n - 1, type); 161 } 162 } 163 } 164 } 165 } 166 } 167 168 /** 111 169 * Downloads n images into the cache beginning from the supplied start-image (including the start-image itself). 112 170 * … … 114 172 * @param n the number of images to download 115 173 * @param type the quality of the image (full or thumbnail) 116 * @param goForward true if the next images, false if the previous ones should be downloaded 117 */ 118 private static void preDownloadImages(StreetsideImage startImage, int n, CacheUtils.PICTURE type, final boolean goForward) { 174 */ 175 private static void preDownloadImages(StreetsideImage startImage, int n, CacheUtils.PICTURE type) { 119 176 if (n >= 1 && startImage != null) { 120 177 CacheUtils.downloadPicture(startImage, type); 121 final StreetsideAbstractImage nextImg = goForward ? startImage.next() : startImage.previous(); 122 if (nextImg instanceof StreetsideImage && n >= 2) { 123 preDownloadImages((StreetsideImage) nextImg, n - 1, type, goForward); 178 if (startImage.next() instanceof StreetsideImage && n >= 2) { 179 preDownloadImages((StreetsideImage) startImage.next(), n - 1, type); 124 180 } 125 181 } … … 168 224 * Called when the walk stops by itself of forcefully. 169 225 */ 170 p rivatevoid end() {226 public void end() { 171 227 if (SwingUtilities.isEventDispatchThread()) { 172 228 end = true; … … 176 232 SwingUtilities.invokeLater(this::end); 177 233 } 234 // TODO: WalkThread for Cubemaps? @rrh 235 /*if (Platform.isEventDispatchThread()) { 236 end = true; 237 data.removeListener(this); 238 StreetsideViewerDialog.getInstance().setMode(StreetsideViewerDialog.MODE.NORMAL); 239 } else { 240 Platform.invokeLater(this::end); 241 }*/ 178 242 } 179 243 } -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/cache/package-info.java
r34334 r34349 2 2 /** 3 3 * This package is all about caching resources downloaded from 4 * <a href="https:// www.microsoft.com/en-us/maps/streetside">Streetside</a>4 * <a href="https://mapillary.com">mapillary.com</a> 5 5 * for faster access to those resources in the future. 6 6 */ -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/cubemap/CubemapBuilder.java
r34348 r34349 44 44 } 45 45 46 47 48 startTime = System.nanoTime();49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 46 @Override 47 public void selectedImageChanged(StreetsideAbstractImage oldImage, StreetsideAbstractImage newImage) { 48 startTime = System.currentTimeMillis(); 49 50 if (newImage != null) { 51 52 cubemap = null; 53 cubemap = new StreetsideCubemap(newImage.getId(), newImage.getLatLon(), newImage.getHe()); 54 cubemap.setCd(newImage.getCd()); 55 56 // download cubemap images in different threads and then subsequently 57 // set the cubeface images in JavaFX 58 downloadCubemapImages(cubemap.getId()); 59 } 60 } 61 62 public void reload(String imageId) { 63 if (cubemap != null && imageId.equals(cubemap.getId())) { 64 CubemapBuilder.getInstance().getCubemap().resetFaces2TileMap(); 65 downloadCubemapImages(imageId); 66 } 67 } 68 68 69 69 public void downloadCubemapImages(String imageId) { … … 75 75 int fails = 0; 76 76 77 long startTime = System. nanoTime();77 long startTime = System.currentTimeMillis(); 78 78 79 79 try { … … 102 102 for (Future<String> ff : results) { 103 103 104 Logging. info(I18n.tr("Completed tile downloading task {0} in {1}", ff.get(),105 CubemapUtils.msToString(startTime - System. nanoTime())));104 Logging.debug(I18n.tr("Completed tile downloading task {0} in {1}", ff.get(), 105 CubemapUtils.msToString(startTime - System.currentTimeMillis()))); 106 106 } 107 107 … … 115 115 + String.valueOf(Integer.valueOf(j).toString() + Integer.valueOf(k).toString())); 116 116 tasks.add(new TileDownloadingTask(tileId)); 117 Logging. info(117 Logging.debug( 118 118 I18n.tr("Starting tile downloading task for imageId {0}, cubeface {1}, tileID {2}", 119 119 imageId, CubemapUtils.getFaceNumberForCount(i), tileId)); … … 124 124 List<Future<String>> results = pool.invokeAll(tasks); 125 125 for (Future<String> ff : results) { 126 Logging. debug(I18n.tr("Completed tile downloading task {0} in {1}", ff.get(),127 CubemapUtils.msToString(startTime - System. nanoTime())));126 Logging.info(I18n.tr("Completed tile downloading task {0} in {1}", ff.get(), 127 CubemapUtils.msToString(startTime - System.currentTimeMillis()))); 128 128 } 129 129 } … … 134 134 } 135 135 136 long stopTime = System. nanoTime();136 long stopTime = System.currentTimeMillis(); 137 137 long runTime = stopTime - startTime; 138 138 139 Logging.info(I18n.tr(" Imagery downloading tasks completed for all tiles in {0} seconds.", runTime % 1000));139 Logging.info(I18n.tr("Tile imagery downloading tasks completed in {0}", CubemapUtils.msToString(runTime))); 140 140 141 141 if (fails > 0) { … … 164 164 165 165 if (tileCount == (CubemapUtils.NUM_SIDES * maxCols * maxRows)) { 166 Logging. debug(I18n.tr("{0} tile images ready for building cumbemap faces for cubemap {0}", tileCount,166 Logging.info(I18n.tr("{0} tile images ready for building cumbemap faces for cubemap {0}", tileCount, 167 167 CubemapBuilder.getInstance().getCubemap().getId())); 168 168 169 169 buildCubemapFaces(); 170 170 } else { 171 Logging. debug(I18n.tr("{0} tile images received for cubemap {1}", Integer.valueOf(tileCount).toString(),171 Logging.info(I18n.tr("{0} tile images received for cubemap {1}", Integer.valueOf(tileCount).toString(), 172 172 CubemapBuilder.getInstance().getCubemap().getId())); 173 173 } … … 246 246 StreetsideViewerPanel.getThreeSixtyDegreeViewerPanel().repaint(); 247 247 248 long endTime = System. nanoTime();248 long endTime = System.currentTimeMillis(); 249 249 long runTime = endTime - startTime; 250 250 Logging.info(I18n.tr("Completed downloading, assembling and setting cubemap imagery for cubemap {0} in {1}", 251 cubemap.getId(), runTime));251 cubemap.getId(), CubemapUtils.msToString(runTime))); 252 252 } 253 253 -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/cubemap/GraphicsUtils.java
r34348 r34349 44 44 BufferedImage res = null; 45 45 46 int pixelBuffer = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 2 :1;46 int pixelBuffer = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()?2:1; 47 47 48 48 tiles = cropMultiTiledImages(tiles, pixelBuffer); 49 49 50 int rows = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 4 : 2; // we assume the no. of rows and 51 // cols are known and each chunk 52 // has 53 // equal width and height 54 int cols = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 4 : 2; 50 int rows = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()?4:2; //we assume the no. of rows and cols are known and each chunk has equal width and height 51 int cols = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()?4:2; 55 52 56 53 int chunkWidth, chunkHeight; 57 54 58 59 55 chunkWidth = tiles[0].getWidth(); 56 chunkHeight = tiles[0].getHeight(); 60 57 61 //Initializing the final image62 BufferedImage img = new BufferedImage(chunkWidth * cols, chunkHeight *rows, BufferedImage.TYPE_INT_ARGB);58 //Initializing the final image 59 BufferedImage img = new BufferedImage(chunkWidth*cols, chunkHeight*rows, BufferedImage.TYPE_INT_ARGB); 63 60 64 65 66 67 // TODO: mirror image 68 61 int num = 0; 62 for (int i = 0; i < rows; i++) { 63 for (int j = 0; j < cols; j++) { 64 // TODO: this makes the image a mirror image. why!?! 65 img.createGraphics().drawImage(tiles[num], chunkWidth * j, chunkHeight * i, null); 69 66 70 int width = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 1014 : 510; 71 int height = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 1014 : 510; 67 // TODO: remove file test! 68 /*try { 69 ImageIO.write(img, "jpeg", new File("/Users/renerr18/Desktop/TileImagesTest/tile16b" + Long.valueOf(System.currentTimeMillis()).toString() + "createGraphicsAfter.jpeg")); 70 //ImageIO.write(res[i], "jpeg", outputfileAfter); 71 } catch (IOException e) { 72 // TODO Auto-generated catch block 73 e.printStackTrace(); 74 }*/ 72 75 73 res = new BufferedImage(StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 1014 : 510, 74 StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 1014 : 510, 75 BufferedImage.TYPE_INT_ARGB); 76 int width = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()?1014:510; 77 int height = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()?1014:510; 76 78 77 // Create mirror image pixel by pixel 78 for (int y = 0; y < height; y++) { 79 for (int lx = 0, rx = width - 1; lx < width; lx++, rx--) { 80 // lx starts from the left side of the image 81 // rx starts from the right side of the image 82 // lx is used since we are getting pixel from left side 83 // rx is used to set from right side 84 // get source pixel value 85 int p = img.getRGB(lx, y); 79 // BufferedImage for mirror image 80 res = new BufferedImage(StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()?1014:510, StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()?1014:510, 81 BufferedImage.TYPE_INT_ARGB); 86 82 87 // set mirror image pixel value 88 res.setRGB(rx, y, p); 89 } 90 } 91 num++; 92 } 93 } 83 // Create mirror image pixel by pixel 84 for (int y = 0; y < height; y++) 85 { 86 for (int lx = 0, rx = width - 1; lx < width; lx++, rx--) 87 { 88 // lx starts from the left side of the image 89 // rx starts from the right side of the image 90 // lx is used since we are getting pixel from left side 91 // rx is used to set from right side 92 // get source pixel value 93 int p = img.getRGB(lx, y); 94 94 95 Logging.debug("Image concatenated....."); 95 // set mirror image pixel value 96 res.setRGB(rx, y, p); 97 } 98 } 99 num++; 100 } 101 } 96 102 97 return res; 103 Logging.info("Image concatenated....."); 104 105 return res; 98 106 } 99 107 -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/cubemap/TileDownloadingTask.java
r34348 r34349 22 22 23 23 private String tileId; 24 private final long startTime = System. nanoTime();24 private final long startTime = System.currentTimeMillis(); 25 25 private StreetsideCache cache; 26 26 protected CubemapBuilder cb; … … 120 120 fireTileAdded(tileId); 121 121 122 long endTime = System. nanoTime();123 long runTime = endTime - startTime;124 Logging. info("Loaded image for tile {0} in {1} seconds", tileId, runTime);122 long endTime = System.currentTimeMillis(); 123 long runTime = startTime - endTime; 124 Logging.debug("Loaded image for tile {0} in {1} seconds", tileId, CubemapUtils.msToString(runTime)); 125 125 126 126 return tileId; -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/gui/StreetsideExportDialog.java
r34333 r34349 134 134 135 135 private static final long serialVersionUID = 1035332841101190301L; 136 private String lastPath; 136 137 private String lastPath; 137 138 private final StreetsideExportDialog dlg; 138 139 -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/gui/StreetsideImageDisplay.java
r34333 r34349 39 39 * 40 40 * @author nokutu 41 * @author renerr1842 *43 41 * @see StreetsideImageDisplay 44 42 * @see StreetsideMainDialog … … 82 80 visibleRect = StreetsideImageDisplay.this.visibleRect; 83 81 } 84 this.mouseIsDragging = false;82 mouseIsDragging = false; 85 83 selectedRect = null; 86 84 if (image != null && Math.min(getSize().getWidth(), getSize().getHeight()) > 0) { … … 91 89 // borders, this point is not calculated 92 90 // again if there was less than 1.5seconds since the last event. 93 if (e.getWhen() - this.lastTimeForMousePoint > 1500 || this.mousePointInImg == null) {94 this.lastTimeForMousePoint = e.getWhen();95 this.mousePointInImg = comp2imgCoord(visibleRect, e.getX(), e.getY());91 if (e.getWhen() - lastTimeForMousePoint > 1500 || mousePointInImg == null) { 92 lastTimeForMousePoint = e.getWhen(); 93 mousePointInImg = comp2imgCoord(visibleRect, e.getX(), e.getY()); 96 94 } 97 95 // Set the zoom to the visible rectangle in image coordinates … … 123 121 // cursor doesn't move on the image. 124 122 Rectangle drawRect = calculateDrawImageRectangle(visibleRect); 125 visibleRect.x = this.mousePointInImg.x123 visibleRect.x = mousePointInImg.x 126 124 + ((drawRect.x - e.getX()) * visibleRect.width) / drawRect.width; 127 visibleRect.y = this.mousePointInImg.y125 visibleRect.y = mousePointInImg.y 128 126 + ((drawRect.y - e.getY()) * visibleRect.height) / drawRect.height; 129 127 // The position is also limited by the image size … … 187 185 public void mousePressed(MouseEvent e) { 188 186 if (getImage() == null) { 189 this.mouseIsDragging = false;190 StreetsideImageDisplay.this.selectedRect = null;187 mouseIsDragging = false; 188 selectedRect = null; 191 189 return; 192 190 } … … 200 198 return; 201 199 if (e.getButton() == StreetsideProperties.PICTURE_DRAG_BUTTON.get()) { 202 this.mousePointInImg = comp2imgCoord(visibleRect, e.getX(), e.getY());203 this.mouseIsDragging = true;204 StreetsideImageDisplay.this.selectedRect = null;200 mousePointInImg = comp2imgCoord(visibleRect, e.getX(), e.getY()); 201 mouseIsDragging = true; 202 selectedRect = null; 205 203 } else if (e.getButton() == StreetsideProperties.PICTURE_ZOOM_BUTTON.get()) { 206 204 mousePointInImg = comp2imgCoord(visibleRect, e.getX(), e.getY()); 207 checkPointInVisibleRect( this.mousePointInImg, visibleRect);208 this.mouseIsDragging = false;209 StreetsideImageDisplay.this.selectedRect = new Rectangle(mousePointInImg.x, mousePointInImg.y, 0, 0);205 checkPointInVisibleRect(mousePointInImg, visibleRect); 206 mouseIsDragging = false; 207 selectedRect = new Rectangle(mousePointInImg.x, mousePointInImg.y, 0, 0); 210 208 StreetsideImageDisplay.this.repaint(); 211 209 } else { 212 this.mouseIsDragging = false;213 StreetsideImageDisplay.this.selectedRect = null;210 mouseIsDragging = false; 211 selectedRect = null; 214 212 } 215 213 } … … 217 215 @Override 218 216 public void mouseDragged(MouseEvent e) { 219 if (! this.mouseIsDragging && StreetsideImageDisplay.this.selectedRect == null)217 if (!mouseIsDragging && selectedRect == null) 220 218 return; 221 219 Image image; … … 226 224 } 227 225 if (image == null) { 228 this.mouseIsDragging = false;229 StreetsideImageDisplay.this.selectedRect = null;226 mouseIsDragging = false; 227 selectedRect = null; 230 228 return; 231 229 } 232 if ( this.mouseIsDragging) {230 if (mouseIsDragging) { 233 231 Point p = comp2imgCoord(visibleRect, e.getX(), e.getY()); 234 visibleRect.x += this.mousePointInImg.x - p.x;235 visibleRect.y += this.mousePointInImg.y - p.y;232 visibleRect.x += mousePointInImg.x - p.x; 233 visibleRect.y += mousePointInImg.y - p.y; 236 234 checkVisibleRectPos(image, visibleRect); 237 235 synchronized (StreetsideImageDisplay.this) { … … 239 237 } 240 238 StreetsideImageDisplay.this.repaint(); 241 } else if ( StreetsideImageDisplay.this.selectedRect != null) {239 } else if (selectedRect != null) { 242 240 Point p = comp2imgCoord(visibleRect, e.getX(), e.getY()); 243 241 checkPointInVisibleRect(p, visibleRect); 244 Rectangle rect = new Rectangle(p.x < this.mousePointInImg.x ? p.x245 : this.mousePointInImg.x, p.y < this.mousePointInImg.y ? p.y246 : this.mousePointInImg.y, p.x < this.mousePointInImg.x ? this.mousePointInImg.x247 - p.x : p.x - this.mousePointInImg.x,248 p.y < this.mousePointInImg.y ? this.mousePointInImg.y - p.y : p.y249 - this.mousePointInImg.y);242 Rectangle rect = new Rectangle(p.x < mousePointInImg.x ? p.x 243 : mousePointInImg.x, p.y < mousePointInImg.y ? p.y 244 : mousePointInImg.y, p.x < mousePointInImg.x ? mousePointInImg.x 245 - p.x : p.x - mousePointInImg.x, 246 p.y < mousePointInImg.y ? mousePointInImg.y - p.y : p.y 247 - mousePointInImg.y); 250 248 checkVisibleRectSize(image, rect); 251 249 checkVisibleRectPos(image, rect); 252 StreetsideImageDisplay.this.selectedRect = rect;250 selectedRect = rect; 253 251 StreetsideImageDisplay.this.repaint(); 254 252 } … … 257 255 @Override 258 256 public void mouseReleased(MouseEvent e) { 259 if (! this.mouseIsDragging && StreetsideImageDisplay.this.selectedRect == null)257 if (!mouseIsDragging && selectedRect == null) 260 258 return; 261 259 Image image; … … 264 262 } 265 263 if (image == null) { 266 this.mouseIsDragging = false;267 StreetsideImageDisplay.this.selectedRect = null;264 mouseIsDragging = false; 265 selectedRect = null; 268 266 return; 269 267 } 270 if ( this.mouseIsDragging) {271 this.mouseIsDragging = false;272 } else if ( StreetsideImageDisplay.this.selectedRect != null) {273 int oldWidth = StreetsideImageDisplay.this.selectedRect.width;274 int oldHeight = StreetsideImageDisplay.this.selectedRect.height;268 if (mouseIsDragging) { 269 mouseIsDragging = false; 270 } else if (selectedRect != null) { 271 int oldWidth = selectedRect.width; 272 int oldHeight = selectedRect.height; 275 273 // Check that the zoom doesn't exceed 2:1 276 if ( StreetsideImageDisplay.this.selectedRect.width < getSize().width / 2) {277 StreetsideImageDisplay.this.selectedRect.width = getSize().width / 2;278 } 279 if ( StreetsideImageDisplay.this.selectedRect.height < getSize().height / 2) {280 StreetsideImageDisplay.this.selectedRect.height = getSize().height / 2;274 if (selectedRect.width < getSize().width / 2) { 275 selectedRect.width = getSize().width / 2; 276 } 277 if (selectedRect.height < getSize().height / 2) { 278 selectedRect.height = getSize().height / 2; 281 279 } 282 280 // Set the same ratio for the visible rectangle and the display 283 281 // area 284 int hFact = StreetsideImageDisplay.this.selectedRect.height * getSize().width;285 int wFact = StreetsideImageDisplay.this.selectedRect.width * getSize().height;282 int hFact = selectedRect.height * getSize().width; 283 int wFact = selectedRect.width * getSize().height; 286 284 if (hFact > wFact) { 287 StreetsideImageDisplay.this.selectedRect.width = hFact / getSize().height;285 selectedRect.width = hFact / getSize().height; 288 286 } else { 289 StreetsideImageDisplay.this.selectedRect.height = wFact / getSize().width;287 selectedRect.height = wFact / getSize().width; 290 288 } 291 289 // Keep the center of the selection 292 if ( StreetsideImageDisplay.this.selectedRect.width != oldWidth) {293 StreetsideImageDisplay.this.selectedRect.x -= (StreetsideImageDisplay.this.selectedRect.width - oldWidth) / 2;294 } 295 if ( StreetsideImageDisplay.this.selectedRect.height != oldHeight) {296 StreetsideImageDisplay.this.selectedRect.y -= (StreetsideImageDisplay.this.selectedRect.height - oldHeight) / 2;297 } 298 checkVisibleRectSize(image, StreetsideImageDisplay.this.selectedRect);299 checkVisibleRectPos(image, StreetsideImageDisplay.this.selectedRect);290 if (selectedRect.width != oldWidth) { 291 selectedRect.x -= (selectedRect.width - oldWidth) / 2; 292 } 293 if (selectedRect.height != oldHeight) { 294 selectedRect.y -= (selectedRect.height - oldHeight) / 2; 295 } 296 checkVisibleRectSize(image, selectedRect); 297 checkVisibleRectPos(image, selectedRect); 300 298 synchronized (StreetsideImageDisplay.this) { 301 StreetsideImageDisplay.this.visibleRect = StreetsideImageDisplay.this.selectedRect;302 } 303 StreetsideImageDisplay.this.selectedRect = null;299 visibleRect = selectedRect; 300 } 301 selectedRect = null; 304 302 StreetsideImageDisplay.this.repaint(); 305 303 } … … 362 360 this.detections.addAll(detections); 363 361 } 364 this.selectedRect = null;362 selectedRect = null; 365 363 if (image != null) 366 this.visibleRect = new Rectangle(0, 0, image.getWidth(null),364 visibleRect = new Rectangle(0, 0, image.getWidth(null), 367 365 image.getHeight(null)); 368 366 } … … 376 374 */ 377 375 public BufferedImage getImage() { 378 return this.image;376 return image; 379 377 } 380 378 … … 404 402 + target.height, visibleRect.x, visibleRect.y, visibleRect.x 405 403 + visibleRect.width, visibleRect.y + visibleRect.height, null); 406 if ( this.selectedRect != null) {407 Point topLeft = img2compCoord(visibleRect, this.selectedRect.x,408 this.selectedRect.y);409 Point bottomRight = img2compCoord(visibleRect, this.selectedRect.x410 + this.selectedRect.width, this.selectedRect.y + this.selectedRect.height);404 if (selectedRect != null) { 405 Point topLeft = img2compCoord(visibleRect, selectedRect.x, 406 selectedRect.y); 407 Point bottomRight = img2compCoord(visibleRect, selectedRect.x 408 + selectedRect.width, selectedRect.y + selectedRect.height); 411 409 g.setColor(new Color(128, 128, 128, 180)); 412 410 g.fillRect(target.x, target.y, target.width, topLeft.y - target.y); -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/gui/StreetsideMainDialog.java
r34333 r34349 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.streetside.gui; 3 4 import static org.openstreetmap.josm.tools.I18n.marktr;5 import static org.openstreetmap.josm.tools.I18n.tr;6 import static org.openstreetmap.josm.tools.I18n.trc;7 3 8 4 import java.awt.BorderLayout; … … 18 14 import javax.imageio.ImageIO; 19 15 import javax.swing.AbstractAction; 16 import javax.swing.Action; 20 17 import javax.swing.JComponent; 21 18 import javax.swing.KeyStroke; … … 37 34 import org.openstreetmap.josm.plugins.streetside.cache.StreetsideCache; 38 35 import org.openstreetmap.josm.plugins.streetside.gui.imageinfo.ImageInfoHelpPopup; 39 import org.openstreetmap.josm.plugins.streetside. model.UserProfile;36 import org.openstreetmap.josm.plugins.streetside.gui.imageinfo.StreetsideViewerHelpPopup; 40 37 import org.openstreetmap.josm.plugins.streetside.utils.StreetsideProperties; 38 import org.openstreetmap.josm.tools.I18n; 41 39 import org.openstreetmap.josm.tools.ImageProvider; 42 40 import org.openstreetmap.josm.tools.Logging; … … 46 44 * 47 45 * @author nokutu 46 * @author renerr18 48 47 */ 49 48 public final class StreetsideMainDialog extends ToggleDialog implements 50 ICachedLoaderListener, StreetsideDataListener { 51 52 private static final long serialVersionUID = 6856496736429480600L; 53 54 private static final String BASE_TITLE = marktr("Streetside image"); 55 private static final String MESSAGE_SEPARATOR = " — "; 56 57 private static StreetsideMainDialog instance; 58 59 private volatile StreetsideAbstractImage image; 60 61 private final SideButton nextButton = new SideButton(new NextPictureAction()); 62 private final SideButton previousButton = new SideButton(new PreviousPictureAction()); 63 /** 64 * Button used to jump to the image following the red line 65 */ 66 public final SideButton redButton = new SideButton(new RedAction()); 67 /** 68 * Button used to jump to the image following the blue line 69 */ 70 public final SideButton blueButton = new SideButton(new BlueAction()); 71 72 private final SideButton playButton = new SideButton(new PlayAction()); 73 private final SideButton pauseButton = new SideButton(new PauseAction()); 74 private final SideButton stopButton = new SideButton(new StopAction()); 75 76 private ImageInfoHelpPopup imageInfoHelp; 77 78 /** 79 * Buttons mode. 80 * 81 * @author nokutu 82 */ 83 public enum MODE { 84 /** 85 * Standard mode to view pictures. 86 */ 87 NORMAL, 88 /** 89 * Mode when in walk. 90 */ 91 WALK 92 } 93 94 /** 95 * Object containing the shown image and that handles zoom and drag 96 */ 97 public final StreetsideImageDisplay streetsideImageDisplay; 98 99 private StreetsideCache imageCache; 100 private StreetsideCache thumbnailCache; 101 102 private StreetsideMainDialog() { 103 super(tr(BASE_TITLE), "streetside-main", tr("Open Streetside window"), null, 200, 104 true, StreetsidePreferenceSetting.class); 105 addShortcuts(); 106 streetsideImageDisplay = new StreetsideImageDisplay(); 107 108 blueButton.setForeground(Color.BLUE); 109 redButton.setForeground(Color.RED); 110 111 setMode(MODE.NORMAL); 112 } 113 114 /** 115 * Adds the shortcuts to the buttons. 116 */ 117 private void addShortcuts() { 118 nextButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 119 KeyStroke.getKeyStroke("PAGE_DOWN"), "next"); 120 nextButton.getActionMap().put("next", new NextPictureAction()); 121 previousButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 122 KeyStroke.getKeyStroke("PAGE_UP"), "previous"); 123 previousButton.getActionMap().put("previous", 124 new PreviousPictureAction()); 125 blueButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 126 KeyStroke.getKeyStroke("control PAGE_UP"), "blue"); 127 blueButton.getActionMap().put("blue", new BlueAction()); 128 redButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 129 KeyStroke.getKeyStroke("control PAGE_DOWN"), "red"); 130 redButton.getActionMap().put("red", new RedAction()); 131 } 132 133 /** 134 * Returns the unique instance of the class. 135 * 136 * @return The unique instance of the class. 137 */ 138 public static synchronized StreetsideMainDialog getInstance() { 139 if (instance == null) 140 instance = new StreetsideMainDialog(); 141 return instance; 142 } 143 144 /** 145 * @return true, iff the singleton instance is present 146 */ 147 public static boolean hasInstance() { 148 return instance != null; 149 } 150 151 public synchronized void setImageInfoHelp(ImageInfoHelpPopup popup) { 152 imageInfoHelp = popup; 153 } 154 155 /** 156 * Sets a new mode for the dialog. 157 * 158 * @param mode The mode to be set. Must not be {@code null}. 159 */ 160 public void setMode(MODE mode) { 161 switch (mode) { 162 case WALK: 163 createLayout( 164 streetsideImageDisplay, 165 Arrays.asList(playButton, pauseButton, stopButton) 166 ); 167 break; 168 case NORMAL: 169 default: 170 createLayout( 171 streetsideImageDisplay, 172 Arrays.asList(blueButton, previousButton, nextButton, redButton) 173 ); 174 break; 175 } 176 disableAllButtons(); 177 if (MODE.NORMAL.equals(mode)) { 178 updateImage(); 179 } 180 revalidate(); 181 repaint(); 182 } 183 184 /** 185 * Destroys the unique instance of the class. 186 */ 187 public static synchronized void destroyInstance() { 188 instance = null; 189 } 190 191 /** 192 * Downloads the full quality picture of the selected StreetsideImage and sets 193 * in the StreetsideImageDisplay object. 194 */ 195 public synchronized void updateImage() { 196 updateImage(true); 197 } 198 199 /** 200 * Downloads the picture of the selected StreetsideImage and sets in the 201 * StreetsideImageDisplay object. 202 * 203 * @param fullQuality If the full quality picture must be downloaded or just the 204 * thumbnail. 205 */ 206 public synchronized void updateImage(boolean fullQuality) { 207 if (!SwingUtilities.isEventDispatchThread()) { 208 SwingUtilities.invokeLater(this::updateImage); 209 } else { 210 if (!StreetsideLayer.hasInstance()) { 211 return; 212 } 213 if (image == null) { 214 streetsideImageDisplay.setImage(null, null); 215 setTitle(tr(BASE_TITLE)); 216 disableAllButtons(); 217 return; 218 } 219 220 if (imageInfoHelp != null && StreetsideProperties.IMAGEINFO_HELP_COUNTDOWN.get() > 0 && imageInfoHelp.showPopup()) { 221 // Count down the number of times the popup will be displayed 222 StreetsideProperties.IMAGEINFO_HELP_COUNTDOWN.put(StreetsideProperties.IMAGEINFO_HELP_COUNTDOWN.get() - 1); 223 } 224 225 // Enables/disables next/previous buttons 226 nextButton.setEnabled(false); 227 previousButton.setEnabled(false); 228 if (image.getSequence() != null) { 229 StreetsideAbstractImage tempImage = image; 230 while (tempImage.next() != null) { 231 tempImage = tempImage.next(); 232 if (tempImage.isVisible()) { 233 nextButton.setEnabled(true); 234 break; 235 } 236 } 237 } 238 if (image.getSequence() != null) { 239 StreetsideAbstractImage tempImage = image; 240 while (tempImage.previous() != null) { 241 tempImage = tempImage.previous(); 242 if (tempImage.isVisible()) { 243 previousButton.setEnabled(true); 244 break; 245 } 246 } 247 } 248 if (image instanceof StreetsideImage) { 249 StreetsideImage streetsideImage = (StreetsideImage) image; 250 // Downloads the thumbnail. 251 streetsideImageDisplay.setImage(null, null); 252 if (thumbnailCache != null) 253 thumbnailCache.cancelOutstandingTasks(); 254 thumbnailCache = new StreetsideCache(streetsideImage.getId(), 255 StreetsideCache.Type.THUMBNAIL); 256 try { 257 thumbnailCache.submit(this, false); 258 } catch (IOException e) { 259 Logging.error(e); 260 } 261 262 // Downloads the full resolution image. 263 if (fullQuality || new StreetsideCache(streetsideImage.getId(), 264 StreetsideCache.Type.FULL_IMAGE).get() != null) { 265 if (imageCache != null) 266 imageCache.cancelOutstandingTasks(); 267 imageCache = new StreetsideCache(streetsideImage.getId(), 268 StreetsideCache.Type.FULL_IMAGE); 269 try { 270 imageCache.submit(this, false); 271 } catch (IOException e) { 272 Logging.error(e); 273 } 274 } 275 } else if (image instanceof StreetsideImportedImage) { 276 StreetsideImportedImage streetsideImage = (StreetsideImportedImage) image; 277 try { 278 streetsideImageDisplay.setImage(streetsideImage.getImage(), null); 279 } catch (IOException e) { 280 Logging.error(e); 281 } 282 } 283 updateTitle(); 284 } 285 286 } 287 288 /** 289 * Disables all the buttons in the dialog 290 */ 291 private void disableAllButtons() { 292 nextButton.setEnabled(false); 293 previousButton.setEnabled(false); 294 blueButton.setEnabled(false); 295 redButton.setEnabled(false); 296 } 297 298 /** 299 * Sets a new StreetsideImage to be shown. 300 * 301 * @param image The image to be shown. 302 */ 303 public synchronized void setImage(StreetsideAbstractImage image) { 304 this.image = image; 305 } 306 307 /** 308 * Updates the title of the dialog. 309 */ 310 public synchronized void updateTitle() { 311 if (!SwingUtilities.isEventDispatchThread()) { 312 SwingUtilities.invokeLater(this::updateTitle); 313 } else if (image != null) { 314 StringBuilder title = new StringBuilder(tr(BASE_TITLE)); 315 if (image instanceof StreetsideImage) { 316 StreetsideImage streetsideImage = (StreetsideImage) image; 317 UserProfile user = streetsideImage.getUser(); 318 if (user != null) { 319 title.append(MESSAGE_SEPARATOR).append(user.getUsername()); 320 } 321 if (streetsideImage.getCd() != 0) { 322 title.append(MESSAGE_SEPARATOR).append(streetsideImage.getDate()); 323 } 324 setTitle(title.toString()); 325 } else if (image instanceof StreetsideImportedImage) { 326 StreetsideImportedImage streetsideImportedImage = (StreetsideImportedImage) image; 327 title.append(MESSAGE_SEPARATOR).append(streetsideImportedImage.getFile().getName()); 328 title.append(MESSAGE_SEPARATOR).append(streetsideImportedImage.getDate()); 329 setTitle(title.toString()); 330 } 331 } 332 } 333 334 /** 335 * Returns the {@link StreetsideAbstractImage} object which is being shown. 336 * 337 * @return The {@link StreetsideAbstractImage} object which is being shown. 338 */ 339 public synchronized StreetsideAbstractImage getImage() { 340 return image; 341 } 342 343 /** 344 * Action class form the next image button. 345 * 346 * @author nokutu 347 */ 348 private static class NextPictureAction extends AbstractAction { 349 350 private static final long serialVersionUID = 3023827221453154340L; 351 352 /** 353 * Constructs a normal NextPictureAction 354 */ 355 NextPictureAction() { 356 super(tr("Next picture")); 357 putValue(SHORT_DESCRIPTION, tr("Shows the next picture in the sequence")); 358 new ImageProvider("dialogs", "next").getResource().attachImageIcon(this, true); 359 } 360 361 @Override 362 public void actionPerformed(ActionEvent e) { 363 StreetsideLayer.getInstance().getData().selectNext(); 364 } 365 } 366 367 /** 368 * Action class for the previous image button. 369 * 370 * @author nokutu 371 */ 372 private static class PreviousPictureAction extends AbstractAction { 373 374 private static final long serialVersionUID = -6420511632957956012L; 375 376 /** 377 * Constructs a normal PreviousPictureAction 378 */ 379 PreviousPictureAction() { 380 super(tr("Previous picture")); 381 putValue(SHORT_DESCRIPTION, tr("Shows the previous picture in the sequence")); 382 new ImageProvider("dialogs", "previous").getResource().attachImageIcon(this, true); 383 } 384 385 @Override 386 public void actionPerformed(ActionEvent e) { 387 StreetsideLayer.getInstance().getData().selectPrevious(); 388 } 389 } 390 391 /** 392 * Action class to jump to the image following the red line. 393 * 394 * @author nokutu 395 */ 396 private static class RedAction extends AbstractAction { 397 398 private static final long serialVersionUID = -6480229431481386376L; 399 400 /** 401 * Constructs a normal RedAction 402 */ 403 RedAction() { 404 putValue(NAME, tr("Jump to red")); 405 putValue(SHORT_DESCRIPTION, 406 tr("Jumps to the picture at the other side of the red line")); 407 new ImageProvider("dialogs", "red").getResource().attachImageIcon(this, true); 408 } 409 410 @Override 411 public void actionPerformed(ActionEvent e) { 412 if (StreetsideMainDialog.getInstance().getImage() != null) { 413 StreetsideLayer.getInstance().getData() 414 .setSelectedImage(StreetsideLayer.getInstance().getNNearestImage(1), true); 415 } 416 } 417 } 418 419 /** 420 * Action class to jump to the image following the blue line. 421 * 422 * @author nokutu 423 */ 424 private static class BlueAction extends AbstractAction { 425 426 private static final long serialVersionUID = 6250690644594703314L; 427 428 /** 429 * Constructs a normal BlueAction 430 */ 431 BlueAction() { 432 putValue(NAME, tr("Jump to blue")); 433 putValue(SHORT_DESCRIPTION, 434 tr("Jumps to the picture at the other side of the blue line")); 435 new ImageProvider("dialogs", "blue").getResource().attachImageIcon(this, true); 436 } 437 438 @Override 439 public void actionPerformed(ActionEvent e) { 440 if (StreetsideMainDialog.getInstance().getImage() != null) { 441 StreetsideLayer.getInstance().getData() 442 .setSelectedImage(StreetsideLayer.getInstance().getNNearestImage(2), true); 443 } 444 } 445 } 446 447 private static class StopAction extends AbstractAction implements WalkListener { 448 449 private static final long serialVersionUID = -6561451575815789198L; 450 451 private WalkThread thread; 452 453 /** 454 * Constructs a normal StopAction 455 */ 456 StopAction() { 457 putValue(NAME, trc("as synonym to halt or stand still", "Stop")); 458 putValue(SHORT_DESCRIPTION, tr("Stops the walk.")); 459 new ImageProvider("dialogs/streetsideStop.png").getResource().attachImageIcon(this, true); 460 StreetsidePlugin.getWalkAction().addListener(this); 461 } 462 463 @Override 464 public void actionPerformed(ActionEvent e) { 465 if (thread != null) 466 thread.stopWalk(); 467 } 468 469 @Override 470 public void walkStarted(WalkThread thread) { 471 this.thread = thread; 472 } 473 } 474 475 private static class PlayAction extends AbstractAction implements WalkListener { 476 477 private static final long serialVersionUID = -17943404752082788L; 478 private transient WalkThread thread; 479 480 /** 481 * Constructs a normal PlayAction 482 */ 483 PlayAction() { 484 putValue(NAME, tr("Play")); 485 putValue(SHORT_DESCRIPTION, tr("Continues with the paused walk.")); 486 new ImageProvider("dialogs/streetsidePlay.png").getResource().attachImageIcon(this, true); 487 StreetsidePlugin.getWalkAction().addListener(this); 488 } 489 490 @Override 491 public void actionPerformed(ActionEvent e) { 492 if (thread != null) 493 thread.play(); 494 } 495 496 @Override 497 public void walkStarted(WalkThread thread) { 498 if (thread != null) 499 this.thread = thread; 500 } 501 } 502 503 private static class PauseAction extends AbstractAction implements WalkListener { 504 505 private static final long serialVersionUID = 4400240686337741192L; 506 507 private WalkThread thread; 508 509 /** 510 * Constructs a normal PauseAction 511 */ 512 PauseAction() { 513 putValue(NAME, tr("Pause")); 514 putValue(SHORT_DESCRIPTION, tr("Pauses the walk.")); 515 new ImageProvider("dialogs/streetsidePause.png").getResource().attachImageIcon(this, true); 516 StreetsidePlugin.getWalkAction().addListener(this); 517 } 518 519 @Override 520 public void actionPerformed(ActionEvent e) { 521 thread.pause(); 522 } 523 524 @Override 525 public void walkStarted(WalkThread thread) { 526 this.thread = thread; 527 } 528 } 529 530 /** 531 * When the pictures are returned from the cache, they are set in the 532 * {@link StreetsideImageDisplay} object. 533 */ 534 /*@Override 535 public void loadingFinished(final CacheEntry data, final CacheEntryAttributes attributes, final LoadResult result) { 536 if (!SwingUtilities.isEventDispatchThread()) { 537 SwingUtilities.invokeLater(() -> loadingFinished(data, attributes, result)); 538 } else if (data != null && result == LoadResult.SUCCESS) { 539 try { 540 BufferedImage img = ImageIO.read(new ByteArrayInputStream(data.getContent())); 541 if (img == null) { 542 return; 543 } 544 if ( 545 streetsideImageDisplay.getImage() == null 546 || img.getHeight() > this.streetsideImageDisplay.getImage().getHeight() 547 ) { 548 final StreetsideAbstractImage mai = getImage(); 549 this.streetsideImageDisplay.setImage( 550 img, 551 mai instanceof StreetsideImage ? ((StreetsideImage) getImage()).getDetections() : null 552 ); 553 } 554 } catch (IOException e) { 555 Logging.error(e); 556 } 557 } 558 }*/ 559 560 /** 561 * When the pictures are returned from the cache, they are set in the 562 * {@link StreetsideImageDisplay} object. 563 */ 564 @Override 565 public void loadingFinished(final CacheEntry data, final CacheEntryAttributes attributes, final LoadResult result) { 566 if (!SwingUtilities.isEventDispatchThread()) { 567 SwingUtilities.invokeLater(() -> loadingFinished(data, attributes, result)); 568 569 } else if (data != null && result == LoadResult.SUCCESS) { 570 try { 571 final BufferedImage img = ImageIO.read(new ByteArrayInputStream(data.getContent())); 572 if (img == null) { 573 return; 574 } 575 if ( 576 streetsideImageDisplay.getImage() == null 577 || img.getHeight() > streetsideImageDisplay.getImage().getHeight() 578 ) { 579 //final StreetsideAbstractImage mai = getImage(); 580 streetsideImageDisplay.setImage( 581 img, 582 //mai instanceof StreetsideImage ? ((StreetsideImage) getImage()).getDetections() : null 583 null); 584 } 585 } catch (final IOException e) { 586 Logging.error(e); 587 } 588 } 589 } 590 591 /** 592 * Creates the layout of the dialog. 593 * 594 * @param data The content of the dialog 595 * @param buttons The buttons where you can click 596 */ 597 public void createLayout(Component data, List<SideButton> buttons) { 598 removeAll(); 599 createLayout(data, true, buttons); 600 add(titleBar, BorderLayout.NORTH); 601 } 602 603 @Override 604 public void selectedImageChanged(StreetsideAbstractImage oldImage, StreetsideAbstractImage newImage) { 605 setImage(newImage); 606 updateImage(); 607 } 608 609 @Override 610 public void imagesAdded() { 611 // This method is enforced by StreetsideDataListener, but only selectedImageChanged() is needed 612 } 613 49 ICachedLoaderListener, StreetsideDataListener { 50 51 private static final long serialVersionUID = 2645654786827812861L; 52 53 public static final String BASE_TITLE = I18n.marktr("Microsoft Streetside image"); 54 private static final String MESSAGE_SEPARATOR = " — "; 55 56 private static StreetsideMainDialog instance; 57 58 private volatile StreetsideAbstractImage image; 59 60 public final SideButton nextButton = new SideButton(new NextPictureAction()); 61 public final SideButton previousButton = new SideButton(new PreviousPictureAction()); 62 /** 63 * Button used to jump to the image following the red line 64 */ 65 public final SideButton redButton = new SideButton(new RedAction()); 66 /** 67 * Button used to jump to the image following the blue line 68 */ 69 public final SideButton blueButton = new SideButton(new BlueAction()); 70 71 private final SideButton playButton = new SideButton(new PlayAction()); 72 private final SideButton pauseButton = new SideButton(new PauseAction()); 73 private final SideButton stopButton = new SideButton(new StopAction()); 74 75 private ImageInfoHelpPopup imageInfoHelp; 76 77 private StreetsideViewerHelpPopup streetsideViewerHelp; 78 79 /** 80 * Buttons mode. 81 * 82 * @author nokutu 83 */ 84 public enum MODE { 85 /** 86 * Standard mode to view pictures. 87 */ 88 NORMAL, 89 /** 90 * Mode when in walk. 91 */ 92 WALK 93 } 94 95 /** 96 * Object containing the shown image and that handles zoom and drag 97 */ 98 public StreetsideImageDisplay streetsideImageDisplay; 99 100 private StreetsideCache imageCache; 101 public StreetsideCache thumbnailCache; 102 103 private StreetsideMainDialog() { 104 super(I18n.tr(StreetsideMainDialog.BASE_TITLE), "streetside-main", I18n.tr("Open Streetside window"), null, 200, 105 true, StreetsidePreferenceSetting.class); 106 addShortcuts(); 107 108 streetsideImageDisplay = new StreetsideImageDisplay(); 109 110 blueButton.setForeground(Color.BLUE); 111 redButton.setForeground(Color.RED); 112 113 // TODO: Modes for cubemaps? @rrh 114 setMode(MODE.NORMAL); 115 } 116 117 /** 118 * Adds the shortcuts to the buttons. 119 */ 120 private void addShortcuts() { 121 nextButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 122 KeyStroke.getKeyStroke("PAGE_DOWN"), "next"); 123 nextButton.getActionMap().put("next", new NextPictureAction()); 124 previousButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 125 KeyStroke.getKeyStroke("PAGE_UP"), "previous"); 126 previousButton.getActionMap().put("previous", 127 new PreviousPictureAction()); 128 blueButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 129 KeyStroke.getKeyStroke("control PAGE_UP"), "blue"); 130 blueButton.getActionMap().put("blue", new BlueAction()); 131 redButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 132 KeyStroke.getKeyStroke("control PAGE_DOWN"), "red"); 133 redButton.getActionMap().put("red", new RedAction()); 134 } 135 136 /** 137 * Returns the unique instance of the class. 138 * 139 * @return The unique instance of the class. 140 */ 141 public static synchronized StreetsideMainDialog getInstance() { 142 if (StreetsideMainDialog.instance == null) { 143 StreetsideMainDialog.instance = new StreetsideMainDialog(); 144 } 145 return StreetsideMainDialog.instance; 146 } 147 148 /** 149 * @return true, iff the singleton instance is present 150 */ 151 public static boolean hasInstance() { 152 return StreetsideMainDialog.instance != null; 153 } 154 155 public synchronized void setImageInfoHelp(ImageInfoHelpPopup popup) { 156 imageInfoHelp = popup; 157 } 158 159 public synchronized void setStreetsideViewerHelp(StreetsideViewerHelpPopup popup) { 160 streetsideViewerHelp = popup; 161 } 162 163 /** 164 * @return the streetsideViewerHelp 165 */ 166 public StreetsideViewerHelpPopup getStreetsideViewerHelp() { 167 return streetsideViewerHelp; 168 } 169 170 /** 171 * Sets a new mode for the dialog. 172 * 173 * @param mode The mode to be set. Must not be {@code null}. 174 */ 175 public void setMode(MODE mode) { 176 switch (mode) { 177 case WALK: 178 createLayout( 179 streetsideImageDisplay, 180 Arrays.asList(playButton, pauseButton, stopButton) 181 ); 182 case NORMAL: 183 default: 184 createLayout( 185 streetsideImageDisplay, 186 Arrays.asList(blueButton, previousButton, nextButton, redButton) 187 ); 188 } 189 disableAllButtons(); 190 if (MODE.NORMAL.equals(mode)) { 191 updateImage(); 192 } } 193 194 /** 195 * Destroys the unique instance of the class. 196 */ 197 public static synchronized void destroyInstance() { 198 StreetsideMainDialog.instance = null; 199 } 200 201 /** 202 * Downloads the full quality picture of the selected StreetsideImage and sets 203 * in the StreetsideImageDisplay object. 204 */ 205 public synchronized void updateImage() { 206 updateImage(true); 207 } 208 209 /** 210 * Downloads the picture of the selected StreetsideImage and sets in the 211 * StreetsideImageDisplay object. 212 * 213 * @param fullQuality If the full quality picture must be downloaded or just the 214 * thumbnail. 215 */ 216 public synchronized void updateImage(boolean fullQuality) { 217 if (!SwingUtilities.isEventDispatchThread()) { 218 SwingUtilities.invokeLater(this::updateImage); 219 } else { 220 if (!StreetsideLayer.hasInstance()) { 221 return; 222 } 223 if (image == null) { 224 streetsideImageDisplay.setImage(null, null); 225 setTitle(I18n.tr(StreetsideMainDialog.BASE_TITLE)); 226 disableAllButtons(); 227 return; 228 } 229 230 // TODO: help for cubemaps? @rrh 231 if (imageInfoHelp != null && StreetsideProperties.IMAGEINFO_HELP_COUNTDOWN.get() > 0 && imageInfoHelp.showPopup()) { 232 // Count down the number of times the popup will be displayed 233 StreetsideProperties.IMAGEINFO_HELP_COUNTDOWN.put(StreetsideProperties.IMAGEINFO_HELP_COUNTDOWN.get() - 1); 234 } 235 236 // Enables/disables next/previous buttons 237 nextButton.setEnabled(false); 238 previousButton.setEnabled(false); 239 if (image.getSequence() != null) { 240 StreetsideAbstractImage tempImage = image; 241 while (tempImage.next() != null) { 242 tempImage = tempImage.next(); 243 if (tempImage.isVisible()) { 244 nextButton.setEnabled(true); 245 break; 246 } 247 } 248 } 249 if (image.getSequence() != null) { 250 StreetsideAbstractImage tempImage = image; 251 while (tempImage.previous() != null) { 252 tempImage = tempImage.previous(); 253 if (tempImage.isVisible()) { 254 previousButton.setEnabled(true); 255 break; 256 } 257 } 258 } 259 if (image instanceof StreetsideImage) { 260 final StreetsideImage streetsideImage = (StreetsideImage) image; 261 // Downloads the thumbnail. 262 streetsideImageDisplay.setImage(null, null); 263 if (thumbnailCache != null) { 264 thumbnailCache.cancelOutstandingTasks(); 265 } 266 thumbnailCache = new StreetsideCache(streetsideImage.getId(), 267 StreetsideCache.Type.THUMBNAIL); 268 try { 269 thumbnailCache.submit(this, false); 270 } catch (final IOException e) { 271 Logging.error(e); 272 } 273 274 // Downloads the full resolution image. 275 if (fullQuality || new StreetsideCache(streetsideImage.getId(), 276 StreetsideCache.Type.FULL_IMAGE).get() != null) { 277 if (imageCache != null) { 278 imageCache.cancelOutstandingTasks(); 279 } 280 imageCache = new StreetsideCache(streetsideImage.getId(), 281 StreetsideCache.Type.FULL_IMAGE); 282 try { 283 imageCache.submit(this, false); 284 } catch (final IOException e) { 285 Logging.error(e); 286 } 287 } 288 // TODO: handle/convert/remove "imported images" 289 } /*else if (image instanceof StreetsideImportedImage) { 290 final StreetsideImportedImage streetsideImage = (StreetsideImportedImage) image; 291 try { 292 streetsideImageDisplay.setImage(streetsideImage.getImage(), null); 293 } catch (final IOException e) { 294 Logging.error(e); 295 } 296 }*/ 297 updateTitle(); 298 } 299 } 300 301 /** 302 * Disables all the buttons in the dialog 303 */ 304 public /*private*/ void disableAllButtons() { 305 nextButton.setEnabled(false); 306 previousButton.setEnabled(false); 307 blueButton.setEnabled(false); 308 redButton.setEnabled(false); 309 } 310 311 /** 312 * Sets a new StreetsideImage to be shown. 313 * 314 * @param image The image to be shown. 315 */ 316 public synchronized void setImage(StreetsideAbstractImage image) { 317 this.image = image; 318 } 319 320 /** 321 * Updates the title of the dialog. 322 */ 323 // TODO: update title for 360 degree viewer? @rrh 324 public synchronized void updateTitle() { 325 if (!SwingUtilities.isEventDispatchThread()) { 326 SwingUtilities.invokeLater(this::updateTitle); 327 } else if (image != null) { 328 final StringBuilder title = new StringBuilder(I18n.tr(StreetsideMainDialog.BASE_TITLE)); 329 if (image instanceof StreetsideImage) { 330 final StreetsideImage streetsideImage = (StreetsideImage) image; 331 if (streetsideImage.getCd() != 0) { 332 title.append(StreetsideMainDialog.MESSAGE_SEPARATOR).append(streetsideImage.getDate()); 333 } 334 setTitle(title.toString()); 335 } else if (image instanceof StreetsideImportedImage) { 336 final StreetsideImportedImage mapillaryImportedImage = (StreetsideImportedImage) image; 337 title.append(StreetsideMainDialog.MESSAGE_SEPARATOR).append(mapillaryImportedImage.getFile().getName()); 338 title.append(StreetsideMainDialog.MESSAGE_SEPARATOR).append(mapillaryImportedImage.getDate()); 339 setTitle(title.toString()); 340 } 341 } 342 } 343 344 /** 345 * Returns the {@link StreetsideAbstractImage} object which is being shown. 346 * 347 * @return The {@link StreetsideAbstractImage} object which is being shown. 348 */ 349 public synchronized StreetsideAbstractImage getImage() { 350 return image; 351 } 352 353 /** 354 * Action class form the next image button. 355 * 356 * @author nokutu 357 */ 358 private static class NextPictureAction extends AbstractAction { 359 360 private static final long serialVersionUID = 6333692154558730392L; 361 362 /** 363 * Constructs a normal NextPictureAction 364 */ 365 NextPictureAction() { 366 super(I18n.tr("Next picture")); 367 putValue(Action.SHORT_DESCRIPTION, I18n.tr("Shows the next picture in the sequence")); 368 new ImageProvider("help", "next").getResource().attachImageIcon(this, true); 369 } 370 371 @Override 372 public void actionPerformed(ActionEvent e) { 373 StreetsideLayer.getInstance().getData().selectNext(); 374 } 375 } 376 377 /** 378 * Action class for the previous image button. 379 * 380 * @author nokutu 381 */ 382 private static class PreviousPictureAction extends AbstractAction { 383 384 private static final long serialVersionUID = 4390593660514657107L; 385 386 /** 387 * Constructs a normal PreviousPictureAction 388 */ 389 PreviousPictureAction() { 390 super(I18n.tr("Previous picture")); 391 putValue(Action.SHORT_DESCRIPTION, I18n.tr("Shows the previous picture in the sequence")); 392 new ImageProvider("help", "previous").getResource().attachImageIcon(this, true); 393 } 394 395 @Override 396 public void actionPerformed(ActionEvent e) { 397 StreetsideLayer.getInstance().getData().selectPrevious(); 398 } 399 } 400 401 /** 402 * Action class to jump to the image following the red line. 403 * 404 * @author nokutu 405 */ 406 private static class RedAction extends AbstractAction { 407 408 private static final long serialVersionUID = -1244456062285831231L; 409 410 /** 411 * Constructs a normal RedAction 412 */ 413 RedAction() { 414 putValue(Action.NAME, I18n.tr("Jump to red")); 415 putValue(Action.SHORT_DESCRIPTION, 416 I18n.tr("Jumps to the picture at the other side of the red line")); 417 new ImageProvider("dialogs", "red").getResource().attachImageIcon(this, true); 418 } 419 420 // TODO: RedAction for cubemaps? @rrh 421 @Override 422 public void actionPerformed(ActionEvent e) { 423 if (StreetsideMainDialog.getInstance().getImage() != null) { 424 StreetsideLayer.getInstance().getData() 425 .setSelectedImage(StreetsideLayer.getInstance().getNNearestImage(1), true); 426 } 427 } 428 } 429 430 /** 431 * Action class to jump to the image following the blue line. 432 * 433 * @author nokutu 434 */ 435 private static class BlueAction extends AbstractAction { 436 437 private static final long serialVersionUID = 5951233534212838780L; 438 439 /** 440 * Constructs a normal BlueAction 441 */ 442 BlueAction() { 443 putValue(Action.NAME, I18n.tr("Jump to blue")); 444 putValue(Action.SHORT_DESCRIPTION, 445 I18n.tr("Jumps to the picture at the other side of the blue line")); 446 new ImageProvider("dialogs", "blue").getResource().attachImageIcon(this, true); 447 } 448 449 // TODO: BlueAction for cubemaps? 450 @Override 451 public void actionPerformed(ActionEvent e) { 452 if (StreetsideMainDialog.getInstance().getImage() != null) { 453 StreetsideLayer.getInstance().getData() 454 .setSelectedImage(StreetsideLayer.getInstance().getNNearestImage(2), true); 455 } 456 } 457 } 458 459 private static class StopAction extends AbstractAction implements WalkListener { 460 461 private static final long serialVersionUID = 8789972456611625341L; 462 463 private WalkThread thread; 464 465 /** 466 * Constructs a normal StopAction 467 */ 468 StopAction() { 469 putValue(Action.NAME, I18n.tr("Stop")); 470 putValue(Action.SHORT_DESCRIPTION, I18n.tr("Stops the walk.")); 471 new ImageProvider("dialogs/streetsideStop.png").getResource().attachImageIcon(this, true); 472 StreetsidePlugin.getStreetsideWalkAction().addListener(this); 473 } 474 475 @Override 476 public void actionPerformed(ActionEvent e) { 477 if (thread != null) { 478 thread.stopWalk(); 479 } 480 } 481 482 @Override 483 public void walkStarted(WalkThread thread) { 484 this.thread = thread; 485 } 486 } 487 488 private static class PlayAction extends AbstractAction implements WalkListener { 489 490 private static final long serialVersionUID = -1572747020946842769L; 491 492 private transient WalkThread thread; 493 494 /** 495 * Constructs a normal PlayAction 496 */ 497 PlayAction() { 498 putValue(Action.NAME, I18n.tr("Play")); 499 putValue(Action.SHORT_DESCRIPTION, I18n.tr("Continues with the paused walk.")); 500 new ImageProvider("dialogs/streetsidePlay.png").getResource().attachImageIcon(this, true); 501 StreetsidePlugin.getStreetsideWalkAction().addListener(this); 502 } 503 504 @Override 505 public void actionPerformed(ActionEvent e) { 506 if (thread != null) { 507 thread.play(); 508 } 509 } 510 511 @Override 512 public void walkStarted(WalkThread thread) { 513 if (thread != null) { 514 this.thread = thread; 515 } 516 } 517 } 518 519 private static class PauseAction extends AbstractAction implements WalkListener { 520 521 /** 522 * 523 */ 524 private static final long serialVersionUID = -8758326399460817222L; 525 private WalkThread thread; 526 527 /** 528 * Constructs a normal PauseAction 529 */ 530 PauseAction() { 531 putValue(Action.NAME, I18n.tr("Pause")); 532 putValue(Action.SHORT_DESCRIPTION, I18n.tr("Pauses the walk.")); 533 new ImageProvider("dialogs/streetsidePause.png").getResource().attachImageIcon(this, true); 534 StreetsidePlugin.getStreetsideWalkAction().addListener(this); 535 } 536 537 @Override 538 public void actionPerformed(ActionEvent e) { 539 thread.pause(); 540 } 541 542 @Override 543 public void walkStarted(WalkThread thread) { 544 this.thread = thread; 545 } 546 } 547 548 /** 549 * When the pictures are returned from the cache, they are set in the 550 * {@link StreetsideImageDisplay} object. 551 */ 552 @Override 553 public void loadingFinished(final CacheEntry data, final CacheEntryAttributes attributes, final LoadResult result) { 554 if (!SwingUtilities.isEventDispatchThread()) { 555 SwingUtilities.invokeLater(() -> loadingFinished(data, attributes, result)); 556 557 } else if (data != null && result == LoadResult.SUCCESS) { 558 try { 559 final BufferedImage img = ImageIO.read(new ByteArrayInputStream(data.getContent())); 560 if (img == null) { 561 return; 562 } 563 if ( 564 streetsideImageDisplay.getImage() == null 565 || img.getHeight() > streetsideImageDisplay.getImage().getHeight() 566 ) { 567 //final StreetsideAbstractImage mai = getImage(); 568 streetsideImageDisplay.setImage( 569 img, 570 //mai instanceof StreetsideImage ? ((StreetsideImage) getImage()).getDetections() : null 571 null); 572 } 573 } catch (final IOException e) { 574 Logging.error(e); 575 } 576 } 577 } 578 579 580 /** 581 * Creates the layout of the dialog. 582 * 583 * @param data The content of the dialog 584 * @param buttons The buttons where you can click 585 */ 586 public void createLayout(Component data, List<SideButton> buttons) { 587 removeAll(); 588 createLayout(data, true, buttons); 589 add(titleBar, BorderLayout.NORTH); 590 } 591 592 @Override 593 public void selectedImageChanged(StreetsideAbstractImage oldImage, StreetsideAbstractImage newImage) { 594 setImage(newImage); 595 updateImage(); 596 } 597 598 @Override 599 public void imagesAdded() { 600 // This method is enforced by StreetsideDataListener, but only selectedImageChanged() is needed 601 } 602 603 /** 604 * @return the streetsideImageDisplay 605 */ 606 public StreetsideImageDisplay getStreetsideImageDisplay() { 607 return streetsideImageDisplay; 608 } 609 610 /** 611 * @param streetsideImageDisplay the streetsideImageDisplay to set 612 */ 613 public void setStreetsideImageDisplay(StreetsideImageDisplay streetsideImageDisplay) { 614 this.streetsideImageDisplay = streetsideImageDisplay; 615 } 616 617 /** 618 * @return the streetsideImageDisplay 619 */ 620 /*public StreetsideViewerDisplay getStreetsideViewerDisplay() { 621 return streetsideViewerDisplay; 622 }*/ 623 624 /** 625 * @param streetsideImageDisplay the streetsideImageDisplay to set 626 */ 627 /*public void setStreetsideViewerDisplay(StreetsideViewerDisplay streetsideViewerDisplay) { 628 streetsideViewerDisplay = streetsideViewerDisplay; 629 }*/ 630 631 /*private StreetsideViewerDisplay initStreetsideViewerDisplay() { 632 StreetsideViewerDisplay res = new StreetsideViewerDisplay(); 633 //this.add(streetsideViewerDisplay); 634 635 636 Platform.runLater(new Runnable() { 637 @Override 638 public void run() { 639 Scene scene; 640 try { 641 scene = StreetsideViewerDisplay.createScene(); 642 res.setScene(scene); 643 } catch (NonInvertibleTransformException e) { 644 // TODO Auto-generated catch block 645 e.printStackTrace(); 646 } 647 } 648 }); 649 return res; 650 }*/ 614 651 } -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/gui/boilerplate/package-info.java
r34334 r34349 1 1 // License: GPL. For details, see LICENSE file. 2 2 /** 3 * The GUI components that are special to the streetsideplugin.3 * The GUI components that are special to the mapillary plugin. 4 4 */ 5 5 package org.openstreetmap.josm.plugins.streetside.gui.boilerplate; -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/gui/imageinfo/ImageInfoPanel.java
r34348 r34349 12 12 13 13 import javax.swing.ImageIcon; 14 import javax.swing.JCheckBox;15 14 import javax.swing.JLabel; 16 15 import javax.swing.JPanel; … … 19 18 import org.apache.commons.logging.Log; 20 19 import org.apache.commons.logging.LogFactory; 21 22 import org.openstreetmap.josm.data.SelectionChangedListener; 23 import org.openstreetmap.josm.data.osm.DataSet; 20 import org.openstreetmap.josm.data.osm.DataSelectionListener; 24 21 import org.openstreetmap.josm.data.osm.OsmPrimitive; 25 22 import org.openstreetmap.josm.data.osm.Tag; … … 37 34 import org.openstreetmap.josm.tools.I18n; 38 35 39 public final class ImageInfoPanel extends ToggleDialog implements StreetsideDataListener, SelectionChangedListener {36 public final class ImageInfoPanel extends ToggleDialog implements StreetsideDataListener, DataSelectionListener { 40 37 private static final long serialVersionUID = 4141847503072417190L; 41 38 private static final Log L = LogFactory.getLog(ImageInfoPanel.class); … … 43 40 private static final ImageIcon EMPTY_USER_AVATAR = new ImageIcon(new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB)); 44 41 45 private final JLabel numDetectionsLabel;46 private final JCheckBox showDetectionsCheck;42 //private final JLabel numDetectionsLabel; 43 //private final JCheckBox showDetectionsCheck; 47 44 private final JLabel usernameLabel; 48 45 private final JTextPane imgKeyValue; … … 62 59 150 63 60 ); 64 DataSet.addSelectionListener(this); 65 66 numDetectionsLabel = new JLabel(); 67 numDetectionsLabel.setFont(numDetectionsLabel.getFont().deriveFont(Font.PLAIN)); 68 69 showDetectionsCheck = new JCheckBox(I18n.tr("Show detections on top of image")); 70 71 // no selections currently available for Streetside 72 showDetectionsCheck.setSelected(false); 61 SelectionEventManager.getInstance().addSelectionListener(this); 62 63 //numDetectionsLabel = new JLabel(); 64 //numDetectionsLabel.setFont(numDetectionsLabel.getFont().deriveFont(Font.PLAIN)); 65 66 //showDetectionsCheck = new JCheckBox(I18n.tr("Show detections on top of image")); 67 //showDetectionsCheck.setSelected(StreetsideProperties.SHOW_DETECTED_SIGNS.get()); 68 /*showDetectionsCheck.addActionListener( 69 action -> StreetsideProperties.SHOW_DETECTED_SIGNS.put(showDetectionsCheck.isSelected()) 70 ); 71 StreetsideProperties.SHOW_DETECTED_SIGNS.addListener( 72 valueChange -> showDetectionsCheck.setSelected(StreetsideProperties.SHOW_DETECTED_SIGNS.get()) 73 );*/ 73 74 74 75 usernameLabel = new JLabel(); … … 119 120 gbc.gridy = 0; 120 121 gbc.anchor = GridBagConstraints.LINE_START; 121 root.add(numDetectionsLabel, gbc);122 gbc.gridy++;123 root.add(showDetectionsCheck, gbc);124 gbc.gridy++;122 //root.add(numDetectionsLabel, gbc); 123 //gbc.gridy++; 124 //root.add(showDetectionsCheck, gbc); 125 //gbc.gridy++; 125 126 root.add(usernameLabel, gbc); 126 127 gbc.gridy++; … … 171 172 172 173 /* (non-Javadoc) 173 * @see org.openstreetmap.josm.plugins. mapillary.MapillaryDataListener#selectedImageChanged(org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage, org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage)174 * @see org.openstreetmap.josm.plugins.streetside.StreetsideDataListener#selectedImageChanged(org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage, org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage) 174 175 */ 175 176 @Override … … 181 182 )); 182 183 183 numDetectionsLabel.setText(I18n.tr("{0} detections", newImage instanceof StreetsideImage ? ((StreetsideImage) newImage).getDetections().size() : 0));184 //numDetectionsLabel.setText(I18n.tr("{0} detections", newImage instanceof StreetsideImage ? ((StreetsideImage) newImage).getDetections().size() : 0)); 184 185 imgKeyValue.setEnabled(newImage instanceof StreetsideImage); 185 186 final String newImageKey = newImage instanceof StreetsideImage ? ((StreetsideImage) newImage).getId(): null; … … 208 209 } 209 210 210 // Currently no user info supported in Streetside plugin 211 final UserProfile user = null; 211 final UserProfile user = newImage instanceof StreetsideImage ? ((StreetsideImage) newImage).getUser() : null; 212 212 usernameLabel.setEnabled(user != null); 213 213 if (user != null) { … … 232 232 */ 233 233 @Override 234 public synchronized void selectionChanged(final Collection<? extends OsmPrimitive> sel) { 234 public synchronized void selectionChanged(final SelectionChangeEvent event) { 235 final Collection<? extends OsmPrimitive> sel = event.getSelection(); 235 236 L.debug(String.format("Selection changed. %d primitives are selected.", sel == null ? 0 : sel.size())); 236 237 addStreetsideTagAction.setTarget(sel != null && sel.size() == 1 ? sel.iterator().next() : null); -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/gui/imageinfo/StreetsideViewerPanel.java
r34333 r34349 84 84 checkPanel.add(privacyLink, BorderLayout.PAGE_END); 85 85 86 add(checkPanel, BorderLayout. SOUTH);86 add(checkPanel, BorderLayout.PAGE_START); 87 87 add(threeSixtyDegreeViewerPanel, BorderLayout.CENTER); 88 88 -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/gui/package-info.java
r34334 r34349 1 1 // License: GPL. For details, see LICENSE file. 2 2 /** 3 * The GUI components that are special to the streetsideplugin.3 * The GUI components that are special to the mapillary plugin. 4 4 */ 5 5 package org.openstreetmap.josm.plugins.streetside.gui; -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/io/download/SequenceDownloadRunnable.java
r34348 r34349 48 48 } 49 49 50 StreetsideSequence seq = new StreetsideSequence(null); 50 StreetsideSequence seq = new StreetsideSequence(StreetsideSequenceIdGenerator.generateId()); 51 52 // TODO: how can LatLon and heading / camera angles (he attribute) be set for a sequence? 53 // and does it make sense? @rrh 51 54 52 55 List<StreetsideImage> bubbleImages = new ArrayList<>(); 53 56 54 final long startTime = System. nanoTime();57 final long startTime = System.currentTimeMillis(); 55 58 56 59 ObjectMapper mapper = new ObjectMapper(); … … 64 67 try { 65 68 66 JsonParser parser = mapper.getFactory().createParser(new BufferedInputStream(con.getInputStream())); 67 if (parser.nextToken() != JsonToken.START_ARRAY) { 68 parser.close(); 69 throw new IllegalStateException("Expected an array"); 70 } 71 72 StreetsideImage previous = null; 73 74 while (parser.nextToken() == JsonToken.START_OBJECT) { 69 JsonParser parser = mapper.getFactory().createParser(new BufferedInputStream(con.getInputStream())); 70 if(parser.nextToken() != JsonToken.START_ARRAY) { 71 parser.close(); 72 throw new IllegalStateException("Expected an array"); 73 } 74 75 76 StreetsideImage previous = null; 77 78 while (parser.nextToken() == JsonToken.START_OBJECT) { 75 79 // read everything from this START_OBJECT to the matching END_OBJECT 76 80 // and return it as a tree model ObjectNode … … 79 83 if (node.get("id") != null && node.get("la") != null && node.get("lo") != null) { 80 84 StreetsideImage image = new StreetsideImage(CubemapUtils.convertDecimal2Quaternary(node.path("id").asLong()), node.path("la").asDouble(), node.get("lo").asDouble()); 81 if (previous != null) { 82 previous.setNe(image.getNe()); 85 if(previous!=null) { 86 // Analyze sequence behaviour 87 //previous.setNext(image.) 83 88 } 84 89 image.setAd(node.path("ad").asInt()); … … 93 98 image.setPi(node.path("pi").asDouble()); 94 99 image.setPr(node.path("pr").asLong()); 100 // TODO: inner class @rrh 101 // image.setRn(node.path("rn").asText()); 95 102 image.setRo(node.path("ro").asDouble()); 96 103 … … 98 105 List<StreetsideImage> tiles = new ArrayList<StreetsideImage>(); 99 106 100 EnumSet.allOf(CubemapUtils.CubemapFaces.class).forEach(face -> { 101 102 for (int i = 0; i < 4; i++) { 103 // Initialize four-tiled cubemap faces (four images per cube side with 18-length 104 // Quadkey) 105 if (!StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()) { 106 StreetsideImage tile = new StreetsideImage(String.valueOf(image.getId() + Integer.valueOf(i))); 107 tiles.add(tile); 108 } 109 // Initialize four-tiled cubemap faces (four images per cub eside with 20-length 110 // Quadkey) 111 if (StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()) { 112 for (int j = 0; j < 4; j++) { 113 StreetsideImage tile = new StreetsideImage( 114 String.valueOf( 115 image.getId() + face.getValue() + CubemapUtils.rowCol2StreetsideCellAddressMap 116 .get(String.valueOf(Integer.valueOf(i).toString() + Integer.valueOf(j).toString())) 117 )); 118 tiles.add(tile 119 ); 120 } 121 } 122 } 123 }); 124 125 bubbleImages.add(image); 126 Logging.debug("Added image with id <" + image.getId() + ">"); 107 // TODO: set previous and next @rrh 108 109 EnumSet.allOf(CubemapUtils.CubemapFaces.class).forEach(face -> { 110 111 for (int i = 0; i < 4; i++) { 112 // Initialize four-tiled cubemap faces (four images per cube side with 18-length 113 // Quadkey) 114 //if (StreetsideProperties.CUBEFACE_SIZE.get().intValue() == 4) { 115 if (!StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()) { 116 StreetsideImage tile = new StreetsideImage( 117 String.valueOf(image.getId() + Integer.valueOf(i))); 118 tiles.add(tile); 119 } 120 // Initialize four-tiled cubemap faces (four images per cub eside with 20-length 121 // Quadkey) 122 //if (StreetsideProperties.CUBEFACE_SIZE.get().intValue() == 16) { 123 if (StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()) { 124 for (int j = 0; j < 4; j++) { 125 StreetsideImage tile = new StreetsideImage(String.valueOf(image.getId() 126 + face.getValue() + CubemapUtils.rowCol2StreetsideCellAddressMap 127 .get(String.valueOf(Integer.valueOf(i).toString() + Integer.valueOf(j).toString())))); 128 tiles.add(tile); 129 } 130 } 131 } 132 }); 133 134 bubbleImages.add(image); 135 Logging.info("Added image with id <" + image.getId() + ">"); 136 // TODO: double check whether this pre-caches successfullly @rrh 137 //StreetsideData.downloadSurroundingCubemaps(image); 127 138 128 139 } 129 140 } 130 141 131 parser.close(); 142 parser.close(); 143 144 //StreetsideImage[] images; 145 146 // First load all of the 'bubbles' from the request as Streetside Images 147 /*List<StreetsideImage> images = mapper 148 .readValue(new BufferedInputStream(con.getInputStream()), new TypeReference<List<StreetsideImage>>() {}); 149 */ 150 151 152 //images = mapper.readValue(new BufferedInputStream(con.getInputStream()), StreetsideImage[].class); 153 154 /*for (StreetsideImage image : bubbleImages) { 155 image = JsonStreetsideSequencesDecoder.decodeBubbleData(image); 156 if(image != null) bubbleImages.add(image); 157 }*/ 132 158 133 159 } catch (JsonParseException e) { … … 164 190 } 165 191 166 final long endTime = System. nanoTime();//currentTimeMillis();192 final long endTime = System.currentTimeMillis(); 167 193 Logging.info(I18n.tr("Sucessfully loaded {0} Microsoft Streetside images in {0} ",seq.getImages().size(),endTime-startTime%60)); 168 194 } -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/io/export/package-info.java
r34334 r34349 1 1 // License: GPL. For details, see LICENSE file. 2 2 /** 3 * Classes for exporting images that were downloaded from <a href="https:// www.microsoft.com/en-us/maps/streetside">Streetside</a>.3 * Classes for exporting images that were downloaded from <a href="https://mapillary.com">mapillary.com</a> . 4 4 */ 5 5 package org.openstreetmap.josm.plugins.streetside.io.export; -
applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/utils/StreetsideURL.java
r34348 r34349 236 236 } 237 237 238 239 240 241 242 243 244 245 246 247 248 249 final String urlStr = baseUrlPrefix + cubemapImageId + CubemapUtils.rowCol2StreetsideCellAddressMap 250 .get(String.valueOf(i) + String.valueOf(j)) + baseUrlSuffix; 251 res.add(new URL(urlStr)); 252 } catch (final MalformedURLException e) { 253 Logging.error(I18n.tr("Error creating URL String for cubemap {0}", cubemapImageId));254 e.printStackTrace(); 255 } 256 257 258 } 259 }); 260 261 break;262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 238 public static URL[] string2URLs(String baseUrlPrefix, String cubemapImageId, String baseUrlSuffix) { 239 List<URL> res = new ArrayList<>(); 240 241 switch (StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 16 : 4) { 242 243 case 16: 244 245 EnumSet.allOf(CubemapUtils.CubemapFaces.class).forEach(face -> { 246 for (int i = 0; i < 4; i++) { 247 for (int j = 0; j < 4; j++) { 248 try { 249 final String urlStr = baseUrlPrefix + cubemapImageId 250 + CubemapUtils.rowCol2StreetsideCellAddressMap 251 .get(String.valueOf(i) + String.valueOf(j)) 252 + baseUrlSuffix; 253 res.add(new URL(urlStr)); 254 } catch (final MalformedURLException e) { 255 Logging.error(I18n.tr("Error creating URL String for cubemap {0}", cubemapImageId)); 256 e.printStackTrace(); 257 } 258 259 } 260 } 261 }); 262 263 case 4: 264 EnumSet.allOf(CubemapUtils.CubemapFaces.class).forEach(face -> { 265 for (int i = 0; i < 4; i++) { 266 267 try { 268 final String urlStr = baseUrlPrefix + cubemapImageId 269 + CubemapUtils.rowCol2StreetsideCellAddressMap.get(String.valueOf(i)) + baseUrlSuffix; 270 res.add(new URL(urlStr)); 271 } catch (final MalformedURLException e) { 272 Logging.error(I18n.tr("Error creating URL String for cubemap {0}", cubemapImageId)); 273 e.printStackTrace(); 274 } 275 276 } 277 }); 278 break; // break is optional 279 default: 280 // Statements 281 } 282 return res.stream().toArray(URL[]::new); 283 } 284 284 285 285 /**
Note:
See TracChangeset
for help on using the changeset viewer.