Changeset 31513 in osm for applications/editors/josm/plugins
- Timestamp:
- 2015-08-21T20:44:15+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java
r31496 r31513 1 1 package org.openstreetmap.josm.plugins.mapillary; 2 2 3 import java.util.Date;4 import java.text.ParseException;5 3 import java.text.SimpleDateFormat; 6 4 import java.util.Calendar; 5 import java.util.Date; 7 6 import java.util.concurrent.locks.Lock; 8 7 import java.util.concurrent.locks.ReentrantLock; … … 25 24 * images to prevent concurrency problems. 26 25 */ 27 public static Lock LOCK = new ReentrantLock();26 public static final Lock LOCK = new ReentrantLock(); 28 27 29 28 /** The time the image was captured, in Epoch format. */ … … 35 34 /** Direction of the picture. */ 36 35 public final double ca; 37 /** If the image has been modified from its initial values. */38 public boolean isModified = false;39 36 /** Temporal position of the picture until it is uploaded. */ 40 37 public LatLon tempLatLon; … … 51 48 */ 52 49 protected double movingCa; 50 /** Whether the image must be drown in the map or not */ 53 51 private boolean visible; 54 52 55 53 /** 56 * Main constructor of the class.54 * Creates a new object in the given position and with the given direction. 57 55 * 58 56 * @param lat … … 74 72 75 73 /** 76 * Returns whether the object has been modified or not.77 *78 * @return true if the object has been modified; false otherwise.79 */80 public boolean isModified() {81 return this.isModified;82 }83 84 /**85 * Returns a LatLon object containing the current coordinates of the object.86 * When you are dragging the image this changes.87 *88 * @return The LatLon object with the position of the object.89 */90 public LatLon getLatLon() {91 return this.movingLatLon;92 }93 94 /**95 * Returns whether the image is visible on the map or not.96 *97 * @return True if the image is visible; false otherwise.98 */99 public boolean isVisible() {100 return this.visible;101 }102 103 /**104 * Set's whether the image should be visible on the map or not.105 *106 * @param visible107 * true if the image is set to be visible; false otherwise.108 */109 public void setVisible(boolean visible) {110 this.visible = visible;111 }112 113 /**114 * Returns the last fixed coordinates of the object.115 *116 * @return A LatLon object containing.117 */118 public LatLon getTempLatLon() {119 return this.tempLatLon;120 }121 122 /**123 * Moves the image temporally to another position124 *125 * @param x126 * The movement of the image in longitude units.127 * @param y128 * The movement of the image in latitude units.129 */130 public void move(double x, double y) {131 this.movingLatLon = new LatLon(this.tempLatLon.getY() + y,132 this.tempLatLon.getX() + x);133 this.isModified = true;134 }135 136 /**137 * Turns the image direction.138 *139 * @param ca140 * The angle the image is moving.141 */142 public void turn(double ca) {143 this.movingCa = this.tempCa + ca;144 this.isModified = true;145 }146 147 /**148 * Called when the mouse button is released, meaning that the picture has149 * stopped being dragged.150 */151 public void stopMoving() {152 this.tempLatLon = this.movingLatLon;153 this.tempCa = this.movingCa;154 }155 156 /**157 74 * Returns the direction towards the image has been taken. 158 75 * … … 164 81 165 82 /** 166 * Returns the last fixed direction of the object.167 * 168 * @return The l ast fixed direction of the object. 0 means north.169 */ 170 public double getTempCa() {171 return this. tempCa;83 * Returns the Epoch time when the image was captured. 84 * 85 * @return The long containing the Epoch time when the image was captured. 86 */ 87 public long getCapturedAt() { 88 return this.capturedAt; 172 89 } 173 90 … … 193 110 194 111 /** 195 * Sets the Epoch time when the picture was captured.196 *197 * @param capturedAt198 * Epoch time when the image was captured.199 */200 public void setCapturedAt(long capturedAt) {201 this.capturedAt = capturedAt;202 }203 204 /**205 * Returns the Epoch time when the image was captured.206 *207 * @return The long containing the Epoch time when the image was captured.208 */209 public long getCapturedAt() {210 return this.capturedAt;211 }212 213 /**214 112 * Returns the date the picture was taken in the given format. 215 113 * … … 228 126 229 127 /** 230 * Parses a string with a given format and returns the Epoch time. 231 * 232 * @param date 233 * The string containing the date. 234 * @param format 235 * The format of the date. 236 * @return The date in Epoch format. 237 * @throws ParseException 238 */ 239 public static long getEpoch(String date, String format) throws ParseException { 240 241 SimpleDateFormat formatter = new SimpleDateFormat(format); 242 Date dateTime = formatter.parse(date); 243 return dateTime.getTime(); 244 245 } 246 247 /** 248 * Returns current time in Epoch format 249 * 250 * @return The current date in Epoch format. 251 */ 252 protected static long currentTime() { 253 Calendar cal = Calendar.getInstance(); 254 return cal.getTimeInMillis(); 255 } 256 257 /** 258 * Sets the MapillarySequence object which contains the MapillaryImage. 259 * 260 * @param sequence 261 * The MapillarySequence that contains the MapillaryImage. 262 */ 263 public void setSequence(MapillarySequence sequence) { 264 this.sequence = sequence; 128 * Returns a LatLon object containing the current coordinates of the object. 129 * When you are dragging the image this changes. 130 * 131 * @return The LatLon object with the position of the object. 132 */ 133 public LatLon getLatLon() { 134 return this.movingLatLon; 265 135 } 266 136 … … 277 147 278 148 return this.sequence; 149 } 150 151 /** 152 * Returns the last fixed direction of the object. 153 * 154 * @return The last fixed direction of the object. 0 means north. 155 */ 156 public double getTempCa() { 157 return this.tempCa; 158 } 159 160 /** 161 * Returns the last fixed coordinates of the object. 162 * 163 * @return A LatLon object containing. 164 */ 165 public LatLon getTempLatLon() { 166 return this.tempLatLon; 167 } 168 169 /** 170 * Returns whether the object has been modified or not. 171 * 172 * @return true if the object has been modified; false otherwise. 173 */ 174 public boolean isModified() { 175 return (this.getLatLon() != this.latLon || this.getCa() != this.ca); 176 } 177 178 /** 179 * Returns whether the image is visible on the map or not. 180 * 181 * @return True if the image is visible; false otherwise. 182 */ 183 public boolean isVisible() { 184 return this.visible; 185 } 186 187 /** 188 * Moves the image temporally to another position 189 * 190 * @param x 191 * The movement of the image in longitude units. 192 * @param y 193 * The movement of the image in latitude units. 194 */ 195 public void move(double x, double y) { 196 this.movingLatLon = new LatLon(this.tempLatLon.getY() + y, 197 this.tempLatLon.getX() + x); 279 198 } 280 199 … … 315 234 316 235 } 236 237 /** 238 * Sets the Epoch time when the picture was captured. 239 * 240 * @param capturedAt 241 * Epoch time when the image was captured. 242 */ 243 public void setCapturedAt(long capturedAt) { 244 this.capturedAt = capturedAt; 245 } 246 247 /** 248 * Sets the MapillarySequence object which contains the MapillaryImage. 249 * 250 * @param sequence 251 * The MapillarySequence that contains the MapillaryImage. 252 */ 253 public void setSequence(MapillarySequence sequence) { 254 this.sequence = sequence; 255 } 256 257 /** 258 * Set's whether the image should be visible on the map or not. 259 * 260 * @param visible 261 * true if the image is set to be visible; false otherwise. 262 */ 263 public void setVisible(boolean visible) { 264 this.visible = visible; 265 } 266 267 /** 268 * Called when the mouse button is released, meaning that the picture has 269 * stopped being dragged, so the temporal values are saved. 270 */ 271 public void stopMoving() { 272 this.tempLatLon = this.movingLatLon; 273 this.tempCa = this.movingCa; 274 } 275 276 /** 277 * Turns the image direction. 278 * 279 * @param ca 280 * The angle the image is moving. 281 */ 282 public void turn(double ca) { 283 this.movingCa = this.tempCa + ca; 284 } 317 285 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
r31512 r31513 1 1 package org.openstreetmap.josm.plugins.mapillary; 2 3 import java.util.ArrayList; 4 import java.util.List; 5 import java.util.concurrent.CopyOnWriteArrayList; 2 6 3 7 import org.openstreetmap.josm.Main; … … 5 9 import org.openstreetmap.josm.plugins.mapillary.cache.CacheUtils; 6 10 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog; 7 8 import java.util.ArrayList;9 import java.util.List;10 import java.util.concurrent.CopyOnWriteArrayList;11 11 12 12 /** … … 33 33 34 34 /** 35 * Main constructor.35 * Creates a new object and adds the initial set of listeners. 36 36 */ 37 37 protected MapillaryData() { … … 93 93 * 94 94 * @param images 95 * A {@link List} of {@link MapillaryAbstractImage} objects that are going96 * to be removed.95 * A {@link List} of {@link MapillaryAbstractImage} objects that are 96 * going to be removed. 97 97 */ 98 98 public synchronized void remove(List<MapillaryAbstractImage> images) { … … 347 347 348 348 /** 349 * Adds a {@link MapillaryImage} object to the list of selected images, (when ctrl +350 * c lick)349 * Adds a {@link MapillaryImage} object to the list of selected images, (when 350 * ctrl + click) 351 351 * 352 352 * @param image -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java
r31501 r31513 59 59 this.file = file; 60 60 try { 61 this.datetimeOriginal = getEpoch(datetimeOriginal, "yyyy:MM:dd hh:mm:ss");61 this.datetimeOriginal = MapillaryUtils.getEpoch(datetimeOriginal, "yyyy:MM:dd hh:mm:ss"); 62 62 } catch (ParseException e) { 63 63 try { 64 this.datetimeOriginal = getEpoch(datetimeOriginal,64 this.datetimeOriginal = MapillaryUtils.getEpoch(datetimeOriginal, 65 65 "yyyy/MM/dd hh:mm:ss"); 66 66 } catch (ParseException e1) { 67 this.datetimeOriginal = currentTime();67 this.datetimeOriginal = MapillaryUtils.currentTime(); 68 68 } 69 69 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31512 r31513 1 1 package org.openstreetmap.josm.plugins.mapillary; 2 2 3 import static org.openstreetmap.josm.tools.I18n.marktr; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 4 import static org.openstreetmap.josm.tools.I18n.marktr;5 6 import org.openstreetmap.josm.plugins.mapillary.cache.CacheUtils;7 import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryDownloader;8 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryFilterDialog;9 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog;10 import org.openstreetmap.josm.plugins.mapillary.history.MapillaryRecord;11 import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandDelete;12 import org.openstreetmap.josm.plugins.mapillary.mode.AbstractMode;13 import org.openstreetmap.josm.plugins.mapillary.mode.JoinMode;14 import org.openstreetmap.josm.plugins.mapillary.mode.SelectMode;15 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils;16 import org.openstreetmap.josm.Main;17 import org.openstreetmap.josm.gui.layer.Layer;18 import org.openstreetmap.josm.data.Bounds;19 import org.openstreetmap.josm.gui.MapView;20 import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener;21 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;22 import org.openstreetmap.josm.gui.NavigatableComponent;23 import org.openstreetmap.josm.gui.layer.AbstractModifiableLayer;24 import org.openstreetmap.josm.gui.layer.OsmDataLayer;25 import org.openstreetmap.josm.data.coor.LatLon;26 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;27 import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;28 import org.openstreetmap.josm.gui.dialogs.LayerListDialog;29 import org.openstreetmap.josm.gui.dialogs.LayerListPopup;30 import org.openstreetmap.josm.data.osm.event.PrimitivesAddedEvent;31 import org.openstreetmap.josm.data.osm.event.PrimitivesRemovedEvent;32 import org.openstreetmap.josm.data.osm.event.TagsChangedEvent;33 import org.openstreetmap.josm.data.osm.event.NodeMovedEvent;34 import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent;35 import org.openstreetmap.josm.data.osm.event.RelationMembersChangedEvent;36 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent;37 import org.openstreetmap.josm.data.osm.event.DataChangedEvent;38 import org.openstreetmap.josm.data.osm.event.DataSetListener;39 5 40 6 import java.awt.AlphaComposite; … … 51 17 import java.awt.image.AffineTransformOp; 52 18 import java.awt.image.BufferedImage; 19 import java.util.ArrayList; 20 import java.util.List; 21 import java.util.concurrent.CopyOnWriteArrayList; 53 22 54 23 import javax.swing.AbstractAction; 55 import javax.swing.ImageIcon;56 24 import javax.swing.Action; 57 25 import javax.swing.Icon; 26 import javax.swing.ImageIcon; 58 27 import javax.swing.JComponent; 59 28 import javax.swing.KeyStroke; 60 29 61 import java.util.List; 62 import java.util.ArrayList; 63 import java.util.concurrent.CopyOnWriteArrayList; 30 import org.openstreetmap.josm.Main; 31 import org.openstreetmap.josm.data.Bounds; 32 import org.openstreetmap.josm.data.coor.LatLon; 33 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent; 34 import org.openstreetmap.josm.data.osm.event.DataChangedEvent; 35 import org.openstreetmap.josm.data.osm.event.DataSetListener; 36 import org.openstreetmap.josm.data.osm.event.NodeMovedEvent; 37 import org.openstreetmap.josm.data.osm.event.PrimitivesAddedEvent; 38 import org.openstreetmap.josm.data.osm.event.PrimitivesRemovedEvent; 39 import org.openstreetmap.josm.data.osm.event.RelationMembersChangedEvent; 40 import org.openstreetmap.josm.data.osm.event.TagsChangedEvent; 41 import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent; 42 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 43 import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors; 44 import org.openstreetmap.josm.gui.MapView; 45 import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener; 46 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 47 import org.openstreetmap.josm.gui.NavigatableComponent; 48 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 49 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 50 import org.openstreetmap.josm.gui.layer.AbstractModifiableLayer; 51 import org.openstreetmap.josm.gui.layer.Layer; 52 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 53 import org.openstreetmap.josm.plugins.mapillary.cache.CacheUtils; 54 import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryDownloader; 55 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryFilterDialog; 56 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog; 57 import org.openstreetmap.josm.plugins.mapillary.history.MapillaryRecord; 58 import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandDelete; 59 import org.openstreetmap.josm.plugins.mapillary.mode.AbstractMode; 60 import org.openstreetmap.josm.plugins.mapillary.mode.JoinMode; 61 import org.openstreetmap.josm.plugins.mapillary.mode.SelectMode; 62 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils; 64 63 65 64 /** … … 515 514 // When more data is downloaded, a delayed update is thrown, in order to 516 515 // wait for the data bounds to be set. 517 Main.worker.submit(new delayedDownload()); 516 Main.worker.submit(new DelayedDownload()); 517 } 518 519 @Override 520 public void primitivesAdded(PrimitivesAddedEvent event) { 521 } 522 523 @Override 524 public void primitivesRemoved(PrimitivesRemovedEvent event) { 525 } 526 527 @Override 528 public void tagsChanged(TagsChangedEvent event) { 529 } 530 531 @Override 532 public void nodeMoved(NodeMovedEvent event) { 533 } 534 535 @Override 536 public void wayNodesChanged(WayNodesChangedEvent event) { 537 } 538 539 @Override 540 public void relationMembersChanged(RelationMembersChangedEvent event) { 541 } 542 543 @Override 544 public void otherDatasetChange(AbstractDatasetChangedEvent event) { 545 } 546 547 @Override 548 public void visitBoundingBox(BoundingXYVisitor v) { 549 } 550 551 @Override 552 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 553 if (newLayer == this) { 554 MapillaryUtils.updateHelpText(); 555 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.JOIN_MENU, true); 556 } else 557 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.JOIN_MENU, false); 558 } 559 560 @Override 561 public void layerAdded(Layer newLayer) { 562 } 563 564 @Override 565 public void layerRemoved(Layer oldLayer) { 518 566 } 519 567 … … 524 572 * 525 573 */ 526 private class delayedDownload extends Thread {574 private class DelayedDownload extends Thread { 527 575 528 576 @Override … … 537 585 } 538 586 539 @Override540 public void primitivesAdded(PrimitivesAddedEvent event) {541 }542 543 @Override544 public void primitivesRemoved(PrimitivesRemovedEvent event) {545 }546 547 @Override548 public void tagsChanged(TagsChangedEvent event) {549 }550 551 @Override552 public void nodeMoved(NodeMovedEvent event) {553 }554 555 @Override556 public void wayNodesChanged(WayNodesChangedEvent event) {557 }558 559 @Override560 public void relationMembersChanged(RelationMembersChangedEvent event) {561 }562 563 @Override564 public void otherDatasetChange(AbstractDatasetChangedEvent event) {565 }566 567 @Override568 public void visitBoundingBox(BoundingXYVisitor v) {569 }570 571 @Override572 public void activeLayerChange(Layer oldLayer, Layer newLayer) {573 if (newLayer == this) {574 MapillaryUtils.updateHelpText();575 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.JOIN_MENU, true);576 } else577 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.JOIN_MENU, false);578 }579 580 @Override581 public void layerAdded(Layer newLayer) {582 }583 584 @Override585 public void layerRemoved(Layer oldLayer) {586 }587 588 587 /** 589 588 * Action used to delete images. -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
r31501 r31513 8 8 9 9 import org.apache.commons.jcs.access.CacheAccess; 10 import org.openstreetmap.josm.Main; 10 11 import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry; 11 12 import org.openstreetmap.josm.data.cache.JCSCacheManager; 12 13 import org.openstreetmap.josm.gui.MainMenu; 13 import org.openstreetmap.josm.Main;14 14 import org.openstreetmap.josm.gui.MapFrame; 15 15 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 16 16 import org.openstreetmap.josm.plugins.Plugin; 17 17 import org.openstreetmap.josm.plugins.PluginInformation; 18 import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryDownloadAction; 19 import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryDownloadViewAction; 20 import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryExportAction; 21 import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryImportAction; 22 import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryImportIntoSequenceAction; 23 import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryJoinAction; 24 import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryUploadAction; 25 import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryWalkAction; 26 import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryZoomAction; 18 27 import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryDownloader; 19 28 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryFilterDialog; 20 29 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryHistoryDialog; 30 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog; 21 31 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryPreferenceSetting; 22 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog;23 32 import org.openstreetmap.josm.plugins.mapillary.oauth.MapillaryUser; 24 import org.openstreetmap.josm.plugins.mapillary.actions.*;25 33 import org.openstreetmap.josm.tools.ImageProvider; 26 34 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java
r31459 r31513 3 3 import java.io.BufferedReader; 4 4 import java.io.IOException; 5 import java.io.InputStreamReader; 5 6 import java.net.URL; 6 import java.io.InputStreamReader;7 8 import javax.json.JsonArray;9 import javax.json.JsonObject;10 import javax.json.Json;11 12 7 import java.util.ArrayList; 13 8 import java.util.List; … … 15 10 import java.util.concurrent.locks.Lock; 16 11 import java.util.concurrent.locks.ReentrantLock; 12 13 import javax.json.Json; 14 import javax.json.JsonArray; 15 import javax.json.JsonObject; 17 16 18 17 import org.openstreetmap.josm.Main; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java
r31512 r31513 1 1 package org.openstreetmap.josm.plugins.mapillary.downloads; 2 2 3 import java.util.concurrent.ThreadPoolExecutor;4 import java.util.concurrent.TimeUnit;5 3 import java.io.UnsupportedEncodingException; 6 4 import java.net.URLEncoder; … … 8 6 import java.util.concurrent.ArrayBlockingQueue; 9 7 import java.util.concurrent.ConcurrentHashMap; 8 import java.util.concurrent.ThreadPoolExecutor; 9 import java.util.concurrent.TimeUnit; 10 10 11 11 import org.openstreetmap.josm.Main; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/HyperlinkLabel.java
r31512 r31513 125 125 add(this.copyTag); 126 126 127 this.edit = new JMenuItem(tr("Edit on web page"));127 this.edit = new JMenuItem(tr("Edit on website")); 128 128 this.edit.addActionListener(new editAction()); 129 129 add(this.edit); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryHistoryDialog.java
r31501 r31513 23 23 import javax.swing.event.TreeSelectionEvent; 24 24 import javax.swing.event.TreeSelectionListener; 25 import javax.swing.tree.DefaultMutableTreeNode; 25 26 import javax.swing.tree.DefaultTreeCellRenderer; 26 27 import javax.swing.tree.DefaultTreeModel; … … 37 38 import org.openstreetmap.josm.tools.ImageProvider; 38 39 import org.openstreetmap.josm.tools.Shortcut; 39 40 import javax.swing.tree.DefaultMutableTreeNode;41 40 42 41 /** -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java
r31457 r31513 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.awt.event.ActionEvent;6 import java.awt.event.KeyEvent;7 import java.awt.image.BufferedImage;8 5 import java.awt.BorderLayout; 9 6 import java.awt.Color; … … 11 8 import java.awt.FlowLayout; 12 9 import java.awt.GridLayout; 10 import java.awt.event.ActionEvent; 11 import java.awt.event.KeyEvent; 12 import java.awt.image.BufferedImage; 13 13 import java.io.ByteArrayInputStream; 14 14 import java.io.IOException; … … 16 16 import java.util.List; 17 17 18 import javax.imageio.ImageIO; 19 import javax.swing.AbstractAction; 20 import javax.swing.JComponent; 21 import javax.swing.JPanel; 22 import javax.swing.KeyStroke; 23 import javax.swing.SwingUtilities; 24 18 25 import org.openstreetmap.josm.Main; 19 26 import org.openstreetmap.josm.data.cache.CacheEntry; 20 27 import org.openstreetmap.josm.data.cache.CacheEntryAttributes; 21 28 import org.openstreetmap.josm.data.cache.ICachedLoaderListener; 29 import org.openstreetmap.josm.gui.SideButton; 22 30 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; 23 import org.openstreetmap.josm.gui.SideButton;24 31 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage; 25 32 import org.openstreetmap.josm.plugins.mapillary.MapillaryDataListener; … … 33 40 import org.openstreetmap.josm.tools.ImageProvider; 34 41 import org.openstreetmap.josm.tools.Shortcut; 35 36 import javax.imageio.ImageIO;37 import javax.swing.JComponent;38 import javax.swing.KeyStroke;39 import javax.swing.SwingUtilities;40 import javax.swing.AbstractAction;41 import javax.swing.JPanel;42 42 43 43 /** -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/CommandMove.java
r31490 r31513 41 41 image.stopMoving(); 42 42 } 43 checkModified();44 43 if (Main.main != null) 45 44 Main.map.repaint(); … … 52 51 image.stopMoving(); 53 52 } 54 checkModified();55 53 if (Main.main != null) 56 54 Main.map.repaint(); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/CommandTurn.java
r31490 r31513 36 36 image.stopMoving(); 37 37 } 38 checkModified();39 38 if (Main.main != null) 40 39 Main.map.repaint(); … … 47 46 image.stopMoving(); 48 47 } 49 checkModified();50 48 if (Main.main != null) 51 49 Main.map.repaint(); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/MapillaryCommand.java
r31490 r31513 45 45 public abstract void sum(MapillaryCommand command); 46 46 47 /**48 * Checks if the image has been modified, comparing with its original values.49 */50 public void checkModified() {51 for (MapillaryAbstractImage image : this.images)52 image.isModified = (image.tempLatLon == image.latLon || image.tempCa == image.ca);53 }54 55 47 @Override 56 48 public abstract String toString(); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/UploadUtils.java
r31512 r31513 55 55 public class UploadUtils { 56 56 57 /** Required keys for POST */58 private static final String[] keys = { "key", "AWSAccessKeyId", "acl",59 "policy", "signature", "Content-Type" };60 /** Mapillary upload URL */61 private static final String UPLOAD_URL = "https://s3-eu-west-1.amazonaws.com/mapillary.uploads.manual.images";62 /** Count to name temporal files. */63 private static int c = 0;64 65 /**66 * Uploads the given MapillaryImportedImage object.67 *68 * @param image69 *70 */71 public static void upload(MapillaryImportedImage image) {72 upload(image, UUID.randomUUID());73 74 }75 76 /**77 * @param image78 * @param uuid79 * The UUID used to create the sequence.80 */81 public static void upload(MapillaryImportedImage image, UUID uuid) {82 String key = MapillaryUser.getUsername() + "/" + uuid.toString() + "/"83 + image.getLatLon().lat() + "_" + image.getLatLon().lon() + "_"84 + image.getCa() + "_" + image.datetimeOriginal + ".jpg";85 86 String policy = null;87 String signature = null;88 policy = MapillaryUser.getSecrets().get("images_policy");89 signature = MapillaryUser.getSecrets().get("images_hash");90 91 HashMap<String, String> hash = new HashMap<>();92 hash.put("key", key);93 hash.put("AWSAccessKeyId", "AKIAI2X3BJAT2W75HILA");94 hash.put("acl", "private");95 hash.put("policy", policy);96 hash.put("signature", signature);97 hash.put("Content-Type", "image/jpeg");98 99 try {100 uploadFile(updateFile(image), hash);101 } catch (ImageReadException | ImageWriteException | IOException e) {102 Main.error(e);103 }104 }105 106 /**107 * @param file108 * @param hash109 * @throws IOException110 * @throws IllegalArgumentException111 * if the hash doesn't contain all the needed keys.112 */113 public static void uploadFile(File file, HashMap<String, String> hash)114 throws IOException {115 HttpClientBuilder builder = HttpClientBuilder.create();116 HttpClient httpClient = builder.build();117 HttpPost httpPost = new HttpPost(UPLOAD_URL);118 119 MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create();120 for (String key : keys) {121 if (hash.get(key) == null)122 throw new IllegalArgumentException();123 entityBuilder.addPart(key, new StringBody(hash.get(key),124 ContentType.TEXT_PLAIN));125 }126 entityBuilder.addPart("file", new FileBody(file));127 128 HttpEntity entity = entityBuilder.build();129 httpPost.setEntity(entity);130 HttpResponse response = httpClient.execute(httpPost);131 if (response.getStatusLine().toString().contains("204")) {132 PluginState.imageUploaded();133 Main.info(PluginState.getUploadString() + " (Mapillary)");134 } else135 Main.info("Upload error");136 file.delete();137 MapillaryUtils.updateHelpText();138 }139 140 /**141 * Uploads the given {@link MapillarySequence}.142 *143 * @param sequence144 * The sequence to upload. It must contain only145 * {@link MapillaryImportedImage} objects.146 * @param delete147 * Whether the images must be deleted after upload or not.148 */149 public static void uploadSequence(MapillarySequence sequence, boolean delete) {150 Main.worker.submit(new SequenceUploadThread(sequence.getImages(), delete));151 }152 153 57 private static class SequenceUploadThread extends Thread { 154 58 private List<MapillaryAbstractImage> images; … … 194 98 } 195 99 } 196 197 100 private static class SingleUploadThread extends Thread { 198 101 … … 210 113 } 211 114 } 115 /** Required keys for POST */ 116 private static final String[] keys = { "key", "AWSAccessKeyId", "acl", 117 "policy", "signature", "Content-Type" }; 118 119 /** Mapillary upload URL */ 120 private static final String UPLOAD_URL = "https://s3-eu-west-1.amazonaws.com/mapillary.uploads.manual.images"; 121 122 /** Count to name temporal files. */ 123 private static int c = 0; 212 124 213 125 /** … … 282 194 return tempFile; 283 195 } 196 197 /** 198 * Uploads the given MapillaryImportedImage object. 199 * 200 * @param image 201 * 202 */ 203 public static void upload(MapillaryImportedImage image) { 204 upload(image, UUID.randomUUID()); 205 206 } 207 208 /** 209 * @param image 210 * @param uuid 211 * The UUID used to create the sequence. 212 */ 213 public static void upload(MapillaryImportedImage image, UUID uuid) { 214 String key = MapillaryUser.getUsername() + "/" + uuid.toString() + "/" 215 + image.getLatLon().lat() + "_" + image.getLatLon().lon() + "_" 216 + image.getCa() + "_" + image.datetimeOriginal + ".jpg"; 217 218 String policy = null; 219 String signature = null; 220 policy = MapillaryUser.getSecrets().get("images_policy"); 221 signature = MapillaryUser.getSecrets().get("images_hash"); 222 223 HashMap<String, String> hash = new HashMap<>(); 224 hash.put("key", key); 225 hash.put("AWSAccessKeyId", "AKIAI2X3BJAT2W75HILA"); 226 hash.put("acl", "private"); 227 hash.put("policy", policy); 228 hash.put("signature", signature); 229 hash.put("Content-Type", "image/jpeg"); 230 231 try { 232 uploadFile(updateFile(image), hash); 233 } catch (ImageReadException | ImageWriteException | IOException e) { 234 Main.error(e); 235 } 236 } 237 238 /** 239 * @param file 240 * @param hash 241 * @throws IOException 242 * @throws IllegalArgumentException 243 * if the hash doesn't contain all the needed keys. 244 */ 245 public static void uploadFile(File file, HashMap<String, String> hash) 246 throws IOException { 247 HttpClientBuilder builder = HttpClientBuilder.create(); 248 HttpClient httpClient = builder.build(); 249 HttpPost httpPost = new HttpPost(UPLOAD_URL); 250 251 MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create(); 252 for (String key : keys) { 253 if (hash.get(key) == null) 254 throw new IllegalArgumentException(); 255 entityBuilder.addPart(key, new StringBody(hash.get(key), 256 ContentType.TEXT_PLAIN)); 257 } 258 entityBuilder.addPart("file", new FileBody(file)); 259 260 HttpEntity entity = entityBuilder.build(); 261 httpPost.setEntity(entity); 262 HttpResponse response = httpClient.execute(httpPost); 263 if (response.getStatusLine().toString().contains("204")) { 264 PluginState.imageUploaded(); 265 Main.info(PluginState.getUploadString() + " (Mapillary)"); 266 } else 267 Main.info("Upload error"); 268 file.delete(); 269 MapillaryUtils.updateHelpText(); 270 } 271 272 /** 273 * Uploads the given {@link MapillarySequence}. 274 * 275 * @param sequence 276 * The sequence to upload. It must contain only 277 * {@link MapillaryImportedImage} objects. 278 * @param delete 279 * Whether the images must be deleted after upload or not. 280 */ 281 public static void uploadSequence(MapillarySequence sequence, boolean delete) { 282 Main.worker.submit(new SequenceUploadThread(sequence.getImages(), delete)); 283 } 284 284 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtils.java
r31512 r31513 8 8 import java.net.URISyntaxException; 9 9 import java.net.URL; 10 import java.text.ParseException; 10 11 import java.text.SimpleDateFormat; 11 12 import java.util.ArrayList; 12 13 import java.util.Calendar; 14 import java.util.Date; 13 15 import java.util.List; 14 16 … … 45 47 46 48 /** 47 * Updates the help text at the bottom of the window. 48 */ 49 public static void updateHelpText() { 50 String ret = ""; 51 if (PluginState.isDownloading()) 52 ret += tr("Downloading Mapillary images"); 53 else if (MapillaryLayer.getInstance().getData().size() > 0) 54 ret += tr("Total Mapillary images: {0}", MapillaryLayer.getInstance() 55 .getData().size()); 56 else 57 ret += tr("No images found"); 58 if (MapillaryLayer.getInstance().mode != null) 59 ret += " -- " + tr(MapillaryLayer.getInstance().mode.toString()); 60 if (PluginState.isUploading()) 61 ret += " -- " + PluginState.getUploadString(); 62 Main.map.statusLine.setHelpText(ret); 49 * Open the default browser in the given URL. 50 * 51 * @param url 52 * The URL that is going to be opened. 53 */ 54 public static void browse(URL url) { 55 Desktop desktop = Desktop.getDesktop(); 56 if (desktop.isSupported(Desktop.Action.BROWSE)) { 57 try { 58 desktop.browse(url.toURI()); 59 } catch (IOException | URISyntaxException e1) { 60 Main.error(e1); 61 } 62 } else { 63 Runtime runtime = Runtime.getRuntime(); 64 try { 65 runtime.exec("xdg-open " + url); 66 } catch (IOException exc) { 67 exc.printStackTrace(); 68 } 69 } 70 } 71 72 /** 73 * Returns the current date. 74 * 75 * @return A {@code String} object containing the current date. 76 */ 77 public static String currentDate() { 78 Calendar cal = Calendar.getInstance(); 79 SimpleDateFormat formatter = new SimpleDateFormat("yyyy:MM:dd hh:mm:ss"); 80 return formatter.format(cal.getTime()); 81 } 82 83 /** 84 * Returns current time in Epoch format 85 * 86 * @return The current date in Epoch format. 87 */ 88 public static long currentTime() { 89 Calendar cal = Calendar.getInstance(); 90 return cal.getTimeInMillis(); 63 91 } 64 92 … … 122 150 123 151 /** 124 * Open the default browser in the given URL. 125 * 126 * @param url 127 * The URL that is going to be opened. 128 */ 129 public static void browse(URL url) { 130 Desktop desktop = Desktop.getDesktop(); 131 if (desktop.isSupported(Desktop.Action.BROWSE)) { 132 try { 133 desktop.browse(url.toURI()); 134 } catch (IOException | URISyntaxException e1) { 135 Main.error(e1); 136 } 137 } else { 138 Runtime runtime = Runtime.getRuntime(); 139 try { 140 runtime.exec("xdg-open " + url); 141 } catch (IOException exc) { 142 exc.printStackTrace(); 143 } 144 } 152 * Parses a string with a given format and returns the Epoch time. 153 * 154 * @param date 155 * The string containing the date. 156 * @param format 157 * The format of the date. 158 * @return The date in Epoch format. 159 * @throws ParseException 160 */ 161 public static long getEpoch(String date, String format) throws ParseException { 162 SimpleDateFormat formatter = new SimpleDateFormat(format); 163 Date dateTime = formatter.parse(date); 164 return dateTime.getTime(); 165 } 166 167 /** 168 * Returns the extension of a {@link File} object. 169 * 170 * @param file 171 * The {@link File} object whose extension is going to be returned. 172 * @return A {@code String} object containing the extension in lowercase. 173 */ 174 public static String getExtension(File file) { 175 if (file.isDirectory()) 176 throw new IllegalArgumentException("The file is a directory"); 177 int k = file.getName().lastIndexOf('.'); 178 if (k > 0) { 179 return file.getName().substring(k + 1).toLowerCase(); 180 } 181 throw new IllegalArgumentException("Error parsing the extension"); 145 182 } 146 183 … … 178 215 if (Main.main != null) 179 216 MapillaryData.dataUpdated(); 180 }181 182 /**183 * Separates two images belonging to the same sequence.184 *185 * @param mapillaryAbstractImage186 * @param mapillaryAbstractImage2187 */188 public synchronized static void unjoin(189 MapillaryAbstractImage mapillaryAbstractImage,190 MapillaryAbstractImage mapillaryAbstractImage2) {191 MapillaryAbstractImage firstImage = mapillaryAbstractImage;192 MapillaryAbstractImage secondImage = mapillaryAbstractImage2;193 194 if (mapillaryAbstractImage.next() != mapillaryAbstractImage2) {195 firstImage = mapillaryAbstractImage2;196 secondImage = mapillaryAbstractImage;197 }198 199 ArrayList<MapillaryAbstractImage> firstHalf = new ArrayList<>(firstImage200 .getSequence().getImages()201 .subList(0, firstImage.getSequence().getImages().indexOf(secondImage)));202 ArrayList<MapillaryAbstractImage> secondHalf = new ArrayList<>(firstImage203 .getSequence()204 .getImages()205 .subList(firstImage.getSequence().getImages().indexOf(secondImage),206 firstImage.getSequence().getImages().size()));207 208 MapillarySequence seq1 = new MapillarySequence();209 MapillarySequence seq2 = new MapillarySequence();210 211 for (MapillaryAbstractImage img : firstHalf) {212 img.setSequence(seq1);213 seq1.add(img);214 }215 for (MapillaryAbstractImage img : secondHalf) {216 img.setSequence(seq2);217 seq2.add(img);218 }219 if (Main.main != null)220 MapillaryData.dataUpdated();221 }222 223 /**224 * Zooms to fit all the given {@link MapillaryAbstractImage} objects.225 *226 * @param images227 * The images your are zooming to.228 * @param select229 * Whether the added images must be selected or not.230 */231 public static void showPictures(final List<MapillaryAbstractImage> images,232 final boolean select) {233 if (!SwingUtilities.isEventDispatchThread()) {234 SwingUtilities.invokeLater(new Runnable() {235 @Override236 public void run() {237 showPictures(images, select);238 }239 });240 } else {241 double minLat = 90;242 double minLon = 180;243 double maxLat = -90;244 double maxLon = -180;245 for (MapillaryAbstractImage img : images) {246 if (img.getLatLon().lat() < minLat)247 minLat = img.getLatLon().lat();248 if (img.getLatLon().lon() < minLon)249 minLon = img.getLatLon().lon();250 if (img.getLatLon().lat() > maxLat)251 maxLat = img.getLatLon().lat();252 if (img.getLatLon().lon() > maxLon)253 maxLon = img.getLatLon().lon();254 }255 Bounds zoomBounds = new Bounds(new LatLon(minLat, minLon), new LatLon(256 maxLat, maxLon));257 // The zoom rectangle must have a minimum size.258 double latExtent = zoomBounds.getMaxLat() - zoomBounds.getMinLat() >= MIN_ZOOM_SQUARE_SIDE ? zoomBounds259 .getMaxLat() - zoomBounds.getMinLat()260 : MIN_ZOOM_SQUARE_SIDE;261 double lonExtent = zoomBounds.getMaxLon() - zoomBounds.getMinLon() >= MIN_ZOOM_SQUARE_SIDE ? zoomBounds262 .getMaxLon() - zoomBounds.getMinLon()263 : MIN_ZOOM_SQUARE_SIDE;264 zoomBounds = new Bounds(zoomBounds.getCenter(), latExtent, lonExtent);265 266 Main.map.mapView.zoomTo(zoomBounds);267 MapillaryLayer.getInstance().getData().setSelectedImage(null);268 if (select)269 MapillaryLayer.getInstance().getData().addMultiSelectedImage(images);270 if (Main.main != null)271 MapillaryData.dataUpdated();272 }273 }274 275 /**276 * Zooms to fit all the {@link MapillaryAbstractImage} objects stored in the277 * database.278 */279 public static void showAllPictures() {280 showPictures(MapillaryLayer.getInstance().getData().getImages(), false);281 }282 283 /**284 * Returns the current date.285 *286 * @return A {@code String} object containing the current date.287 */288 public static String currentDate() {289 Calendar cal = Calendar.getInstance();290 SimpleDateFormat formatter = new SimpleDateFormat("yyyy:MM:dd hh:mm:ss");291 return formatter.format(cal.getTime());292 217 } 293 218 … … 319 244 * have all the needed EXIF tags; {@code false} returns an image in 320 245 * the center of the screen. 321 * @return The imported image. 246 * @return The imported image, whose data has been extracted from the 247 * picture's metadata. 322 248 * @throws ImageReadException 323 249 * If the {@link File} isn't an image. … … 378 304 * @param file 379 305 * The file where the image is located. 306 * @return The imported image. 307 */ 308 public static MapillaryImportedImage readNoTags(File file) { 309 return readNoTags( 310 file, 311 Main.map.mapView.getProjection().eastNorth2latlon( 312 Main.map.mapView.getCenter())); 313 } 314 315 /** 316 * Reads a image file that doesn't contain the needed GPS information. And 317 * creates a new icon in the middle of the map. 318 * 319 * @param file 320 * The file where the image is located. 380 321 * @param pos 381 322 * A {@link LatLon} object indicating the position in the map where … … 406 347 407 348 /** 408 * Reads a image file that doesn't contain the needed GPS information. And 409 * creates a new icon in the middle of the map. 410 * 411 * @param file 412 * The file where the image is located. 413 * @return The imported image. 414 */ 415 public static MapillaryImportedImage readNoTags(File file) { 416 return readNoTags( 417 file, 418 Main.map.mapView.getProjection().eastNorth2latlon( 419 Main.map.mapView.getCenter())); 420 } 421 422 /** 423 * Returns the extension of a {@link File} object. 424 * 425 * @param file 426 * The {@link File} object whose extension is going to be returned. 427 * @return A {@code String} object containing the extension. 428 */ 429 public static String getExtension(File file) { 430 if (file.isDirectory()) 431 throw new IllegalArgumentException("The file is a directory"); 432 int k = file.getName().lastIndexOf('.'); 433 if (k > 0) { 434 return file.getName().substring(k + 1).toLowerCase(); 435 } 436 throw new IllegalArgumentException("Error parsing the extension"); 349 * Zooms to fit all the {@link MapillaryAbstractImage} objects stored in the 350 * database. 351 */ 352 public static void showAllPictures() { 353 showPictures(MapillaryLayer.getInstance().getData().getImages(), false); 354 } 355 356 /** 357 * Zooms to fit all the given {@link MapillaryAbstractImage} objects. 358 * 359 * @param images 360 * The images your are zooming to. 361 * @param select 362 * Whether the added images must be selected or not. 363 */ 364 public static void showPictures(final List<MapillaryAbstractImage> images, 365 final boolean select) { 366 if (!SwingUtilities.isEventDispatchThread()) { 367 SwingUtilities.invokeLater(new Runnable() { 368 @Override 369 public void run() { 370 showPictures(images, select); 371 } 372 }); 373 } else { 374 double minLat = 90; 375 double minLon = 180; 376 double maxLat = -90; 377 double maxLon = -180; 378 for (MapillaryAbstractImage img : images) { 379 if (img.getLatLon().lat() < minLat) 380 minLat = img.getLatLon().lat(); 381 if (img.getLatLon().lon() < minLon) 382 minLon = img.getLatLon().lon(); 383 if (img.getLatLon().lat() > maxLat) 384 maxLat = img.getLatLon().lat(); 385 if (img.getLatLon().lon() > maxLon) 386 maxLon = img.getLatLon().lon(); 387 } 388 Bounds zoomBounds = new Bounds(new LatLon(minLat, minLon), new LatLon( 389 maxLat, maxLon)); 390 // The zoom rectangle must have a minimum size. 391 double latExtent = zoomBounds.getMaxLat() - zoomBounds.getMinLat() >= MIN_ZOOM_SQUARE_SIDE ? zoomBounds 392 .getMaxLat() - zoomBounds.getMinLat() 393 : MIN_ZOOM_SQUARE_SIDE; 394 double lonExtent = zoomBounds.getMaxLon() - zoomBounds.getMinLon() >= MIN_ZOOM_SQUARE_SIDE ? zoomBounds 395 .getMaxLon() - zoomBounds.getMinLon() 396 : MIN_ZOOM_SQUARE_SIDE; 397 zoomBounds = new Bounds(zoomBounds.getCenter(), latExtent, lonExtent); 398 399 Main.map.mapView.zoomTo(zoomBounds); 400 MapillaryLayer.getInstance().getData().setSelectedImage(null); 401 if (select) 402 MapillaryLayer.getInstance().getData().addMultiSelectedImage(images); 403 if (Main.main != null) 404 MapillaryData.dataUpdated(); 405 } 406 } 407 408 /** 409 * Separates two images belonging to the same sequence. 410 * 411 * @param mapillaryAbstractImage 412 * @param mapillaryAbstractImage2 413 */ 414 public synchronized static void unjoin( 415 MapillaryAbstractImage mapillaryAbstractImage, 416 MapillaryAbstractImage mapillaryAbstractImage2) { 417 MapillaryAbstractImage firstImage = mapillaryAbstractImage; 418 MapillaryAbstractImage secondImage = mapillaryAbstractImage2; 419 420 if (mapillaryAbstractImage.next() != mapillaryAbstractImage2) { 421 firstImage = mapillaryAbstractImage2; 422 secondImage = mapillaryAbstractImage; 423 } 424 425 ArrayList<MapillaryAbstractImage> firstHalf = new ArrayList<>(firstImage 426 .getSequence().getImages() 427 .subList(0, firstImage.getSequence().getImages().indexOf(secondImage))); 428 ArrayList<MapillaryAbstractImage> secondHalf = new ArrayList<>(firstImage 429 .getSequence() 430 .getImages() 431 .subList(firstImage.getSequence().getImages().indexOf(secondImage), 432 firstImage.getSequence().getImages().size())); 433 434 MapillarySequence seq1 = new MapillarySequence(); 435 MapillarySequence seq2 = new MapillarySequence(); 436 437 for (MapillaryAbstractImage img : firstHalf) { 438 img.setSequence(seq1); 439 seq1.add(img); 440 } 441 for (MapillaryAbstractImage img : secondHalf) { 442 img.setSequence(seq2); 443 seq2.add(img); 444 } 445 if (Main.main != null) 446 MapillaryData.dataUpdated(); 447 } 448 449 /** 450 * Updates the help text at the bottom of the window. 451 */ 452 public static void updateHelpText() { 453 String ret = ""; 454 if (PluginState.isDownloading()) 455 ret += tr("Downloading Mapillary images"); 456 else if (MapillaryLayer.getInstance().getData().size() > 0) 457 ret += tr("Total Mapillary images: {0}", MapillaryLayer.getInstance() 458 .getData().size()); 459 else 460 ret += tr("No images found"); 461 if (MapillaryLayer.getInstance().mode != null) 462 ret += " -- " + tr(MapillaryLayer.getInstance().mode.toString()); 463 if (PluginState.isUploading()) 464 ret += " -- " + PluginState.getUploadString(); 465 synchronized (MapillaryUtils.class) { 466 Main.map.statusLine.setHelpText(ret); 467 } 437 468 } 438 469 }
Note:
See TracChangeset
for help on using the changeset viewer.