Changeset 31490 in osm for applications/editors
- Timestamp:
- 2015-08-12T12:39:42+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary
- Files:
-
- 3 added
- 8 edited
- 9 moved
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
r31487 r31490 71 71 * @param image 72 72 */ 73 public synchronized void delete(MapillaryAbstractImage image) {73 public synchronized void remove(MapillaryAbstractImage image) { 74 74 if (MapillaryMainDialog.getInstance().getImage() != null) { 75 75 MapillaryMainDialog.getInstance().setImage(null); … … 89 89 * @param images 90 90 */ 91 public synchronized void delete(List<MapillaryAbstractImage> images) {91 public synchronized void remove(List<MapillaryAbstractImage> images) { 92 92 for (MapillaryAbstractImage img : images) 93 delete(img);93 remove(img); 94 94 } 95 95 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31488 r31490 5 5 6 6 import org.openstreetmap.josm.plugins.mapillary.cache.CacheUtils; 7 import org.openstreetmap.josm.plugins.mapillary.commands.CommandDeleteImage;8 import org.openstreetmap.josm.plugins.mapillary.commands.MapillaryRecord;9 7 import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryDownloader; 10 8 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryFilterDialog; 11 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 12 import org.openstreetmap.josm.plugins.mapillary.mode.AbstractMode; 13 13 import org.openstreetmap.josm.plugins.mapillary.mode.JoinMode; … … 623 623 if (INSTANCE != null) { 624 624 MapillaryRecord.getInstance().addCommand( 625 new CommandDelete Image(getData().getMultiSelectedImages()));625 new CommandDelete(getData().getMultiSelectedImages())); 626 626 } 627 627 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java
r31456 r31490 7 7 import java.io.File; 8 8 import java.io.IOException; 9 import java.util.ArrayList; 10 import java.util.List; 9 11 10 12 import javax.swing.JFileChooser; … … 22 24 import org.openstreetmap.josm.actions.JosmAction; 23 25 import org.openstreetmap.josm.data.coor.LatLon; 26 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage; 24 27 import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage; 25 28 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; 26 29 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin; 30 import org.openstreetmap.josm.plugins.mapillary.history.MapillaryRecord; 31 import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandImport; 27 32 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils; 28 33 import org.openstreetmap.josm.tools.Shortcut; … … 70 75 this.chooser.setMultiSelectionEnabled(true); 71 76 if (this.chooser.showOpenDialog(Main.parent) == JFileChooser.APPROVE_OPTION) { 77 List<MapillaryAbstractImage> images = new ArrayList<>(); 72 78 for (int i = 0; i < this.chooser.getSelectedFiles().length; i++) { 73 79 File file = this.chooser.getSelectedFiles()[i]; … … 85 91 try { 86 92 if (extension.equals("jpg") || extension.equals("jpeg")) 87 MapillaryLayer.getInstance().getData() 88 .add(readJPG(file.listFiles()[j])); 93 images.add(readJPG(file.listFiles()[j])); 89 94 90 95 else if (extension.equals("png")) 91 MapillaryLayer.getInstance().getData() 92 .add(readPNG(file.listFiles()[j])); 96 images.add(readPNG(file.listFiles()[j])); 93 97 } catch (ImageReadException | IOException | NullPointerException e1) { 94 98 Main.error(e1); … … 101 105 .equals(".jpeg")) { 102 106 try { 103 MapillaryLayer.getInstance().getData().add(readJPG(file));107 images.add(readJPG(file)); 104 108 } catch (ImageReadException ex) { 105 109 Main.error(ex); … … 109 113 } else if (file.getPath().substring(file.getPath().length() - 4) 110 114 .equals(".png")) { 111 MapillaryLayer.getInstance().getData().add(readPNG(file));115 images.add(readPNG(file)); 112 116 } 113 117 } 114 118 } 119 MapillaryRecord.getInstance().addCommand(new CommandImport(images)); 115 120 MapillaryLayer.getInstance().showAllPictures(); 116 117 121 } 118 122 } … … 154 158 double caValue = 0; 155 159 if (lat.getValue() instanceof RationalNumber[]) 156 latValue = MapillaryUtils.degMinSecToDouble( (RationalNumber[]) lat.getValue(), lat_ref157 .getValue().toString()); 160 latValue = MapillaryUtils.degMinSecToDouble( 161 (RationalNumber[]) lat.getValue(), lat_ref.getValue().toString()); 158 162 if (lon.getValue() instanceof RationalNumber[]) 159 lonValue = MapillaryUtils.degMinSecToDouble( (RationalNumber[]) lon.getValue(), lon_ref160 .getValue().toString()); 163 lonValue = MapillaryUtils.degMinSecToDouble( 164 (RationalNumber[]) lon.getValue(), lon_ref.getValue().toString()); 161 165 if (ca != null && ca.getValue() instanceof RationalNumber) 162 166 caValue = ((RationalNumber) ca.getValue()).doubleValue(); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportIntoSequenceAction.java
r31473 r31490 10 10 import java.util.Comparator; 11 11 import java.util.LinkedList; 12 import java.util.List; 12 13 13 14 import javax.swing.JFileChooser; … … 29 30 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin; 30 31 import org.openstreetmap.josm.plugins.mapillary.MapillarySequence; 32 import org.openstreetmap.josm.plugins.mapillary.history.MapillaryRecord; 33 import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandImport; 31 34 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils; 32 35 import org.openstreetmap.josm.tools.Shortcut; … … 44 47 private JFileChooser chooser; 45 48 46 private Li nkedList<MapillaryImportedImage> images;49 private List<MapillaryAbstractImage> images; 47 50 48 51 /** … … 111 114 } 112 115 joinImages(); 113 }114 116 MapillaryRecord.getInstance().addCommand(new CommandImport(this.images)); 117 } 115 118 MapillaryLayer.getInstance().showAllPictures(); 116 119 } … … 161 164 MapillaryImportedImage image = new MapillaryImportedImage(latValue, 162 165 lonValue, caValue, file, datetimeOriginal.getStringValue()); 163 MapillaryLayer.getInstance().getData().add(image);164 image.getCapturedAt();165 166 166 this.images.add(image); 167 167 } … … 174 174 Collections.sort(this.images, new MapillaryEpochComparator()); 175 175 MapillarySequence seq = new MapillarySequence(); 176 for (Mapillary ImportedImage img : this.images) {176 for (MapillaryAbstractImage img : this.images) { 177 177 seq.add(img); 178 178 img.setSequence(seq); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryHistoryDialog.java
r31445 r31490 22 22 import org.openstreetmap.josm.gui.SideButton; 23 23 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; 24 import org.openstreetmap.josm.plugins.mapillary. commands.MapillaryCommand;25 import org.openstreetmap.josm.plugins.mapillary. commands.MapillaryRecord;26 import org.openstreetmap.josm.plugins.mapillary.commands.Mapillary RecordListener;24 import org.openstreetmap.josm.plugins.mapillary.history.MapillaryRecord; 25 import org.openstreetmap.josm.plugins.mapillary.history.MapillaryRecordListener; 26 import org.openstreetmap.josm.plugins.mapillary.history.commands.MapillaryCommand; 27 27 import org.openstreetmap.josm.tools.GBC; 28 28 import org.openstreetmap.josm.tools.ImageProvider; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecord.java
r31489 r31490 1 package org.openstreetmap.josm.plugins.mapillary. commands;1 package org.openstreetmap.josm.plugins.mapillary.history; 2 2 3 3 import java.util.ArrayList; 4 4 5 5 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage; 6 import org.openstreetmap.josm.plugins.mapillary.history.commands.MapillaryCommand; 7 import org.openstreetmap.josm.plugins.mapillary.history.commands.MapillaryExecutableCommand; 6 8 7 9 /** -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecordListener.java
r31489 r31490 1 package org.openstreetmap.josm.plugins.mapillary. commands;1 package org.openstreetmap.josm.plugins.mapillary.history; 2 2 3 3 /** -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/CommandDelete.java
r31489 r31490 1 package org.openstreetmap.josm.plugins.mapillary.commands; 1 package org.openstreetmap.josm.plugins.mapillary.history.commands; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.trn; … … 13 13 * 14 14 */ 15 public class CommandDelete Imageextends MapillaryExecutableCommand {15 public class CommandDelete extends MapillaryExecutableCommand { 16 16 17 17 private HashMap<MapillaryAbstractImage, Integer> changesHash; … … 20 20 * @param images 21 21 */ 22 public CommandDelete Image(List<MapillaryAbstractImage> images) {22 public CommandDelete(List<MapillaryAbstractImage> images) { 23 23 super(images); 24 24 this.changesHash = new HashMap<>(); … … 34 34 for (MapillaryAbstractImage img : this.images) { 35 35 this.changesHash.put(img, img.getSequence().getImages().indexOf(img)); 36 MapillaryLayer.getInstance().getData(). delete(img);36 MapillaryLayer.getInstance().getData().remove(img); 37 37 } 38 38 } … … 55 55 @Override 56 56 public void redo() { 57 MapillaryLayer.getInstance().getData(). delete(this.images);57 MapillaryLayer.getInstance().getData().remove(this.images); 58 58 } 59 59 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/CommandJoin.java
r31489 r31490 1 package org.openstreetmap.josm.plugins.mapillary.commands; 1 package org.openstreetmap.josm.plugins.mapillary.history.commands; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/CommandMove.java
r31489 r31490 1 package org.openstreetmap.josm.plugins.mapillary.commands; 1 package org.openstreetmap.josm.plugins.mapillary.history.commands; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.trn; … … 14 14 * 15 15 */ 16 public class CommandMove Imageextends MapillaryCommand {16 public class CommandMove extends MapillaryCommand { 17 17 private double x; 18 18 private double y; … … 28 28 * How much the y coordinate increases. 29 29 */ 30 public CommandMove Image(List<MapillaryAbstractImage> images, double x,30 public CommandMove(List<MapillaryAbstractImage> images, double x, 31 31 double y) { 32 32 super(images); … … 65 65 @Override 66 66 public void sum(MapillaryCommand command) { 67 if (command instanceof CommandMove Image) {68 this.x += ((CommandMove Image) command).x;69 this.y += ((CommandMove Image) command).y;67 if (command instanceof CommandMove) { 68 this.x += ((CommandMove) command).x; 69 this.y += ((CommandMove) command).y; 70 70 } 71 71 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/CommandTurn.java
r31489 r31490 1 package org.openstreetmap.josm.plugins.mapillary.commands; 1 package org.openstreetmap.josm.plugins.mapillary.history.commands; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.trn; … … 14 14 * 15 15 */ 16 public class CommandTurn Imageextends MapillaryCommand {16 public class CommandTurn extends MapillaryCommand { 17 17 private double ca; 18 18 … … 25 25 * How much the images turn. 26 26 */ 27 public CommandTurn Image(List<MapillaryAbstractImage> images, double ca) {27 public CommandTurn(List<MapillaryAbstractImage> images, double ca) { 28 28 super(images); 29 29 this.ca = ca; … … 60 60 @Override 61 61 public void sum(MapillaryCommand command) { 62 if (command instanceof CommandTurn Image) {63 this.ca += ((CommandTurn Image) command).ca;62 if (command instanceof CommandTurn) { 63 this.ca += ((CommandTurn) command).ca; 64 64 } 65 65 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/CommandUnjoin.java
r31489 r31490 1 package org.openstreetmap.josm.plugins.mapillary.commands; 1 package org.openstreetmap.josm.plugins.mapillary.history.commands; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/MapillaryCommand.java
r31489 r31490 1 package org.openstreetmap.josm.plugins.mapillary.commands; 1 package org.openstreetmap.josm.plugins.mapillary.history.commands; 2 2 3 3 import java.util.ArrayList; … … 13 13 */ 14 14 public abstract class MapillaryCommand { 15 protected List<MapillaryAbstractImage> images; 15 /** Set of {@link MapillaryAbstractImage} objects affected by the command */ 16 public List<MapillaryAbstractImage> images; 16 17 17 18 /** -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/MapillaryExecutableCommand.java
r31489 r31490 1 package org.openstreetmap.josm.plugins.mapillary.commands; 1 package org.openstreetmap.josm.plugins.mapillary.history.commands; 2 2 3 3 import java.util.List; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java
r31489 r31490 15 15 import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage; 16 16 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; 17 import org.openstreetmap.josm.plugins.mapillary. commands.CommandJoin;18 import org.openstreetmap.josm.plugins.mapillary.commands.Command Unjoin;19 import org.openstreetmap.josm.plugins.mapillary.commands. MapillaryRecord;17 import org.openstreetmap.josm.plugins.mapillary.history.MapillaryRecord; 18 import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandJoin; 19 import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandUnjoin; 20 20 21 21 /** -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java
r31460 r31490 17 17 import org.openstreetmap.josm.plugins.mapillary.MapillaryImage; 18 18 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; 19 import org.openstreetmap.josm.plugins.mapillary.commands.CommandMoveImage;20 import org.openstreetmap.josm.plugins.mapillary.commands.CommandTurnImage;21 import org.openstreetmap.josm.plugins.mapillary.commands.MapillaryRecord;22 19 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog; 20 import org.openstreetmap.josm.plugins.mapillary.history.MapillaryRecord; 21 import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandMove; 22 import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandTurn; 23 23 24 24 /** … … 134 134 double from = this.data.getSelectedImage().getTempCa(); 135 135 double to = this.data.getSelectedImage().getCa(); 136 this.record.addCommand(new CommandTurn Image(this.data.getMultiSelectedImages(), to136 this.record.addCommand(new CommandTurn(this.data.getMultiSelectedImages(), to 137 137 - from)); 138 138 } else if (this.data.getSelectedImage().getTempLatLon() != this.data … … 140 140 LatLon from = this.data.getSelectedImage().getTempLatLon(); 141 141 LatLon to = this.data.getSelectedImage().getLatLon(); 142 this.record.addCommand(new CommandMove Image(this.data.getMultiSelectedImages(), to142 this.record.addCommand(new CommandMove(this.data.getMultiSelectedImages(), to 143 143 .getX() - from.getX(), to.getY() - from.getY())); 144 144 } -
applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/commands/MapillaryRecordTest.java
r31482 r31490 10 10 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage; 11 11 import org.openstreetmap.josm.plugins.mapillary.MapillaryImage; 12 import org.openstreetmap.josm.plugins.mapillary.history.MapillaryRecord; 13 import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandMove; 14 import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandTurn; 15 import org.openstreetmap.josm.plugins.mapillary.history.commands.MapillaryCommand; 12 16 13 17 /** … … 41 45 @Test 42 46 public void commandTest() { 43 MapillaryCommand cmd12 = new CommandMove Image(47 MapillaryCommand cmd12 = new CommandMove( 44 48 Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }), 45 49 0.1, 0.1); 46 MapillaryCommand cmd23 = new CommandMove Image(50 MapillaryCommand cmd23 = new CommandMove( 47 51 Arrays.asList(new MapillaryAbstractImage[] { this.img2, this.img3 }), 48 52 0.1, 0.1); 49 MapillaryCommand cmd13 = new CommandMove Image(53 MapillaryCommand cmd13 = new CommandMove( 50 54 Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img3 }), 51 55 0.1, 0.1); 52 MapillaryCommand cmd1 = new CommandMove Image(56 MapillaryCommand cmd1 = new CommandMove( 53 57 Arrays.asList(new MapillaryAbstractImage[] { this.img1 }), 54 58 0.1, 0.1); 55 MapillaryCommand cmd31 = new CommandMove Image(59 MapillaryCommand cmd31 = new CommandMove( 56 60 Arrays.asList(new MapillaryAbstractImage[] { this.img3, this.img1 }), 57 61 0.2, 0.2); … … 98 102 @Test 99 103 public void commandMoveTest() { 100 CommandMove Imagecmd1 = new CommandMoveImage(104 CommandMove cmd1 = new CommandMove( 101 105 Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }), 102 106 0.1, 0.1); 103 CommandMove Imagecmd2 = new CommandMoveImage(107 CommandMove cmd2 = new CommandMove( 104 108 Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }), 105 109 0.1, 0.1); … … 132 136 @Test 133 137 public void commandTurnTest() { 134 CommandTurn Imagecmd1 = new CommandTurnImage(138 CommandTurn cmd1 = new CommandTurn( 135 139 Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }), 136 140 0.2); 137 CommandTurn Imagecmd2 = new CommandTurnImage(141 CommandTurn cmd2 = new CommandTurn( 138 142 Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }), 139 143 0.1);
Note:
See TracChangeset
for help on using the changeset viewer.