~ubuntu-branches/ubuntu/utopic/gpsprune/utopic

« back to all changes in this revision

Viewing changes to tim/prune/correlate/Correlator.java

  • Committer: Package Import Robot
  • Author(s): Mònica Ramírez Arceda
  • Date: 2013-05-15 10:26:51 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130515102651-130bcw88wox3u0q0
Tags: 15-1
* New upstream version
  - "nautical mile" is added to unit selector (Closes: #639503)
* debian/control:
  - Add myself as an uploader
  - Standards-Version bump to 3.9.4, no changes needed
* debian/copyright:
  - Add required Copyright field to tim/prune/function/srtm/gen/ files
  - Update years
* debian/scripts/gpsprune:
  - Fix sed commands, when there is no host/port, proxyhost/proxyport
    variables must be empty.
    Thanks to Simó Albert i Beltran <sim6@probeta.net> and to
    <debian@activityworkshop.net> for the patch!

Show diffs side-by-side

added added

removed removed

Lines of Context:
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;
38
40
 
39
41
/**
40
42
 * Abstract superclass of the two correlator functions
312
314
        {
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);
382
386
 
 
387
                // listener for radio buttons
 
388
                ActionListener radioListener = new ActionListener() {
 
389
                        public void actionPerformed(ActionEvent e) {
 
390
                                enableEditBoxes();
 
391
                        }
 
392
                };
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);
517
531
        }
518
532
 
519
533
        /**
 
534
         * Enable or disable the edit boxes according to the radio button selections
 
535
         */
 
536
        private void enableEditBoxes()
 
537
        {
 
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());
 
543
        }
 
544
 
 
545
        /**
520
546
         * Parse the time limit values entered and validate them
521
547
         * @return TimeDifference object describing limit
522
548
         */
557
583
        /**
558
584
         * @return the selected distance units from the dropdown
559
585
         */
560
 
        protected Distance.Units getSelectedDistanceUnits()
 
586
        protected Unit getSelectedDistanceUnits()
561
587
        {
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()];
564
590
        }
565
591
 
604
630
                _mediaLaterOption.setSelected(timeDiff.getIsPositive());
605
631
                _pointLaterOption.setSelected(!timeDiff.getIsPositive());
606
632
                _previewEnabled = true;
 
633
                enableEditBoxes();
607
634
                createPreview(timeDiff, true);
608
635
        }
609
636
 
635
662
        protected PointMediaPair getPointPairForMedia(Track inTrack, MediaObject inMedia, TimeDifference inOffset)
636
663
        {
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())
642
666
                {
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++)
645
671
                        {
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)
648
674
                                {
649
 
                                        long numSeconds = pointStamp.getSecondsSince(mediaStamp);
650
 
                                        pair.addPoint(point, numSeconds);
 
675
                                        Timestamp pointStamp = point.getTimestamp();
 
676
                                        if (pointStamp != null && pointStamp.isValid())
 
677
                                        {
 
678
                                                long numSeconds = pointStamp.getSecondsSince(mediaStamp);
 
679
                                                pair.addPoint(point, numSeconds);
 
680
                                        }
651
681
                                }
652
682
                        }
653
683
                }