Changeset 31380 in osm for applications
- Timestamp:
- 2015-07-15T16:35:08+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryExportAction.java
r31350 r31380 5 5 import java.awt.Dimension; 6 6 import java.awt.event.ActionEvent; 7 import java.awt.event.ActionListener; 7 8 import java.awt.event.KeyEvent; 8 9 import java.io.IOException; … … 10 11 import java.util.List; 11 12 13 import javax.swing.JButton; 12 14 import javax.swing.JDialog; 13 15 import javax.swing.JOptionPane; … … 44 46 @Override 45 47 public void actionPerformed(ActionEvent e) { 46 dialog = new MapillaryExportDialog(); 47 JOptionPane pane = new JOptionPane(dialog, JOptionPane.PLAIN_MESSAGE, 48 JOptionPane.OK_CANCEL_OPTION); 48 JOptionPane pane = new JOptionPane(); 49 50 JButton ok = new JButton("Ok"); 51 ok.addActionListener(new OKAction(pane)); 52 JButton cancel = new JButton(tr("Cancel")); 53 cancel.addActionListener(new CancelAction(pane)); 54 55 56 dialog = new MapillaryExportDialog(ok); 57 pane.setMessage(dialog); 58 pane.setOptions(new JButton[] { ok, cancel }); 59 49 60 JDialog dlg = pane.createDialog(Main.parent, tr("Export images")); 50 61 dlg.setMinimumSize(new Dimension(400, 150)); … … 95 106 } 96 107 108 private class OKAction implements ActionListener { 109 private JOptionPane pane; 110 111 public OKAction(JOptionPane pane) { 112 this.pane = pane; 113 } 114 115 @Override 116 public void actionPerformed(ActionEvent e) { 117 pane.setValue(JOptionPane.OK_OPTION); 118 } 119 } 120 121 private class CancelAction implements ActionListener { 122 private JOptionPane pane; 123 124 public CancelAction(JOptionPane pane) { 125 this.pane = pane; 126 } 127 128 @Override 129 public void actionPerformed(ActionEvent e) { 130 pane.setValue(JOptionPane.CANCEL_OPTION); 131 } 132 } 97 133 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportWriterThread.java
r31350 r31380 13 13 import org.apache.commons.imaging.ImageReadException; 14 14 import org.apache.commons.imaging.ImageWriteException; 15 import org.apache.commons.imaging.Imaging; 16 import org.apache.commons.imaging.common.ImageMetadata; 15 17 import org.apache.commons.imaging.common.RationalNumber; 18 import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata; 16 19 import org.apache.commons.imaging.formats.jpeg.exif.ExifRewriter; 20 import org.apache.commons.imaging.formats.tiff.TiffImageMetadata; 17 21 import org.apache.commons.imaging.formats.tiff.constants.ExifTagConstants; 18 22 import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants; … … 67 71 } else if (mimg instanceof MapillaryImage) 68 72 finalPath = path + "/" + ((MapillaryImage) mimg).getKey(); 69 else 70 finalPath = path + "/" + i; 73 else if (mimg instanceof MapillaryImportedImage) 74 finalPath = path + "/" 75 + ((MapillaryImportedImage) mimg).getFile().getName(); 76 ; 71 77 // Creates a temporal file that is going to be deleted after 72 78 // writing the EXIF tags. … … 75 81 76 82 // Write EXIF tags 77 TiffOutputSet outputSet = new TiffOutputSet(); 78 TiffOutputDirectory exifDirectory = outputSet 79 .getOrCreateExifDirectory(); 83 TiffOutputSet outputSet = null; 84 TiffOutputDirectory exifDirectory = null; 85 // If the image is imported, loads the rest of the EXIF data. 86 if (mimg instanceof MapillaryImportedImage) { 87 final ImageMetadata metadata = Imaging 88 .getMetadata(((MapillaryImportedImage) mimg).getFile()); 89 final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata; 90 if (null != jpegMetadata) { 91 final TiffImageMetadata exif = jpegMetadata.getExif(); 92 if (null != exif) { 93 outputSet = exif.getOutputSet(); 94 } 95 } 96 } 97 if (null == outputSet) { 98 outputSet = new TiffOutputSet(); 99 } 100 exifDirectory = outputSet.getOrCreateExifDirectory(); 101 102 exifDirectory 103 .removeField(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION_REF); 80 104 exifDirectory.add(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION_REF, 81 105 GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION_REF_VALUE_TRUE_NORTH); 106 107 exifDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION); 82 108 exifDirectory.add(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION, 83 109 RationalNumber.valueOf(mimg.getCa())); 84 if (mimg instanceof MapillaryImportedImage) { 110 111 exifDirectory.removeField(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL); 112 if (mimg instanceof MapillaryImportedImage) 85 113 exifDirectory.add(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL, 86 114 ((MapillaryImportedImage) mimg).getDate("yyyy/MM/dd hh:mm:ss")); 87 }else if (mimg instanceof MapillaryImage)115 else if (mimg instanceof MapillaryImage) 88 116 exifDirectory.add(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL, 89 117 ((MapillaryImage) mimg).getDate("yyyy/MM/dd hh/mm/ss")); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryExportDialog.java
r31350 r31380 48 48 public JFileChooser chooser; 49 49 protected String exportDirectory; 50 private JButton ok; 50 51 51 public MapillaryExportDialog() { 52 public MapillaryExportDialog(JButton ok) { 53 this.ok = ok; 54 ok.setEnabled(false); 55 52 56 setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); 53 57 … … 101 105 102 106 /** 103 * Creates the folder cho ser GUI.107 * Creates the folder chooser GUI. 104 108 */ 105 109 @Override … … 115 119 path.setText(chooser.getSelectedFile().toString()); 116 120 this.updateUI(); 121 ok.setEnabled(true); 117 122 } 118 123 }
Note:
See TracChangeset
for help on using the changeset viewer.