// Path: src/util/Tuple.java
// public class Tuple<K,V>  {
// 	private K key;
// 	private V value;
// 
// 	/**
// 	 * Creates a new tuple.
// 	 * @param key The key of the tuple
// 	 * @param value The value of the tuple
// 	 */
// 	public Tuple(K key, V value) {
// 		this.key = key;
// 		this.value = value;
// 	}
// 
// 	/**
// 	 * Returns the key
// 	 * @return the key
// 	 */
// 	public K getKey() {
// 		return key;
// 	}
// 
// 	/**
// 	 * Returns the value
// 	 * @return the value
// 	 */
// 	public V getValue() {
// 		return value;
// 	}
// 
// 	/**
// 	 * Returns a string representation of the tuple
// 	 * @return a string representation of the tuple
// 	 */
// 	public String toString() {
// 		return key.toString() + ":" + value.toString();
// 	}
// }
// 
// Path: src/core/SettingsError.java
// public class SettingsError extends SimError {
// 
// 	public SettingsError(String cause) {
// 		super(cause);
// 	}
// 
// 	public SettingsError(String cause, Exception e) {
// 		super(cause,e);
// 	}
// 
// 	public SettingsError(Exception e) {
// 		super(e);
// 	}
// 
// }


import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import util.Tuple;
import core.Coord;
import core.SettingsError;
/*
 * Copyright 2010 Aalto University, ComNet
 * Released under GPLv3. See LICENSE.txt for details.
 */
package input;





/**
 * Reader for ExternalMovement movement model's time-location tuples.
 * <P>
 * First line of the file should be the offset header. Syntax of the header
 * should be:<BR>
 * <CODE>minTime maxTime minX maxX minY maxY minZ maxZ</CODE>
 * <BR>
 * Last two values (Z-axis) are ignored at the moment but can be present
 * in the file.
 * <P>
 * Following lines' syntax should be:<BR>
 * <CODE>time id xPos yPos</CODE><BR>
 * where <CODE>time</CODE> is the time when a node with <CODE>id</CODE> should
 * be at location <CODE>(xPos, yPos)</CODE>.
 * </P>
 * <P>
 * All lines must be sorted by time. Sampling interval (time difference between
 * two time instances) must be same for the whole file.
 * </P>
 */
public class ExternalMovementReader {
	/* Prefix for comment lines (lines starting with this are ignored) */
	public static final String COMMENT_PREFIX = "#";
	private Scanner scanner;
	private double lastTimeStamp = -1;
	private String lastLine;
	private double minTime;
	private double maxTime;
	private double minX;
	private double maxX;
	private double minY;
	private double maxY;
	private boolean normalize;


	/**
	 * Constructor. Creates a new reader that reads the data from a file.
	 * @param inFilePath Path to the file where the data is read
	 * @throws SettingsError if the file wasn't found
	 */
	public ExternalMovementReader(String inFilePath) {
		this.normalize = true;
		File inFile = new File(inFilePath);
		try {
			scanner = new Scanner(inFile);
		} catch (FileNotFoundException e) {
// Path: src/util/Tuple.java
// public class Tuple<K,V>  {
// 	private K key;
// 	private V value;
// 
// 	/**
// 	 * Creates a new tuple.
// 	 * @param key The key of the tuple
// 	 * @param value The value of the tuple
// 	 */
// 	public Tuple(K key, V value) {
// 		this.key = key;
// 		this.value = value;
// 	}
// 
// 	/**
// 	 * Returns the key
// 	 * @return the key
// 	 */
// 	public K getKey() {
// 		return key;
// 	}
// 
// 	/**
// 	 * Returns the value
// 	 * @return the value
// 	 */
// 	public V getValue() {
// 		return value;
// 	}
// 
// 	/**
// 	 * Returns a string representation of the tuple
// 	 * @return a string representation of the tuple
// 	 */
// 	public String toString() {
// 		return key.toString() + ":" + value.toString();
// 	}
// }
// 
// Path: src/core/SettingsError.java
// public class SettingsError extends SimError {
// 
// 	public SettingsError(String cause) {
// 		super(cause);
// 	}
// 
// 	public SettingsError(String cause, Exception e) {
// 		super(cause,e);
// 	}
// 
// 	public SettingsError(Exception e) {
// 		super(e);
// 	}
// 
// }


// Path: src/input/ExternalMovementReader.java
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import util.Tuple;
import core.Coord;
import core.SettingsError;

/*
 * Copyright 2010 Aalto University, ComNet
 * Released under GPLv3. See LICENSE.txt for details.
 */
package input;





/**
 * Reader for ExternalMovement movement model's time-location tuples.
 * <P>
 * First line of the file should be the offset header. Syntax of the header
 * should be:<BR>
 * <CODE>minTime maxTime minX maxX minY maxY minZ maxZ</CODE>
 * <BR>
 * Last two values (Z-axis) are ignored at the moment but can be present
 * in the file.
 * <P>
 * Following lines' syntax should be:<BR>
 * <CODE>time id xPos yPos</CODE><BR>
 * where <CODE>time</CODE> is the time when a node with <CODE>id</CODE> should
 * be at location <CODE>(xPos, yPos)</CODE>.
 * </P>
 * <P>
 * All lines must be sorted by time. Sampling interval (time difference between
 * two time instances) must be same for the whole file.
 * </P>
 */
public class ExternalMovementReader {
	/* Prefix for comment lines (lines starting with this are ignored) */
	public static final String COMMENT_PREFIX = "#";
	private Scanner scanner;
	private double lastTimeStamp = -1;
	private String lastLine;
	private double minTime;
	private double maxTime;
	private double minX;
	private double maxX;
	private double minY;
	private double maxY;
	private boolean normalize;


	/**
	 * Constructor. Creates a new reader that reads the data from a file.
	 * @param inFilePath Path to the file where the data is read
	 * @throws SettingsError if the file wasn't found
	 */
	public ExternalMovementReader(String inFilePath) {
		this.normalize = true;
		File inFile = new File(inFilePath);
		try {
			scanner = new Scanner(inFile);
		} catch (FileNotFoundException e) {
			throw new SettingsError("Couldn't find external movement input " +