Changeset 31450 in osm for applications/editors/josm/plugins/mapillary
- Timestamp:
- 2015-08-05T11:45:39+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
r31445 r31450 18 18 public class MapillaryData { 19 19 20 /** Unique instance of the class */21 public volatile static MapillaryData INSTANCE;22 23 20 private final List<MapillaryAbstractImage> images; 24 21 private MapillaryAbstractImage selectedImage; … … 32 29 * Main constructor. 33 30 */ 34 pr ivateMapillaryData() {31 protected MapillaryData() { 35 32 this.images = new CopyOnWriteArrayList<>(); 36 33 this.multiSelectedImages = new ArrayList<>(); … … 38 35 39 36 addListener(MapillaryPlugin.walkAction); 40 }41 42 /**43 * Returns the unique instance of the class.44 *45 * @return The unique instance of the class.46 */47 public static MapillaryData getInstance() {48 if (INSTANCE == null) {49 INSTANCE = new MapillaryData();50 }51 return INSTANCE;52 }53 54 /**55 * Destroys the unique instance.56 */57 public static void clearInstance() {58 INSTANCE = null;59 37 } 60 38 … … 317 295 } 318 296 if (zoom) 319 Main.map.mapView.zoomTo(MapillaryData.getInstance().getSelectedImage() 320 .getLatLon()); 297 Main.map.mapView.zoomTo(getSelectedImage().getLatLon()); 321 298 if (Main.main != null) 322 299 Main.map.mapView.repaint(); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31449 r31450 99 99 private MapillaryLayer() { 100 100 super(tr("Mapillary Images")); 101 this.data = MapillaryData.getInstance();101 this.data = new MapillaryData(); 102 102 this.bounds = new CopyOnWriteArrayList<>(); 103 103 init(); … … 190 190 if (Main.map.mapView.getEditLayer() != null) 191 191 Main.map.mapView.getEditLayer().data.removeDataSetListener(this); 192 MapillaryData.clearInstance();193 192 clearInstance(); 194 193 super.destroy(); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryExportAction.java
r31445 r31450 18 18 import org.openstreetmap.josm.actions.JosmAction; 19 19 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage; 20 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;21 20 import org.openstreetmap.josm.plugins.mapillary.MapillaryImage; 22 21 import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage; 22 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; 23 23 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin; 24 24 import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryExportManager; … … 71 71 && this.dialog.chooser != null) { 72 72 if (this.dialog.group.isSelected(this.dialog.all.getModel())) { 73 export(Mapillary Data.getInstance().getImages());73 export(MapillaryLayer.getInstance().data.getImages()); 74 74 } else if (this.dialog.group.isSelected(this.dialog.sequence.getModel())) { 75 75 ArrayList<MapillaryAbstractImage> images = new ArrayList<>(); 76 for (MapillaryAbstractImage image : Mapillary Data.getInstance()76 for (MapillaryAbstractImage image : MapillaryLayer.getInstance().data 77 77 .getMultiSelectedImages()) 78 78 if (image instanceof MapillaryImage) { … … 83 83 export(images); 84 84 } else if (this.dialog.group.isSelected(this.dialog.selected.getModel())) { 85 export(Mapillary Data.getInstance().getMultiSelectedImages());85 export(MapillaryLayer.getInstance().data.getMultiSelectedImages()); 86 86 } 87 87 // This option ignores the selected directory. 88 88 } else if (this.dialog.group.isSelected(this.dialog.rewrite.getModel())) { 89 89 ArrayList<MapillaryImportedImage> images = new ArrayList<>(); 90 for (MapillaryAbstractImage image : Mapillary Data.getInstance()90 for (MapillaryAbstractImage image : MapillaryLayer.getInstance().data 91 91 .getImages()) 92 92 if (image instanceof MapillaryImportedImage) { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java
r31445 r31450 22 22 import org.openstreetmap.josm.actions.JosmAction; 23 23 import org.openstreetmap.josm.data.coor.LatLon; 24 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;25 24 import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage; 26 25 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; … … 85 84 try { 86 85 if (extension.equals("jpg") || extension.equals("jpeg")) 87 Mapillary Data.getInstance().add(readJPG(file.listFiles()[j]));86 MapillaryLayer.getInstance().data.add(readJPG(file.listFiles()[j])); 88 87 89 88 else if (extension.equals("png")) 90 Mapillary Data.getInstance().add(readPNG(file.listFiles()[j]));89 MapillaryLayer.getInstance().data.add(readPNG(file.listFiles()[j])); 91 90 } catch (ImageReadException | IOException | NullPointerException e1) { 92 91 Main.error(e1); … … 99 98 .equals(".jpeg")) { 100 99 try { 101 Mapillary Data.getInstance().add(readJPG(file));100 MapillaryLayer.getInstance().data.add(readJPG(file)); 102 101 } catch (ImageReadException ex) { 103 102 Main.error(ex); … … 107 106 } else if (file.getPath().substring(file.getPath().length() - 4) 108 107 .equals(".png")) { 109 Mapillary Data.getInstance().add(readPNG(file));108 MapillaryLayer.getInstance().data.add(readPNG(file)); 110 109 } 111 110 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportIntoSequenceAction.java
r31445 r31450 25 25 import org.openstreetmap.josm.actions.JosmAction; 26 26 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage; 27 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;28 27 import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage; 29 28 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; … … 162 161 MapillaryImportedImage image = new MapillaryImportedImage(latValue, 163 162 lonValue, caValue, file, datetimeOriginal.getStringValue()); 164 Mapillary Data.getInstance().add(image);163 MapillaryLayer.getInstance().data.add(image); 165 164 image.getCapturedAt(); 166 165 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryUploadAction.java
r31449 r31450 13 13 import org.openstreetmap.josm.actions.JosmAction; 14 14 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage; 15 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;16 15 import org.openstreetmap.josm.plugins.mapillary.MapillaryDataListener; 16 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; 17 17 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin; 18 18 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryUploadDialog; … … 38 38 Shortcut.NONE), false, "mapillaryUpload", false); 39 39 this.setEnabled(false); 40 Mapillary Data.getInstance().addListener(this);40 MapillaryLayer.getInstance().data.addListener(this); 41 41 } 42 42 … … 53 53 && (int) pane.getValue() == JOptionPane.OK_OPTION) { 54 54 if (dialog.sequence.isSelected()) { 55 OAuthUtils.uploadSequence(Mapillary Data.getInstance()55 OAuthUtils.uploadSequence(MapillaryLayer.getInstance().data 56 56 .getSelectedImage().getSequence()); 57 57 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryZoomAction.java
r31425 r31450 9 9 import org.openstreetmap.josm.actions.JosmAction; 10 10 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage; 11 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;12 11 import org.openstreetmap.josm.plugins.mapillary.MapillaryDataListener; 12 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; 13 13 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin; 14 14 import org.openstreetmap.josm.tools.Shortcut; … … 29 29 */ 30 30 public MapillaryZoomAction() { 31 super(tr("Zoom to selected image"), MapillaryPlugin .getProvider("icon24.png"),32 tr("Zoom to selected image"), Shortcut.registerShortcut(33 31 super(tr("Zoom to selected image"), MapillaryPlugin 32 .getProvider("icon24.png"), tr("Zoom to selected image"), Shortcut 33 .registerShortcut("Zoom Mapillary", 34 34 tr("Zoom to the currently selected Mapillary image"), 35 35 KeyEvent.CHAR_UNDEFINED, Shortcut.NONE), false, "mapillaryZoom", 36 36 false); 37 Mapillary Data.getInstance().addListener(this);37 MapillaryLayer.getInstance().data.addListener(this); 38 38 this.setEnabled(false); 39 39 } … … 41 41 @Override 42 42 public void actionPerformed(ActionEvent arg0) { 43 if (Mapillary Data.getInstance().getSelectedImage() == null)43 if (MapillaryLayer.getInstance().data.getSelectedImage() == null) 44 44 throw new IllegalStateException(); 45 Main.map.mapView.zoomTo(Mapillary Data.getInstance().getSelectedImage()46 .get LatLon());45 Main.map.mapView.zoomTo(MapillaryLayer.getInstance().data 46 .getSelectedImage().getLatLon()); 47 47 } 48 48 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryExportDialog.java
r31445 r31450 18 18 19 19 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage; 20 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;21 20 import org.openstreetmap.josm.plugins.mapillary.MapillaryImage; 22 21 import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage; 22 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; 23 23 24 24 /** … … 81 81 this.group.add(this.rewrite); 82 82 // Some options are disabled depending on the circumstances 83 if (Mapillary Data.getInstance().getSelectedImage() == null84 || !(Mapillary Data.getInstance().getSelectedImage() instanceof MapillaryImage && ((MapillaryImage) MapillaryData85 .getInstance(). getSelectedImage()).getSequence() != null)) {83 if (MapillaryLayer.getInstance().data.getSelectedImage() == null 84 || !(MapillaryLayer.getInstance().data.getSelectedImage() instanceof MapillaryImage && ((MapillaryImage) MapillaryLayer 85 .getInstance().data.getSelectedImage()).getSequence() != null)) { 86 86 this.sequence.setEnabled(false); 87 87 } 88 if (Mapillary Data.getInstance().getMultiSelectedImages().isEmpty()) {88 if (MapillaryLayer.getInstance().data.getMultiSelectedImages().isEmpty()) { 89 89 this.selected.setEnabled(false); 90 90 } 91 91 this.rewrite.setEnabled(false); 92 for (MapillaryAbstractImage img : MapillaryData.getInstance().getImages()) 92 for (MapillaryAbstractImage img : MapillaryLayer.getInstance().data 93 .getImages()) 93 94 if (img instanceof MapillaryImportedImage) 94 95 this.rewrite.setEnabled(true); … … 158 159 @Override 159 160 public void actionPerformed(ActionEvent arg0) { 160 MapillaryExportDialog.this.choose.setEnabled(!MapillaryExportDialog.this.rewrite.isSelected()); 161 MapillaryExportDialog.this.choose 162 .setEnabled(!MapillaryExportDialog.this.rewrite.isSelected()); 161 163 if (MapillaryExportDialog.this.rewrite.isSelected()) { 162 164 this.lastPath = this.dlg.path.getText(); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterDialog.java
r31445 r31450 26 26 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; 27 27 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage; 28 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;29 28 import org.openstreetmap.josm.plugins.mapillary.MapillaryDataListener; 30 29 import org.openstreetmap.josm.plugins.mapillary.MapillaryImage; 31 30 import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage; 31 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; 32 32 import org.openstreetmap.josm.tools.Shortcut; 33 33 … … 79 79 /** The the {@link JCheckBox} where the respective tag should be searched */ 80 80 private final JCheckBox[] SIGN_CHECKBOXES = { this.signFilter.maxSpeed, 81 this.signFilter.stop, this.signFilter.giveWay, this.signFilter.roundabout, 82 this.signFilter.access, this.signFilter.access, this.signFilter.intersection, 83 this.signFilter.direction, this.signFilter.direction, this.signFilter.intersection, 84 this.signFilter.uneven, this.signFilter.noParking, this.signFilter.noOvertaking, 81 this.signFilter.stop, this.signFilter.giveWay, 82 this.signFilter.roundabout, this.signFilter.access, 83 this.signFilter.access, this.signFilter.intersection, 84 this.signFilter.direction, this.signFilter.direction, 85 this.signFilter.intersection, this.signFilter.uneven, 86 this.signFilter.noParking, this.signFilter.noOvertaking, 85 87 this.signFilter.crossing, this.signFilter.noTurn, this.signFilter.noTurn }; 86 88 … … 174 176 boolean onlySigns = this.onlySigns.isSelected(); 175 177 176 for (MapillaryAbstractImage img : MapillaryData.getInstance().getImages()) { 178 for (MapillaryAbstractImage img : MapillaryLayer.getInstance().data 179 .getImages()) { 177 180 img.setVisible(true); 178 181 if (img instanceof MapillaryImportedImage) { … … 205 208 if (this.time.getSelectedItem().equals(TIME_LIST[1])) { 206 209 if (img.getCapturedAt() < currentTime 207 - ((Integer) this.spinner.getValue()).longValue() * 365 * 24 * 60 * 60208 * 1000) {210 - ((Integer) this.spinner.getValue()).longValue() * 365 * 24 * 60 211 * 60 * 1000) { 209 212 img.setVisible(false); 210 213 continue; … … 213 216 if (this.time.getSelectedItem().equals(TIME_LIST[2])) { 214 217 if (img.getCapturedAt() < currentTime 215 - ((Integer) this.spinner.getValue()).longValue() * 30 * 24 * 60 * 60216 * 1000) {218 - ((Integer) this.spinner.getValue()).longValue() * 30 * 24 * 60 219 * 60 * 1000) { 217 220 img.setVisible(false); 218 221 continue; … … 274 277 @Override 275 278 public void actionPerformed(ActionEvent arg0) { 276 MapillaryFilterDialog.this.onlySigns.setEnabled(MapillaryFilterDialog.this.downloaded.isSelected()); 279 MapillaryFilterDialog.this.onlySigns 280 .setEnabled(MapillaryFilterDialog.this.downloaded.isSelected()); 277 281 } 278 282 } … … 318 322 @Override 319 323 public void actionPerformed(ActionEvent arg0) { 320 MapillaryFilterDialog.this.signChooser.setEnabled(MapillaryFilterDialog.this.onlySigns.isSelected()); 324 MapillaryFilterDialog.this.signChooser 325 .setEnabled(MapillaryFilterDialog.this.onlySigns.isSelected()); 321 326 } 322 327 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java
r31445 r31450 23 23 import org.openstreetmap.josm.gui.SideButton; 24 24 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage; 25 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;26 25 import org.openstreetmap.josm.plugins.mapillary.MapillaryDataListener; 27 26 import org.openstreetmap.josm.plugins.mapillary.MapillaryImage; … … 97 96 tr("Open Mapillary main dialog"), KeyEvent.VK_M, Shortcut.NONE), 98 97 200, false, MapillaryPreferenceSetting.class); 99 Mapillary Data.getInstance().addListener(this);98 MapillaryLayer.getInstance().data.addListener(this); 100 99 addShortcuts(); 101 100 this.mapillaryImageDisplay = new MapillaryImageDisplay(); … … 345 344 @Override 346 345 public void actionPerformed(ActionEvent e) { 347 Mapillary Data.getInstance().selectNext();346 MapillaryLayer.getInstance().data.selectNext(); 348 347 } 349 348 } … … 367 366 @Override 368 367 public void actionPerformed(ActionEvent e) { 369 Mapillary Data.getInstance().selectPrevious();368 MapillaryLayer.getInstance().data.selectPrevious(); 370 369 } 371 370 } … … 390 389 public void actionPerformed(ActionEvent e) { 391 390 if (MapillaryMainDialog.getInstance().getImage() != null) { 392 MapillaryData.getInstance().setSelectedImage(MapillaryLayer.RED, true); 391 MapillaryLayer.getInstance().data.setSelectedImage(MapillaryLayer.RED, 392 true); 393 393 } 394 394 } … … 414 414 public void actionPerformed(ActionEvent e) { 415 415 if (MapillaryMainDialog.getInstance().getImage() != null) { 416 MapillaryData.getInstance().setSelectedImage(MapillaryLayer.BLUE, true); 416 MapillaryLayer.getInstance().data.setSelectedImage(MapillaryLayer.BLUE, 417 true); 417 418 } 418 419 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryUploadDialog.java
r31445 r31450 5 5 import javax.swing.JRadioButton; 6 6 7 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;8 7 import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage; 8 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; 9 9 10 10 /** … … 28 28 29 29 this.sequence = new JRadioButton("Upload selected sequence."); 30 if (Mapillary Data.getInstance().getSelectedImage() == null31 || !(Mapillary Data.getInstance().getSelectedImage() instanceof MapillaryImportedImage))30 if (MapillaryLayer.getInstance().data.getSelectedImage() == null 31 || !(MapillaryLayer.getInstance().data.getSelectedImage() instanceof MapillaryImportedImage)) 32 32 this.sequence.setEnabled(false); 33 33 this.group.add(this.sequence); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/AbstractMode.java
r31445 r31450 28 28 private final static int DOWNLOAD_COOLDOWN = 2000; 29 29 30 protected MapillaryData data = Mapillary Data.getInstance();30 protected MapillaryData data = MapillaryLayer.getInstance().data; 31 31 private static SemiautomaticThread semiautomaticThread = new SemiautomaticThread(); 32 32
Note:
See TracChangeset
for help on using the changeset viewer.