Changeset 31489 in osm for applications
- Timestamp:
- 2015-08-12T12:39:30+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java
r31460 r31489 6 6 import java.awt.Point; 7 7 import java.awt.event.MouseEvent; 8 import java.util.Array List;8 import java.util.Arrays; 9 9 10 10 import org.openstreetmap.josm.Main; … … 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.MapillarySequence; 17 import org.openstreetmap.josm.plugins.mapillary.commands.CommandJoin; 18 import org.openstreetmap.josm.plugins.mapillary.commands.CommandUnjoin; 19 import org.openstreetmap.josm.plugins.mapillary.commands.MapillaryRecord; 18 20 19 21 /** … … 44 46 } else if (this.lastClick != null 45 47 && this.data.getHighlightedImage() instanceof MapillaryImportedImage) { 46 if (((this.data.getHighlightedImage().previous() == null && this.lastClick.next() == null) || (this.data 47 .getHighlightedImage().next() == null && this.lastClick.previous() == null)) 48 && (this.data.getHighlightedImage().getSequence() != this.lastClick.getSequence() || this.lastClick 49 .getSequence() == null)) { 50 join(this.lastClick, (MapillaryImportedImage) this.data.getHighlightedImage()); 48 if (((this.data.getHighlightedImage().previous() == null && this.lastClick 49 .next() == null) || (this.data.getHighlightedImage().next() == null && this.lastClick 50 .previous() == null)) 51 && (this.data.getHighlightedImage().getSequence() != this.lastClick 52 .getSequence() || this.lastClick.getSequence() == null)) { 53 54 MapillaryRecord.getInstance().addCommand( 55 new CommandJoin(Arrays.asList(new MapillaryAbstractImage[] { 56 this.lastClick, this.data.getHighlightedImage() }))); 51 57 } else if (this.lastClick.next() == this.data.getHighlightedImage() 52 58 || this.lastClick.previous() == this.data.getHighlightedImage()) 53 unjoin(this.lastClick, (MapillaryImportedImage) this.data.getHighlightedImage()); 59 MapillaryRecord.getInstance().addCommand( 60 new CommandUnjoin(Arrays.asList(new MapillaryAbstractImage[] { 61 this.lastClick, this.data.getHighlightedImage() }))); 54 62 this.lastClick = null; 55 63 } 56 MapillaryData.dataUpdated(); 64 if (Main.main != null) 65 MapillaryData.dataUpdated(); 57 66 } 58 67 … … 77 86 } 78 87 79 private static void join(MapillaryImportedImage img1, MapillaryImportedImage img2) {80 MapillaryImportedImage firstImage = img1;81 MapillaryImportedImage secondImage = img2;82 83 if (img1.next() != null) {84 firstImage = img2;85 secondImage = img1;86 }87 if (firstImage.getSequence() == null) {88 MapillarySequence seq = new MapillarySequence();89 seq.add(firstImage);90 firstImage.setSequence(seq);91 }92 if (secondImage.getSequence() == null) {93 MapillarySequence seq = new MapillarySequence();94 seq.add(secondImage);95 img2.setSequence(seq);96 }97 98 for (MapillaryAbstractImage img : secondImage.getSequence().getImages()) {99 firstImage.getSequence().add(img);100 img.setSequence(firstImage.getSequence());101 }102 }103 104 private static void unjoin(MapillaryImportedImage img1, MapillaryImportedImage img2) {105 MapillaryImportedImage firstImage = img1;106 MapillaryImportedImage secondImage = img2;107 108 if (img1.next() != img2) {109 firstImage = img2;110 secondImage = img1;111 }112 113 ArrayList<MapillaryAbstractImage> firstHalf = new ArrayList<>(firstImage114 .getSequence().getImages()115 .subList(0, firstImage.getSequence().getImages().indexOf(secondImage)));116 ArrayList<MapillaryAbstractImage> secondHalf = new ArrayList<>(firstImage117 .getSequence()118 .getImages()119 .subList(firstImage.getSequence().getImages().indexOf(secondImage),120 firstImage.getSequence().getImages().size()));121 122 MapillarySequence seq1 = new MapillarySequence();123 MapillarySequence seq2 = new MapillarySequence();124 125 for (MapillaryAbstractImage img : firstHalf) {126 img.setSequence(seq1);127 seq1.add(img);128 }129 for (MapillaryAbstractImage img : secondHalf) {130 img.setSequence(seq2);131 seq2.add(img);132 }133 }134 135 88 @Override 136 89 public String toString() { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtils.java
r31475 r31489 7 7 import java.net.URISyntaxException; 8 8 import java.net.URL; 9 import java.util.ArrayList; 9 10 10 11 import org.apache.commons.imaging.common.RationalNumber; 11 12 import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants; 12 13 import org.openstreetmap.josm.Main; 14 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage; 15 import org.openstreetmap.josm.plugins.mapillary.MapillaryData; 16 import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage; 13 17 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; 18 import org.openstreetmap.josm.plugins.mapillary.MapillarySequence; 14 19 15 20 /** … … 120 125 } 121 126 } 127 128 /** 129 * Joins two images into the same sequence. 130 * 131 * @param img1 132 * @param img2 133 */ 134 public synchronized static void join(MapillaryImportedImage img1, 135 MapillaryImportedImage img2) { 136 MapillaryImportedImage firstImage = img1; 137 MapillaryImportedImage secondImage = img2; 138 139 if (img1.next() != null) { 140 firstImage = img2; 141 secondImage = img1; 142 } 143 if (firstImage.getSequence() == null) { 144 MapillarySequence seq = new MapillarySequence(); 145 seq.add(firstImage); 146 firstImage.setSequence(seq); 147 } 148 if (secondImage.getSequence() == null) { 149 MapillarySequence seq = new MapillarySequence(); 150 seq.add(secondImage); 151 img2.setSequence(seq); 152 } 153 154 for (MapillaryAbstractImage img : secondImage.getSequence().getImages()) { 155 firstImage.getSequence().add(img); 156 img.setSequence(firstImage.getSequence()); 157 } 158 if (Main.main != null) 159 MapillaryData.dataUpdated(); 160 } 161 162 /** 163 * Separates two images belonging to the same sequence. 164 * 165 * @param img1 166 * @param img2 167 */ 168 public synchronized static void unjoin(MapillaryImportedImage img1, 169 MapillaryImportedImage img2) { 170 MapillaryImportedImage firstImage = img1; 171 MapillaryImportedImage secondImage = img2; 172 173 if (img1.next() != img2) { 174 firstImage = img2; 175 secondImage = img1; 176 } 177 178 ArrayList<MapillaryAbstractImage> firstHalf = new ArrayList<>(firstImage 179 .getSequence().getImages() 180 .subList(0, firstImage.getSequence().getImages().indexOf(secondImage))); 181 ArrayList<MapillaryAbstractImage> secondHalf = new ArrayList<>(firstImage 182 .getSequence() 183 .getImages() 184 .subList(firstImage.getSequence().getImages().indexOf(secondImage), 185 firstImage.getSequence().getImages().size())); 186 187 MapillarySequence seq1 = new MapillarySequence(); 188 MapillarySequence seq2 = new MapillarySequence(); 189 190 for (MapillaryAbstractImage img : firstHalf) { 191 img.setSequence(seq1); 192 seq1.add(img); 193 } 194 for (MapillaryAbstractImage img : secondHalf) { 195 img.setSequence(seq2); 196 seq2.add(img); 197 } 198 if (Main.main != null) 199 MapillaryData.dataUpdated(); 200 } 122 201 }
Note:
See TracChangeset
for help on using the changeset viewer.