X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;ds=sidebyside;f=tim%2Fprune%2Fdata%2FTrackInfo.java;h=d58cc167d6353239983e846a4e41969d250e7c89;hb=54b9d8bc8f0025ccf97a67d9dd217ef1f9cf082f;hp=f8e3c844b8ac86bc46c7c45bf8b78c7bc976f88e;hpb=da0b1f449260a0b4a94318006382a9039726ef3e;p=GpsPrune.git diff --git a/tim/prune/data/TrackInfo.java b/tim/prune/data/TrackInfo.java index f8e3c84..d58cc16 100644 --- a/tim/prune/data/TrackInfo.java +++ b/tim/prune/data/TrackInfo.java @@ -10,7 +10,6 @@ import tim.prune.UpdateMessageBroker; */ public class TrackInfo { - private UpdateMessageBroker _broker = null; private Track _track = null; private Selection _selection = null; private FileInfo _fileInfo = null; @@ -20,13 +19,11 @@ public class TrackInfo /** * Constructor * @param inTrack Track object - * @param inBroker broker object */ - public TrackInfo(Track inTrack, UpdateMessageBroker inBroker) + public TrackInfo(Track inTrack) { - _broker = inBroker; _track = inTrack; - _selection = new Selection(_track, inBroker); + _selection = new Selection(_track); _fileInfo = new FileInfo(); _photoList = new PhotoList(); } @@ -85,31 +82,17 @@ public class TrackInfo } - /** - * Load the specified data into the Track - * @param inFieldArray array of Field objects describing fields - * @param inPointArray 2d object array containing data - * @param inAltFormat altitude format - */ - public void loadTrack(Field[] inFieldArray, Object[][] inPointArray, int inAltFormat) - { - _track.cropTo(0); - _track.load(inFieldArray, inPointArray, inAltFormat); - _selection.clearAll(); - } - - /** * Add a Set of Photos * @param inSet Set containing Photo objects * @return array containing number of photos and number of points added */ - public int[] addPhotos(Set inSet) + public int[] addPhotos(Set inSet) { // Firstly count number of points and photos to add int numPhotosToAdd = 0; int numPointsToAdd = 0; - Iterator iterator = null; + Iterator iterator = null; if (inSet != null && !inSet.isEmpty()) { iterator = inSet.iterator(); @@ -117,7 +100,7 @@ public class TrackInfo { try { - Photo photo = (Photo) iterator.next(); + Photo photo = iterator.next(); if (photo != null && !_photoList.contains(photo)) { numPhotosToAdd++; @@ -142,7 +125,7 @@ public class TrackInfo { try { - Photo photo = (Photo) iterator.next(); + Photo photo = iterator.next(); if (photo != null && !_photoList.contains(photo)) { // Add photo @@ -198,7 +181,7 @@ public class TrackInfo if (_track.deletePoint(_selection.getCurrentPointIndex())) { _selection.modifyPointDeleted(); - _broker.informSubscribers(); + UpdateMessageBroker.informSubscribers(); return true; } return false; @@ -236,38 +219,22 @@ public class TrackInfo } // update subscribers _selection.modifyPointDeleted(); - _broker.informSubscribers(); + UpdateMessageBroker.informSubscribers(); } return true; } /** - * Compress the track to the given resolution - * @param inResolution resolution - * @return number of points deleted - */ - public int compress(int inResolution) - { - int numDeleted = _track.compress(inResolution); - if (numDeleted > 0) { - _selection.clearAll(); - _broker.informSubscribers(); - } - return numDeleted; - } - - - /** - * Delete all the duplicate points in the track + * Delete all the points which have been marked for deletion * @return number of points deleted */ - public int deleteDuplicates() + public int deleteMarkedPoints() { - int numDeleted = _track.deleteDuplicates(); + int numDeleted = _track.deleteMarkedPoints(); if (numDeleted > 0) { _selection.clearAll(); - _broker.informSubscribers(); + UpdateMessageBroker.informSubscribers(); } return numDeleted; } @@ -285,15 +252,29 @@ public class TrackInfo /** * Interpolate extra points between two selected ones - * @param inStartIndex start index of interpolation * @param inNumPoints num points to insert * @return true if successful */ public boolean interpolate(int inNumPoints) { boolean success = _track.interpolate(_selection.getStart(), inNumPoints); - if (success) + if (success) { _selection.selectRangeEnd(_selection.getEnd() + inNumPoints); + } + return success; + } + + + /** + * Average selected points to create a new one + * @return true if successful + */ + public boolean average() + { + boolean success = _track.average(_selection.getStart(), _selection.getEnd()); + if (success) { + _selection.selectPoint(_selection.getEnd()+1); + } return success; } @@ -331,13 +312,4 @@ public class TrackInfo _selection.selectPhotoAndPoint(-1, -1); } } - - - /** - * Fire a trigger to all data subscribers - */ - public void triggerUpdate() - { - _broker.informSubscribers(); - } }