Changeset 31495 in osm for applications
- Timestamp:
- 2015-08-13T00:07:14+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31490 r31495 190 190 public void destroy() { 191 191 setMode(null); 192 192 MapillaryRecord.getInstance().reset(); 193 193 AbstractMode.resetThread(); 194 194 MapillaryDownloader.stopAll(); … … 211 211 public static void clearInstance() { 212 212 INSTANCE = null; 213 }214 215 /**216 * Zooms to fit all the {@link MapillaryAbstractImage} icons into the map217 * view.218 */219 public void showAllPictures() {220 double minLat = 90;221 double minLon = 180;222 double maxLat = -90;223 double maxLon = -180;224 for (MapillaryAbstractImage img : this.data.getImages()) {225 if (img.getLatLon().lat() < minLat)226 minLat = img.getLatLon().lat();227 if (img.getLatLon().lon() < minLon)228 minLon = img.getLatLon().lon();229 if (img.getLatLon().lat() > maxLat)230 maxLat = img.getLatLon().lat();231 if (img.getLatLon().lon() > maxLon)232 maxLon = img.getLatLon().lon();233 }234 Main.map.mapView.zoomTo(new Bounds(new LatLon(minLat, minLon), new LatLon(235 maxLat, maxLon)));236 213 } 237 214 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java
r31490 r31495 118 118 } 119 119 MapillaryRecord.getInstance().addCommand(new CommandImport(images)); 120 Mapillary Layer.getInstance().showAllPictures();120 MapillaryUtils.showAllPictures(); 121 121 } 122 122 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportIntoSequenceAction.java
r31490 r31495 116 116 MapillaryRecord.getInstance().addCommand(new CommandImport(this.images)); 117 117 } 118 Mapillary Layer.getInstance().showAllPictures();118 MapillaryUtils.showAllPictures(); 119 119 } 120 120 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/FinishedUploadDialog.java
r31473 r31495 36 36 text.setAlignmentX(Component.CENTER_ALIGNMENT); 37 37 this.add(text); 38 JButton web = new JButton("Approve upload in the website.");38 JButton web = new JButton("Approve upload on the website."); 39 39 web.addActionListener(new WebAction()); 40 40 web.setAlignmentX(Component.CENTER_ALIGNMENT); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryHistoryDialog.java
r31492 r31495 9 9 import java.awt.event.ActionEvent; 10 10 import java.awt.event.KeyEvent; 11 import java.awt.event.MouseEvent; 12 import java.awt.event.MouseListener; 11 13 import java.util.ArrayList; 12 14 import java.util.Arrays; 15 import java.util.concurrent.ConcurrentHashMap; 13 16 14 17 import javax.swing.AbstractAction; … … 18 21 import javax.swing.JTree; 19 22 import javax.swing.SwingUtilities; 23 import javax.swing.event.TreeSelectionEvent; 24 import javax.swing.event.TreeSelectionListener; 20 25 import javax.swing.tree.DefaultTreeCellRenderer; 21 26 import javax.swing.tree.DefaultTreeModel; 27 import javax.swing.tree.TreeSelectionModel; 22 28 23 29 import org.openstreetmap.josm.gui.SideButton; … … 25 31 import org.openstreetmap.josm.plugins.mapillary.history.MapillaryRecord; 26 32 import org.openstreetmap.josm.plugins.mapillary.history.MapillaryRecordListener; 33 import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandDelete; 27 34 import org.openstreetmap.josm.plugins.mapillary.history.commands.MapillaryCommand; 35 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils; 28 36 import org.openstreetmap.josm.tools.GBC; 29 37 import org.openstreetmap.josm.tools.ImageProvider; … … 48 56 private static MapillaryHistoryDialog INSTANCE; 49 57 58 private transient UndoRedoSelectionListener undoSelectionListener; 59 private transient UndoRedoSelectionListener redoSelectionListener; 60 50 61 private final DefaultTreeModel undoTreeModel = new DefaultTreeModel( 51 62 new DefaultMutableTreeNode()); … … 61 72 private SideButton redoButton; 62 73 74 private ConcurrentHashMap<Object, MapillaryCommand> map; 75 63 76 private MapillaryHistoryDialog() { 64 77 super(tr("Mapillary history"), "mapillaryhistory.png", … … 69 82 MapillaryRecord.getInstance().addListener(this); 70 83 84 this.map = new ConcurrentHashMap<>(); 85 71 86 this.undoTree.expandRow(0); 72 87 this.undoTree.setShowsRootHandles(true); 73 88 this.undoTree.setRootVisible(false); 74 89 this.undoTree.setCellRenderer(new MapillaryCellRenderer()); 90 this.undoTree.getSelectionModel().setSelectionMode( 91 TreeSelectionModel.SINGLE_TREE_SELECTION); 92 this.undoTree.addMouseListener(new MouseEventHandler()); 93 this.undoSelectionListener = new UndoRedoSelectionListener(this.undoTree); 94 this.undoTree.getSelectionModel().addTreeSelectionListener( 95 this.undoSelectionListener); 96 75 97 this.redoTree.expandRow(0); 76 98 this.redoTree.setCellRenderer(new MapillaryCellRenderer()); 77 99 this.redoTree.setShowsRootHandles(true); 78 100 this.redoTree.setRootVisible(false); 101 this.redoTree.getSelectionModel().setSelectionMode( 102 TreeSelectionModel.SINGLE_TREE_SELECTION); 103 this.redoTree.addMouseListener(new MouseEventHandler()); 104 this.redoSelectionListener = new UndoRedoSelectionListener(this.redoTree); 105 this.redoTree.getSelectionModel().addTreeSelectionListener( 106 this.redoSelectionListener); 79 107 80 108 JPanel treesPanel = new JPanel(new GridBagLayout()); … … 130 158 DefaultMutableTreeNode undoRoot = new DefaultMutableTreeNode(); 131 159 160 this.map.clear(); 132 161 for (MapillaryCommand command : undoCommands) { 133 if (command != null) 134 undoRoot.add(new DefaultMutableTreeNode(command.toString())); 162 if (command != null) { 163 DefaultMutableTreeNode node = new DefaultMutableTreeNode( 164 command.toString()); 165 this.map.put(node, command); 166 undoRoot.add(node); 167 } 135 168 } 136 169 for (MapillaryCommand command : redoCommands) { 137 if (command != null) 138 redoRoot.add(new DefaultMutableTreeNode(command.toString())); 170 if (command != null) { 171 DefaultMutableTreeNode node = new DefaultMutableTreeNode( 172 command.toString()); 173 this.map.put(node, command); 174 redoRoot.add(node); 175 } 139 176 } 140 177 … … 213 250 MapillaryHistoryDialog.INSTANCE = null; 214 251 } 252 253 private class MouseEventHandler implements MouseListener { 254 255 @Override 256 public void mouseClicked(MouseEvent e) { 257 } 258 259 @Override 260 public void mouseEntered(MouseEvent e) { 261 } 262 263 @Override 264 public void mouseExited(MouseEvent e) { 265 } 266 267 @Override 268 public void mousePressed(MouseEvent e) { 269 if (e.getClickCount() == 2) { 270 if (MapillaryHistoryDialog.this.undoTree.getSelectionPath() != null) { 271 MapillaryCommand cmd = MapillaryHistoryDialog.this.map 272 .get(MapillaryHistoryDialog.this.undoTree.getSelectionPath() 273 .getLastPathComponent()); 274 if (!(cmd instanceof CommandDelete)) 275 MapillaryUtils.showPictures(cmd.images, true); 276 } else 277 MapillaryUtils.showPictures(MapillaryHistoryDialog.this.map 278 .get(MapillaryHistoryDialog.this.redoTree.getSelectionPath() 279 .getLastPathComponent()).images, true); 280 } 281 } 282 283 @Override 284 public void mouseReleased(MouseEvent e) { 285 } 286 } 287 288 private class UndoRedoSelectionListener implements TreeSelectionListener { 289 290 private JTree source; 291 292 private UndoRedoSelectionListener(JTree source) { 293 this.source = source; 294 } 295 296 @Override 297 public void valueChanged(TreeSelectionEvent e) { 298 if (this.source == MapillaryHistoryDialog.this.undoTree) { 299 MapillaryHistoryDialog.this.redoTree.getSelectionModel() 300 .removeTreeSelectionListener( 301 MapillaryHistoryDialog.this.redoSelectionListener); 302 MapillaryHistoryDialog.this.redoTree.clearSelection(); 303 MapillaryHistoryDialog.this.redoTree.getSelectionModel() 304 .addTreeSelectionListener( 305 MapillaryHistoryDialog.this.redoSelectionListener); 306 } 307 if (this.source == MapillaryHistoryDialog.this.redoTree) { 308 MapillaryHistoryDialog.this.undoTree.getSelectionModel() 309 .removeTreeSelectionListener( 310 MapillaryHistoryDialog.this.undoSelectionListener); 311 MapillaryHistoryDialog.this.undoTree.clearSelection(); 312 MapillaryHistoryDialog.this.undoTree.getSelectionModel() 313 .addTreeSelectionListener( 314 MapillaryHistoryDialog.this.undoSelectionListener); 315 } 316 } 317 } 215 318 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecord.java
r31492 r31495 127 127 lis.recordChanged(); 128 128 } 129 130 /** 131 * Resets the object to its start state. 132 */ 133 public void reset() { 134 this.commandList.clear(); 135 this.position = -1; 136 } 129 137 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtils.java
r31489 r31495 8 8 import java.net.URL; 9 9 import java.util.ArrayList; 10 import java.util.List; 11 12 import javax.swing.SwingUtilities; 10 13 11 14 import org.apache.commons.imaging.common.RationalNumber; 12 15 import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants; 13 16 import org.openstreetmap.josm.Main; 17 import org.openstreetmap.josm.data.Bounds; 18 import org.openstreetmap.josm.data.coor.LatLon; 14 19 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage; 15 20 import org.openstreetmap.josm.plugins.mapillary.MapillaryData; … … 25 30 */ 26 31 public class MapillaryUtils { 32 33 private static double MIN_ZOOM_SQUARE_SIDE = 0.002; 34 27 35 /** 28 36 * Updates the help text at the bottom of the window. … … 199 207 MapillaryData.dataUpdated(); 200 208 } 209 210 /** 211 * Zooms to fit all the given {@link MapillaryAbstractImage} objects. 212 * 213 * @param images 214 * The images your are zooming to. 215 * @param select 216 * Whether the added images must be selected or not. 217 */ 218 public static void showPictures(final List<MapillaryAbstractImage> images, 219 final boolean select) { 220 if (!SwingUtilities.isEventDispatchThread()) { 221 SwingUtilities.invokeLater(new Runnable() { 222 @Override 223 public void run() { 224 showPictures(images, select); 225 } 226 }); 227 } else { 228 double minLat = 90; 229 double minLon = 180; 230 double maxLat = -90; 231 double maxLon = -180; 232 for (MapillaryAbstractImage img : images) { 233 if (img.getLatLon().lat() < minLat) 234 minLat = img.getLatLon().lat(); 235 if (img.getLatLon().lon() < minLon) 236 minLon = img.getLatLon().lon(); 237 if (img.getLatLon().lat() > maxLat) 238 maxLat = img.getLatLon().lat(); 239 if (img.getLatLon().lon() > maxLon) 240 maxLon = img.getLatLon().lon(); 241 } 242 Bounds zoomBounds = new Bounds(new LatLon(minLat, minLon), new LatLon( 243 maxLat, maxLon)); 244 // The zoom rectangle must have a minimum size. 245 double latExtent = zoomBounds.getMaxLat() - zoomBounds.getMinLat() >= MIN_ZOOM_SQUARE_SIDE ? zoomBounds 246 .getMaxLat() - zoomBounds.getMinLat() 247 : MIN_ZOOM_SQUARE_SIDE; 248 double lonExtent = zoomBounds.getMaxLon() - zoomBounds.getMinLon() >= MIN_ZOOM_SQUARE_SIDE ? zoomBounds 249 .getMaxLon() - zoomBounds.getMinLon() 250 : MIN_ZOOM_SQUARE_SIDE; 251 zoomBounds = new Bounds(zoomBounds.getCenter(), latExtent, lonExtent); 252 253 Main.map.mapView.zoomTo(zoomBounds); 254 MapillaryLayer.getInstance().getData().setSelectedImage(null); 255 if (select) 256 MapillaryLayer.getInstance().getData().addMultiSelectedImage(images); 257 if (Main.main != null) 258 MapillaryData.dataUpdated(); 259 } 260 } 261 262 /** 263 * Zooms to fit all the {@link MapillaryAbstractImage} objects stored in the 264 * database. 265 */ 266 public static void showAllPictures() { 267 showPictures(MapillaryLayer.getInstance().getData().getImages(), false); 268 } 201 269 }
Note:
See TracChangeset
for help on using the changeset viewer.