1 package tim.prune.data;
3 import tim.prune.UpdateMessageBroker;
6 * Class to hold all track information, including data
7 * and the selection information
11 private UpdateMessageBroker _broker = null;
12 private Track _track = null;
13 private Selection _selection = null;
14 private FileInfo _fileInfo = null;
18 * @param inTrack Track object
19 * @param inBroker broker object
21 public TrackInfo(Track inTrack, UpdateMessageBroker inBroker)
25 _selection = new Selection(_track, inBroker);
26 _fileInfo = new FileInfo();
31 * @return the Track object
33 public Track getTrack()
40 * @return the Selection object
42 public Selection getSelection()
49 * @return the FileInfo object
51 public FileInfo getFileInfo()
57 * Get the currently selected point, if any
58 * @return DataPoint if single point selected, otherwise null
60 public DataPoint getCurrentPoint()
62 return _track.getPoint(_selection.getCurrentPointIndex());
67 * Load the specified data into the Track
68 * @param inFieldArray array of Field objects describing fields
69 * @param inPointArray 2d object array containing data
70 * @param inAltFormat altitude format
72 public void loadTrack(Field[] inFieldArray, Object[][] inPointArray, int inAltFormat)
75 _track.load(inFieldArray, inPointArray, inAltFormat);
76 _selection.clearAll();
81 * Delete the currently selected range of points
82 * @return true if successful
84 public boolean deleteRange()
86 int currPoint = _selection.getCurrentPointIndex();
87 int startSel = _selection.getStart();
88 int endSel = _selection.getEnd();
89 boolean answer = _track.deleteRange(startSel, endSel);
90 // clear range selection
91 _selection.modifyRangeDeleted();
97 * Delete the currently selected point
98 * @return true if point deleted
100 public boolean deletePoint()
102 if (_track.deletePoint(_selection.getCurrentPointIndex()))
104 _selection.modifyPointDeleted();
105 _broker.informSubscribers();
113 * Compress the track to the given resolution
114 * @param inResolution resolution
115 * @return number of points deleted
117 public int compress(int inResolution)
119 int numDeleted = _track.compress(inResolution);
121 _selection.clearAll();
127 * Delete all the duplicate points in the track
128 * @return number of points deleted
130 public int deleteDuplicates()
132 int numDeleted = _track.deleteDuplicates();
134 _selection.clearAll();
140 * Clone the selected range of data points
141 * @return shallow copy of DataPoint objects
143 public DataPoint[] cloneSelectedRange()
145 return _track.cloneRange(_selection.getStart(), _selection.getEnd());
150 * Interpolate extra points between two selected ones
151 * @param inStartIndex start index of interpolation
152 * @param inNumPoints num points to insert
153 * @return true if successful
155 public boolean interpolate(int inNumPoints)
157 boolean success = _track.interpolate(_selection.getStart(), inNumPoints);
159 _selection.selectRangeEnd(_selection.getEnd() + inNumPoints);