X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fload%2FJpegLoader.java;h=a6a45c60b5d1ffe56c8257ac29b9f5e3f31e4a3b;hb=f35b6d628f68e3b5ef19965ad8988d0dd1eb8efa;hp=194f2b7f08b83a09d2a11b72fb2ac4e48f77038c;hpb=112bb0c9b46894adca9a33ed8c99ea712b253185;p=GpsPrune.git diff --git a/tim/prune/load/JpegLoader.java b/tim/prune/load/JpegLoader.java index 194f2b7..a6a45c6 100644 --- a/tim/prune/load/JpegLoader.java +++ b/tim/prune/load/JpegLoader.java @@ -17,19 +17,18 @@ import javax.swing.JPanel; import javax.swing.JProgressBar; import tim.prune.App; -import tim.prune.Config; import tim.prune.I18nManager; +import tim.prune.config.Config; import tim.prune.data.Altitude; import tim.prune.data.DataPoint; +import tim.prune.data.Field; import tim.prune.data.LatLonRectangle; import tim.prune.data.Latitude; import tim.prune.data.Longitude; import tim.prune.data.Photo; import tim.prune.data.Timestamp; -import tim.prune.drew.jpeg.ExifReader; -import tim.prune.drew.jpeg.JpegData; -import tim.prune.drew.jpeg.JpegException; -import tim.prune.drew.jpeg.Rational; +import tim.prune.jpeg.ExifGateway; +import tim.prune.jpeg.JpegData; /** * Class to manage the loading of Jpegs and dealing with the GPS data from them @@ -60,8 +59,7 @@ public class JpegLoader implements Runnable { _app = inApp; _parentFrame = inParentFrame; - String[] fileTypes = {"jpg", "jpe", "jpeg"}; - _fileFilter = new GenericFileFilter("filetype.jpeg", fileTypes); + _fileFilter = new JpegFileFilter(); } @@ -103,16 +101,23 @@ public class JpegLoader implements Runnable if (_fileChooser.showOpenDialog(_parentFrame) == JFileChooser.APPROVE_OPTION) { // Bring up dialog before starting - showDialog(); + if (_progressDialog == null) { + createProgressDialog(); + } + // reset dialog and show it + _progressBar.setValue(0); + _progressBar.setString(""); + _progressDialog.setVisible(true); + // start thread for processing new Thread(this).start(); } } /** - * Show the main dialog + * Create the dialog to show the progress */ - private void showDialog() + private void createProgressDialog() { _progressDialog = new JDialog(_parentFrame, I18nManager.getText("dialog.jpegload.progress.title")); _progressDialog.setLocationRelativeTo(_parentFrame); @@ -135,7 +140,6 @@ public class JpegLoader implements Runnable panel.add(cancelButton); _progressDialog.getContentPane().add(panel); _progressDialog.pack(); - _progressDialog.setVisible(true); } @@ -145,8 +149,8 @@ public class JpegLoader implements Runnable public void run() { // Initialise arrays, errors, summaries - _fileCounts = new int[4]; // files, jpegs, exifs, gps - _photos = new TreeSet(new PhotoSorter()); + _fileCounts = new int[3]; // files, jpegs, gps + _photos = new TreeSet(new MediaSorter()); File[] files = _fileChooser.getSelectedFiles(); // Loop recursively over selected files/directories to count files int numFiles = countFileList(files, true, _subdirCheckbox.isSelected()); @@ -158,10 +162,9 @@ public class JpegLoader implements Runnable // Process the files recursively and build lists of photos processFileList(files, true, _subdirCheckbox.isSelected()); _progressDialog.setVisible(false); + _progressDialog.dispose(); // Sometimes dialog doesn't disappear without this dispose if (_cancelled) {return;} - //System.out.println("Finished - counts are: " + _fileCounts[0] + ", " + _fileCounts[1] - // + ", " + _fileCounts[2] + ", " + _fileCounts[3]); if (_fileCounts[0] == 0) { // No files found at all @@ -173,11 +176,6 @@ public class JpegLoader implements Runnable _app.showErrorMessage("error.jpegload.dialogtitle", "error.jpegload.nojpegsfound"); } else if (!_noExifCheckbox.isSelected() && _fileCounts[2] == 0) - { - // Need coordinates but no exif found - _app.showErrorMessage("error.jpegload.dialogtitle", "error.jpegload.noexiffound"); - } - else if (!_noExifCheckbox.isSelected() && _fileCounts[3] == 0) { // Need coordinates but no gps information found _app.showErrorMessage("error.jpegload.dialogtitle", "error.jpegload.nogpsfound"); @@ -201,7 +199,7 @@ public class JpegLoader implements Runnable if (inFiles != null) { // Loop over elements in array - for (int i=0; i