X-Git-Url: https://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Fcorrelate%2FPhotoCorrelator.java;h=f5f86b1ab36982565a44d9cac29d9bd7aff7ee46;hp=84c179ec3d3a23576d9e6ee83cdf1133758e20af;hb=f35b6d628f68e3b5ef19965ad8988d0dd1eb8efa;hpb=3745d70b1427bb8ac1a085e47cbdc566936784e1 diff --git a/tim/prune/correlate/PhotoCorrelator.java b/tim/prune/correlate/PhotoCorrelator.java index 84c179e..f5f86b1 100644 --- a/tim/prune/correlate/PhotoCorrelator.java +++ b/tim/prune/correlate/PhotoCorrelator.java @@ -1,73 +1,30 @@ package tim.prune.correlate; -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Calendar; -import java.util.Iterator; -import java.util.TreeSet; - -import javax.swing.BorderFactory; -import javax.swing.BoxLayout; -import javax.swing.ButtonGroup; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JDialog; -import javax.swing.JLabel; import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JRadioButton; -import javax.swing.JScrollPane; import javax.swing.JTable; -import javax.swing.JTextField; import tim.prune.App; -import tim.prune.GenericFunction; +import tim.prune.DataSubscriber; import tim.prune.I18nManager; +import tim.prune.UpdateMessageBroker; import tim.prune.data.DataPoint; -import tim.prune.data.Distance; -import tim.prune.data.Field; +import tim.prune.data.MediaList; import tim.prune.data.Photo; import tim.prune.data.PhotoList; import tim.prune.data.TimeDifference; -import tim.prune.data.Timestamp; -import tim.prune.data.Track; -import tim.prune.data.TrackInfo; import tim.prune.undo.UndoCorrelatePhotos; /** * Class to manage the automatic correlation of photos to points * including the GUI stuff to control the correlation options */ -public class PhotoCorrelator extends GenericFunction +public class PhotoCorrelator extends Correlator { - private JDialog _dialog; - private JButton _nextButton = null, _backButton = null; - private JButton _okButton = null; - private JPanel _cards = null; - private JTable _photoSelectionTable = null; - private JLabel _tipLabel = null; - private JTextField _offsetHourBox = null, _offsetMinBox = null, _offsetSecBox = null; - private JRadioButton _photoLaterOption = null, _pointLaterOption = null; - private JRadioButton _timeLimitRadio = null, _distLimitRadio = null; - private JTextField _limitMinBox = null, _limitSecBox = null; - private JTextField _limitDistBox = null; - private JComboBox _distUnitsDropdown = null; - private JTable _previewTable = null; - private boolean _firstTabAvailable = false; - private boolean _previewEnabled = false; // flag required to enable preview function on second panel - - /** * Constructor * @param inApp App object to report actions to */ - public PhotoCorrelator(App inApp) - { + public PhotoCorrelator(App inApp) { super(inApp); } @@ -77,360 +34,34 @@ public class PhotoCorrelator extends GenericFunction return "function.correlatephotos"; } - /** - * Reset dialog and show it - */ - public void begin() - { - // First create dialog if necessary - if (_dialog == null) - { - _dialog = new JDialog(_parentFrame, I18nManager.getText(getNameKey()), true); - _dialog.setLocationRelativeTo(_parentFrame); - _dialog.getContentPane().add(makeDialogContents()); - _dialog.pack(); - } - // Check whether track has timestamps, exit if not - if (!_app.getTrackInfo().getTrack().hasData(Field.TIMESTAMP)) - { - JOptionPane.showMessageDialog(_parentFrame, I18nManager.getText("dialog.correlate.notimestamps"), - I18nManager.getText(getNameKey()), JOptionPane.INFORMATION_MESSAGE); - return; - } - // Check for any non-correlated photos, show warning continue/cancel - if (!trackHasUncorrelatedPhotos()) - { - Object[] buttonTexts = {I18nManager.getText("button.continue"), I18nManager.getText("button.cancel")}; - if (JOptionPane.showOptionDialog(_parentFrame, I18nManager.getText("dialog.correlate.nouncorrelatedphotos"), - I18nManager.getText(getNameKey()), JOptionPane.YES_NO_OPTION, - JOptionPane.WARNING_MESSAGE, null, buttonTexts, buttonTexts[1]) - == JOptionPane.NO_OPTION) - { - return; - } - } - PhotoSelectionTableModel model = makePhotoSelectionTableModel(_app.getTrackInfo()); - _firstTabAvailable = model != null && model.getRowCount() > 0; - CardLayout cl = (CardLayout) _cards.getLayout(); - if (_firstTabAvailable) - { - cl.first(_cards); - _nextButton.setEnabled(true); - _backButton.setEnabled(false); - _tipLabel.setVisible(false); - _photoSelectionTable.setModel(model); - _previewEnabled = false; - for (int i=0; i set = new TreeSet(); - // loop through rows of table adding to list - int numRows = inModel.getRowCount(); - int i; - for (i=0; i iterator = set.iterator(); - for (i=0; i<(numRows+1)/2; i++) - { - pair = iterator.next(); - } - return pair.getIndex(); - } - - - /** - * Disable the ok button - */ - public void disableOkButton() - { - if (_okButton != null) { - _okButton.setEnabled(false); - } - } - - - /** - * Check if the track has any uncorrelated photos - * @return true if there are any photos which are not connected to points - */ - private boolean trackHasUncorrelatedPhotos() - { - PhotoList photoList = _app.getTrackInfo().getPhotoList(); - int numPhotos = photoList.getNumPhotos(); - // loop over photos - for (int i=0; i