File: AppendRangeCmd.java

package info (click to toggle)
gpsprune 26.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,824 kB
  • sloc: java: 52,154; sh: 25; makefile: 21; python: 15
file content (44 lines) | stat: -rw-r--r-- 917 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package tim.prune.cmd;

import tim.prune.DataSubscriber;
import tim.prune.data.DataPoint;
import tim.prune.data.TrackInfo;

import java.util.List;

/**
 * Command to append a range of points to the track
 */
public class AppendRangeCmd extends Command
{
	private final List<DataPoint> _points;

	public AppendRangeCmd(List<DataPoint> inPoints) {
		this(null, inPoints);
	}

	AppendRangeCmd(Command inParent, List<DataPoint> inPoints)
	{
		super(inParent);
		_points = inPoints;
	}

	@Override
	public int getUpdateFlags() {
		return DataSubscriber.DATA_ADDED_OR_REMOVED;
	}

	@Override
	protected boolean executeCommand(TrackInfo inInfo)
	{
		if (_points == null || _points.isEmpty()) {
			return false;
		}
		return inInfo.appendRange(_points);
	}

	@Override
	protected Command makeInverse(TrackInfo inInfo) {
		return new DeleteFinalRangeCmd(this, _points.size());
	}
}