Changeset 31170 in osm for applications/editors/josm/plugins/mapillary/src/org/openstreetmap
- Timestamp:
- 2015-06-01T14:21:30+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31166 r31170 14 14 import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry; 15 15 import org.openstreetmap.josm.data.cache.JCSCacheManager; 16 import org.openstreetmap.josm.data.coor.LatLon; 16 17 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 17 18 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; … … 27 28 import org.openstreetmap.josm.data.osm.event.DataSetListener; 28 29 30 import java.awt.Color; 29 31 import java.awt.Graphics2D; 30 32 import java.awt.Point; … … 45 47 public static Boolean INSTANCED = false; 46 48 public static CacheAccess<String, BufferedImageCacheEntry> CACHE; 47 49 public static MapillaryImage BLUE; 50 public static MapillaryImage RED; 51 48 52 private final MapillaryData mapillaryData; 49 53 private List<Bounds> bounds; … … 143 147 public void paint(Graphics2D g, MapView mv, Bounds box) { 144 148 synchronized (this) { 149 // Draw colored lines 150 this.BLUE = null; 151 this.RED = null; 152 MapillaryToggleDialog.getInstance().blueButton.setEnabled(false); 153 MapillaryToggleDialog.getInstance().redButton.setEnabled(false); 154 if (mapillaryData.getSelectedImage() != null) { 155 MapillaryImage[] closestImages = getClosestImagesFromDifferentSequences(); 156 Point selected = mv.getPoint(mapillaryData.getSelectedImage() 157 .getLatLon()); 158 if (closestImages[0] != null) { 159 this.BLUE = closestImages[0]; 160 g.setColor(Color.BLUE); 161 g.drawLine(mv.getPoint(closestImages[0].getLatLon()).x, 162 mv.getPoint(closestImages[0].getLatLon()).y, 163 selected.x, selected.y); 164 MapillaryToggleDialog.getInstance().blueButton.setEnabled(true); 165 } 166 if (closestImages[1] != null) { 167 this.RED = closestImages[1]; 168 g.setColor(Color.RED); 169 g.drawLine(mv.getPoint(closestImages[1].getLatLon()).x, 170 mv.getPoint(closestImages[1].getLatLon()).y, 171 selected.x, selected.y); 172 MapillaryToggleDialog.getInstance().redButton.setEnabled(true); 173 } 174 } 175 g.setColor(Color.WHITE); 145 176 for (MapillaryImage image : mapillaryData.getImages()) { 146 177 Point p = mv.getPoint(image.getLatLon()); … … 190 221 } 191 222 223 private MapillaryImage[] getClosestImagesFromDifferentSequences() { 224 MapillaryImage[] ret = new MapillaryImage[2]; 225 double[] distances = { 100, 100 }; 226 LatLon selectedCoords = mapillaryData.getSelectedImage().getLatLon(); 227 double maxJumpDistance = 100; 228 for (MapillaryImage image : mapillaryData.getImages()) { 229 if (image.getLatLon().greatCircleDistance(selectedCoords) < maxJumpDistance 230 && mapillaryData.getSelectedImage().getSequence() != image 231 .getSequence()) { 232 if ((ret[0] == null && ret[1] == null) 233 || (image.getLatLon().greatCircleDistance( 234 selectedCoords) < distances[0] && (ret[1] == null || image 235 .getSequence() != ret[1].getSequence()))) { 236 ret[0] = image; 237 distances[0] = image.getLatLon().greatCircleDistance( 238 selectedCoords); 239 } else if ((ret[1] == null || image.getLatLon() 240 .greatCircleDistance(selectedCoords) < distances[1]) 241 && image.getSequence() != ret[0].getSequence()) { 242 ret[1] = image; 243 distances[1] = image.getLatLon().greatCircleDistance( 244 selectedCoords); 245 } 246 } 247 } 248 return ret; 249 } 250 192 251 @Override 193 252 public void mouseClicked(MouseEvent e) { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
r31166 r31170 37 37 exportAction = new MapillaryExportAction(); 38 38 39 DOWNLOAD_MENU = MainMenu .add(Main.main.menu.imageryMenu,40 downloadAction, false , 0);39 DOWNLOAD_MENU = MainMenu 40 .add(Main.main.menu.imageryMenu, downloadAction, false); 41 41 EXPORT_MENU = MainMenu.add(Main.main.menu.fileMenu, exportAction, 42 42 false, 14); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillarySequence.java
r31166 r31170 13 13 public class MapillarySequence { 14 14 private final List<MapillaryImage> images; 15 private String timestamp; 15 16 16 17 public MapillarySequence() { … … 29 30 public List<MapillaryImage> getImages() { 30 31 return this.images; 32 } 33 34 public void setTimestamp(String timestamp) { 35 this.timestamp = timestamp; 36 } 37 38 public String getTimestamp() { 39 return this.timestamp; 31 40 } 32 41 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryToggleDialog.java
r31166 r31170 6 6 import java.awt.image.BufferedImage; 7 7 import java.awt.BorderLayout; 8 import java.awt.Color; 8 9 import java.awt.FlowLayout; 9 10 import java.io.ByteArrayInputStream; … … 43 44 final SideButton previousButton = new SideButton( 44 45 new previousPictureAction()); 46 final SideButton redButton = new SideButton(new redAction()); 47 final SideButton blueButton = new SideButton(new blueAction()); 45 48 46 49 public MapillaryImageDisplay mapillaryImageDisplay; … … 58 61 buttons = new JPanel(); 59 62 buttons.setLayout(new FlowLayout(FlowLayout.CENTER)); 63 blueButton.setBackground(Color.BLUE); 64 redButton.setBackground(Color.RED); 65 blueButton.setForeground(Color.WHITE); 66 redButton.setForeground(Color.WHITE); 67 buttons.add(blueButton); 60 68 buttons.add(previousButton); 61 buttons.add(nextButton); 69 buttons.add(nextButton); 70 buttons.add(redButton); 71 62 72 this.add(buttons, BorderLayout.SOUTH); 63 73 } … … 179 189 } 180 190 } 191 192 class redAction extends AbstractAction { 193 public redAction() { 194 putValue(NAME, "Red"); 195 putValue(SHORT_DESCRIPTION, 196 tr("Shows the previous picture in the sequence")); 197 } 198 199 @Override 200 public void actionPerformed(ActionEvent e) { 201 if (MapillaryToggleDialog.getInstance().getImage() != null) { 202 MapillaryData.getInstance().setSelectedImage(MapillaryLayer.RED); 203 MapillaryToggleDialog.getInstance().setImage(MapillaryLayer.RED); 204 MapillaryToggleDialog.getInstance().updateImage(); 205 Main.map.mapView.zoomTo(MapillaryData.getInstance() 206 .getSelectedImage().getLatLon()); 207 } 208 } 209 } 210 211 class blueAction extends AbstractAction { 212 public blueAction() { 213 putValue(NAME, "Blue"); 214 putValue(SHORT_DESCRIPTION, 215 tr("Shows the previous picture in the sequence")); 216 } 217 218 @Override 219 public void actionPerformed(ActionEvent e) { 220 if (MapillaryToggleDialog.getInstance().getImage() != null) { 221 MapillaryData.getInstance().setSelectedImage(MapillaryLayer.BLUE); 222 MapillaryToggleDialog.getInstance().setImage(MapillaryLayer.BLUE); 223 MapillaryToggleDialog.getInstance().updateImage(); 224 Main.map.mapView.zoomTo(MapillaryData.getInstance() 225 .getSelectedImage().getLatLon()); 226 } 227 } 228 } 181 229 182 230 /** -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java
r31166 r31170 79 79 } 80 80 MapillarySequence sequence = new MapillarySequence(); 81 //sequence.setTimestamp(jsonobj.getString("created_at")); 81 82 int first = -1; 82 83 int last = -1;
Note:
See TracChangeset
for help on using the changeset viewer.