35
35
import tim.prune.data.TimeDifference;
36
36
import tim.prune.data.Timestamp;
37
37
import tim.prune.data.Track;
38
import tim.prune.data.Unit;
39
import tim.prune.data.UnitSetLibrary;
40
42
* Abstract superclass of the two correlator functions
313
315
JPanel card = new JPanel();
314
316
card.setLayout(new BorderLayout(10, 10));
315
card.add(new JLabel(I18nManager.getText(
316
"dialog.correlate." + getMediaTypeKey() + "select.intro")), BorderLayout.NORTH);
317
JLabel introLabel = new JLabel(I18nManager.getText(
318
"dialog.correlate." + getMediaTypeKey() + "select.intro"));
319
introLabel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
320
card.add(introLabel, BorderLayout.NORTH);
317
321
// table doesn't have model yet - that will be attached later
318
322
_selectionTable = new JTable();
319
323
JScrollPane photoScrollPane = new JScrollPane(_selectionTable);
368
372
offsetPanelBot.setLayout(new FlowLayout());
369
373
offsetPanelBot.setBorder(null);
370
374
_mediaLaterOption = new JRadioButton(I18nManager.getText("dialog.correlate.options." + getMediaTypeKey() + "later"));
371
_pointLaterOption = new JRadioButton(I18nManager.getText("dialog.correlate.options.pointlaterphoto"));
375
_pointLaterOption = new JRadioButton(I18nManager.getText("dialog.correlate.options.pointlater" + getMediaTypeKey()));
372
376
_mediaLaterOption.addItemListener(optionsChangedListener);
373
377
_pointLaterOption.addItemListener(optionsChangedListener);
374
378
ButtonGroup laterGroup = new ButtonGroup();
380
384
offsetPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
381
385
card2Top.add(offsetPanel);
387
// listener for radio buttons
388
ActionListener radioListener = new ActionListener() {
389
public void actionPerformed(ActionEvent e) {
383
393
// time limits section
384
394
JPanel limitsPanel = new JPanel();
385
395
limitsPanel.setBorder(BorderFactory.createTitledBorder(I18nManager.getText("dialog.correlate.options.limitspanel")));
388
398
timeLimitPanel.setLayout(new FlowLayout());
389
399
JRadioButton noTimeLimitRadio = new JRadioButton(I18nManager.getText("dialog.correlate.options.notimelimit"));
390
400
noTimeLimitRadio.addItemListener(optionsChangedListener);
401
noTimeLimitRadio.addActionListener(radioListener);
391
402
timeLimitPanel.add(noTimeLimitRadio);
392
403
_timeLimitRadio = new JRadioButton(I18nManager.getText("dialog.correlate.options.timelimit") + " : ");
393
404
_timeLimitRadio.addItemListener(optionsChangedListener);
405
_timeLimitRadio.addActionListener(radioListener);
394
406
timeLimitPanel.add(_timeLimitRadio);
395
407
groupRadioButtons(noTimeLimitRadio, _timeLimitRadio);
396
408
_limitMinBox = new JTextField(3);
407
419
distLimitPanel.setLayout(new FlowLayout());
408
420
JRadioButton noDistLimitRadio = new JRadioButton(I18nManager.getText("dialog.correlate.options.nodistancelimit"));
409
421
noDistLimitRadio.addItemListener(optionsChangedListener);
422
noDistLimitRadio.addActionListener(radioListener);
410
423
distLimitPanel.add(noDistLimitRadio);
411
424
_distLimitRadio = new JRadioButton(I18nManager.getText("dialog.correlate.options.distancelimit"));
412
425
_distLimitRadio.addItemListener(optionsChangedListener);
426
_distLimitRadio.addActionListener(radioListener);
413
427
distLimitPanel.add(_distLimitRadio);
414
428
groupRadioButtons(noDistLimitRadio, _distLimitRadio);
415
429
_limitDistBox = new JTextField(4);
534
* Enable or disable the edit boxes according to the radio button selections
536
private void enableEditBoxes()
538
// enable/disable text field for distance input
539
_limitDistBox.setEnabled(_distLimitRadio.isSelected());
540
// and for time limits
541
_limitMinBox.setEnabled(_timeLimitRadio.isSelected());
542
_limitSecBox.setEnabled(_timeLimitRadio.isSelected());
520
546
* Parse the time limit values entered and validate them
521
547
* @return TimeDifference object describing limit
558
584
* @return the selected distance units from the dropdown
560
protected Distance.Units getSelectedDistanceUnits()
586
protected Unit getSelectedDistanceUnits()
562
final Distance.Units[] distUnits = {Distance.Units.KILOMETRES, Distance.Units.METRES, Distance.Units.MILES};
588
final Unit[] distUnits = {UnitSetLibrary.UNITS_KILOMETRES, UnitSetLibrary.UNITS_METRES, UnitSetLibrary.UNITS_MILES};
563
589
return distUnits[_distUnitsDropdown.getSelectedIndex()];
635
662
protected PointMediaPair getPointPairForMedia(Track inTrack, MediaObject inMedia, TimeDifference inOffset)
637
664
PointMediaPair pair = new PointMediaPair(inMedia);
638
// Add/subtract offset to media timestamp
639
Timestamp mediaStamp = getMediaTimestamp(inMedia).createMinusOffset(inOffset);
640
int numPoints = inTrack.getNumPoints();
641
for (int i=0; i<numPoints; i++)
665
if (inMedia.hasTimestamp())
643
DataPoint point = inTrack.getPoint(i);
644
if (point.getPhoto() == null && point.getAudio() == null)
667
// Add/subtract offset to media timestamp
668
Timestamp mediaStamp = getMediaTimestamp(inMedia).createMinusOffset(inOffset);
669
int numPoints = inTrack.getNumPoints();
670
for (int i=0; i<numPoints; i++)
646
Timestamp pointStamp = point.getTimestamp();
647
if (pointStamp != null && pointStamp.isValid())
672
DataPoint point = inTrack.getPoint(i);
673
if (point.getPhoto() == null && point.getAudio() == null)
649
long numSeconds = pointStamp.getSecondsSince(mediaStamp);
650
pair.addPoint(point, numSeconds);
675
Timestamp pointStamp = point.getTimestamp();
676
if (pointStamp != null && pointStamp.isValid())
678
long numSeconds = pointStamp.getSecondsSince(mediaStamp);
679
pair.addPoint(point, numSeconds);