Changeset 31222 in osm for applications/editors
- Timestamp:
- 2015-06-05T12:07:56+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 5 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
r31218 r31222 183 183 */ 184 184 public void addMultiSelectedImage(MapillaryImage image) { 185 if (this.getSelectedImage() != null) 186 this.multiSelectedImages.add(image); 187 else 188 this.setSelectedImage(image); 185 if (!this.multiSelectedImages.contains(image)) { 186 if (this.getSelectedImage() != null) 187 this.multiSelectedImages.add(image); 188 else 189 this.setSelectedImage(image); 190 } 189 191 Main.map.mapView.repaint(); 190 192 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryDownloadAction.java
r31173 r31222 28 28 tr("Create Mapillary layer."), Shortcut.registerShortcut( 29 29 "menu:Mapillary", tr("Menu: {0}", tr("Mapillary")), 30 KeyEvent.VK_M, Shortcut.ALT_CTRL_SHIFT), false, "mapillaryDownload", false); 30 KeyEvent.VK_M, Shortcut.ALT_CTRL_SHIFT), false, 31 "mapillaryDownload", false); 31 32 } 32 33 … … 40 41 public void actionPerformed(ActionEvent arg0) { 41 42 this.layer = null; 42 if (Main.map == null) { 43 if (Main.map == null || Main.map.mapView == null 44 || Main.map.mapView.getEditLayer() == null) { 43 45 return; 44 46 } … … 55 57 Main.map.mapView.setActiveLayer(layer); 56 58 else 57 Main.map.mapView.setActiveLayer(Main.map.mapView.getEditLayer()); 59 Main.map.mapView 60 .setActiveLayer(Main.map.mapView.getEditLayer()); 58 61 } 59 62 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java
r31219 r31222 14 14 private final String key; 15 15 /** Postion of the picture */ 16 p rivatefinal LatLon latLon;16 public final LatLon latLon; 17 17 /** Direction of the picture */ 18 18 private final double ca; … … 22 22 private boolean isModified = false; 23 23 /** Temporal position of the picture until it is uplaoded */ 24 p rivateLatLon tempLatLon;24 public LatLon tempLatLon; 25 25 /** 26 26 * When the object is being dragged in the map, the temporal position is 27 27 * stored here 28 28 */ 29 p rivateLatLon movingLatLon;29 public LatLon movingLatLon; 30 30 /** Temporal direction of the picture until it is uplaoded */ 31 31 private double tempCa; … … 74 74 public LatLon getLatLon() { 75 75 return movingLatLon; 76 } 77 78 public LatLon getTempLatLon() { 79 return tempLatLon; 76 80 } 77 81 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31219 r31222 5 5 import org.apache.commons.jcs.access.CacheAccess; 6 6 import org.openstreetmap.josm.plugins.mapillary.cache.MapillaryCache; 7 import org.openstreetmap.josm.plugins.mapillary.commands.CommandMoveImage; 8 import org.openstreetmap.josm.plugins.mapillary.commands.CommandTurnImage; 9 import org.openstreetmap.josm.plugins.mapillary.commands.MapillaryRecord; 7 10 import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryDownloader; 8 11 import org.openstreetmap.josm.Main; … … 58 61 public static MapillaryImage RED; 59 62 60 private final MapillaryData mapillaryData; 63 private final MapillaryData mapillaryData = MapillaryData.getInstance(); 64 private final MapillaryRecord record = MapillaryRecord.getInstance(); 65 61 66 private List<Bounds> bounds; 62 67 private MapillaryToggleDialog tgd; … … 66 71 public MapillaryLayer() { 67 72 super(tr("Mapillary Images")); 68 mapillaryData = MapillaryData.getInstance();69 73 bounds = new ArrayList<>(); 70 74 init(); … … 117 121 .getInstance()) 118 122 return; 119 if (e.getClickCount() == 2 && mapillaryData.getSelectedImage() != null) { 120 for (MapillaryImage img : mapillaryData.getSelectedImage().getSequence().getImages()) { 123 MapillaryImage closest = getClosest(e.getPoint()); 124 if (e.getClickCount() == 2 125 && mapillaryData.getSelectedImage() != null 126 && closest != null) { 127 for (MapillaryImage img : closest.getSequence().getImages()) { 121 128 mapillaryData.addMultiSelectedImage(img); 122 129 } 123 130 } 124 MapillaryImage closest = getClosest(e.getPoint());125 131 this.start = e.getPoint(); 126 132 this.closest = closest; 127 133 if (mapillaryData.getMultiSelectedImages().contains(closest)) 128 134 return; 129 if (e.getModifiers() == (MouseEvent.BUTTON1_MASK | MouseEvent.CTRL_MASK)) 135 if (e.getModifiers() == (MouseEvent.BUTTON1_MASK | MouseEvent.CTRL_MASK) 136 && closest != null) 130 137 mapillaryData.addMultiSelectedImage(closest); 131 138 else 132 139 mapillaryData.setSelectedImage(closest); 133 140 } 134 135 private MapillaryImage getClosest(Point clickPoint) {141 142 private MapillaryImage getClosest(Point clickPoint) { 136 143 double snapDistance = 10; 137 144 double minDistance = Double.MAX_VALUE; … … 149 156 } 150 157 } 151 return closest; 158 return closest; 152 159 } 153 160 154 161 @Override 155 162 public void mouseDragged(MouseEvent e) { 163 if (Main.map.mapView.getActiveLayer() != MapillaryLayer 164 .getInstance()) 165 return; 156 166 if (MapillaryData.getInstance().getSelectedImage() != null) { 157 167 if (lastButton == MouseEvent.BUTTON1 && !e.isShiftDown()) { … … 169 179 && e.isShiftDown()) { 170 180 this.closest.turn(Math.toDegrees(Math.atan2( 171 (e.getX() - start.x), -(e.getY() - start.y))) - closest.getTempCa()); 181 (e.getX() - start.x), -(e.getY() - start.y))) 182 - closest.getTempCa()); 172 183 for (MapillaryImage img : MapillaryData.getInstance() 173 184 .getMultiSelectedImages()) { 174 185 img.turn(Math.toDegrees(Math.atan2( 175 (e.getX() - start.x), -(e.getY() - start.y))) - closest.getTempCa()); 186 (e.getX() - start.x), -(e.getY() - start.y))) 187 - closest.getTempCa()); 176 188 } 177 189 Main.map.repaint(); … … 182 194 @Override 183 195 public void mouseReleased(MouseEvent e) { 184 for (MapillaryImage img : MapillaryData.getInstance() 196 if (mapillaryData.getSelectedImage() == null) 197 return; 198 if (mapillaryData.getSelectedImage().getTempCa() != mapillaryData 199 .getSelectedImage().getCa()) { 200 double from = mapillaryData.getSelectedImage().getTempCa(); 201 double to = mapillaryData.getSelectedImage().getCa(); 202 record.addCommand(new CommandTurnImage(mapillaryData 203 .getMultiSelectedImages(), to - from)); 204 } else if (mapillaryData.getSelectedImage().getTempLatLon() != mapillaryData 205 .getSelectedImage().getLatLon()) { 206 LatLon from = mapillaryData.getSelectedImage() 207 .getTempLatLon(); 208 LatLon to = mapillaryData.getSelectedImage().getLatLon(); 209 record.addCommand(new CommandMoveImage(mapillaryData 210 .getMultiSelectedImages(), to.getX() - from.getX(), 211 to.getY() - from.getY())); 212 } 213 for (MapillaryImage img : mapillaryData 185 214 .getMultiSelectedImages()) { 186 215 if (img != null) -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
r31213 r31222 10 10 import org.openstreetmap.josm.data.cache.JCSCacheManager; 11 11 import org.openstreetmap.josm.gui.MainMenu; 12 import org.openstreetmap.josm.gui.MapView; 13 import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener; 12 14 import org.openstreetmap.josm.Main; 13 15 import org.openstreetmap.josm.gui.MapFrame; 16 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 14 17 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 15 18 import org.openstreetmap.josm.plugins.Plugin; … … 23 26 * 24 27 */ 25 public class MapillaryPlugin extends Plugin {28 public class MapillaryPlugin extends Plugin implements EditLayerChangeListener{ 26 29 27 30 public static final ImageIcon ICON24 = new ImageProvider("icon24.png") … … 53 56 false, 14); 54 57 EXPORT_MENU.setEnabled(false); 58 DOWNLOAD_MENU.setEnabled(false); 59 60 MapView.addEditLayerChangeListener(this); 55 61 try { 56 62 CACHE = JCSCacheManager.getCache("mapillary", 10, 10000, … … 81 87 return new MapillaryPreferenceSetting(); 82 88 } 89 90 @Override 91 public void editLayerChanged(OsmDataLayer oldLayer, OsmDataLayer newLayer) { 92 if (oldLayer == null && newLayer != null) 93 DOWNLOAD_MENU.setEnabled(true); 94 else if (oldLayer != null && newLayer == null) 95 DOWNLOAD_MENU.setEnabled(false); 96 } 83 97 }
Note:
See TracChangeset
for help on using the changeset viewer.