1 package tim.prune.function.compress;
3 import java.awt.Component;
4 import java.awt.event.ActionListener;
6 import tim.prune.data.DataPoint;
7 import tim.prune.data.Track;
10 * Algorithm for detecting duplicate points to compress
12 public class DuplicatePointAlgorithm extends CompressionAlgorithm
14 /** Number of points before this one to consider as duplicates */
15 private static final int NUM_POINTS_TO_BACKTRACK = 20;
19 * @param inTrack track object
20 * @param inDetails track details object
21 * @param inListener listener to attach to activation control
23 public DuplicatePointAlgorithm(Track inTrack, TrackDetails inDetails, ActionListener inListener)
25 super(inTrack, inDetails, inListener);
29 * Perform the compression and work out which points should be deleted
30 * @param inFlags deletion flags from previous algorithms
31 * @return number of points deleted
33 protected int compress(boolean[] inFlags)
35 int numPoints = _track.getNumPoints();
37 // Loop over all points looking for duplicates
38 for (int i=1; i<numPoints; i++)
40 // Don't delete points which are already marked as deleted
43 DataPoint currPoint = _track.getPoint(i);
44 // Don't delete any photo points or audio points
45 if (!currPoint.hasMedia())
47 // loop over last few points before this one
48 for (int j=i-NUM_POINTS_TO_BACKTRACK; j<i; j++)
50 if (j<0) {j=0;} // only look at last few points, but not before 0
51 if (!inFlags[j] && currPoint.isDuplicate(_track.getPoint(j)))
66 * @return specific gui components for dialog
68 protected Component getSpecificGuiComponents()
70 // no parameters to set, so no gui components
75 * @return title key for box
77 protected String getTitleTextKey()
79 return "dialog.compress.duplicates.title";