<commit_before>package worldgui;

import utils.Vector;
import air.SimWorld;

import com.trolltech.qt.gui.QGraphicsEllipseItem;
import com.trolltech.qt.gui.QGraphicsScene;
import com.trolltech.qt.gui.QPainter;
import com.trolltech.qt.gui.QStyleOptionGraphicsItem;
import com.trolltech.qt.gui.QWidget;

public class Aircraft extends QGraphicsEllipseItem implements WorldObject {

	private air.Aircraft aircraft;
	
	public Aircraft(air.Aircraft a) {
		super();
		this.aircraft = a;
		
		//this.setRect(this.x, this.y, 10, 10);
	}
	
	public void paint(QPainter p, QStyleOptionGraphicsItem s, QWidget w) {
		Vector pos = this.getPosition();
		
		double xPos = WorldGui.getXPos(pos.getX());
		double yPos = WorldGui.getYPos(pos.getY());
		this.setRect(xPos, yPos, 10, 10);
		p.drawEllipse((int)xPos, (int)yPos, 10, 10);
	}
	
	public void draw(QGraphicsScene scene) {
		Vector pos = this.getPosition();
		double xPos = WorldGui.getXPos(pos.getX());
		double yPos = WorldGui.getYPos(pos.getY());
		scene.addEllipse((int)xPos, (int)yPos, 10, 10);
	}

	protected Vector getPosition() {
		int state = this.aircraft.getState();
		
		switch (state) {
			case air.Aircraft.ON_FLIGHT:
				return this.getFlightPosition();
			case air.Aircraft.ON_GROUND:
			case air.Aircraft.WAITING_FOR_TAKE_OFF:
				return this.getGroundPosition();
			case air.Aircraft.TAKING_OFF:
				Vector position = this.getTakeoffPosition();
				System.err.println(position);
				return position;
			case air.Aircraft.ON_HOLDING_LOOP:
				return this.getHoldingLoopPosition();
			case air.Aircraft.LANDING:
			case air.Aircraft.ARRIVING: 
				return this.getLandingPosition();
		}
		
		return new Vector(new double[] {500000, 200000});
	}
	
	private Vector getGroundPosition() {
		double xPos = this.aircraft.getCurrentAirPort().getX1();
		double yPos = this.aircraft.getCurrentAirPort().getY1();
		
		return new Vector(new double[] {xPos, yPos});
	}
	
	private Vector getTakeoffPosition() {
		double startX   = this.aircraft.getCurrentAirPort().getX1();
		double startY   = this.aircraft.getCurrentAirPort().getY1();
		double endX     = this.aircraft.getCurrentAirPort().getX2();
		double endY     = this.aircraft.getCurrentAirPort().getY2();
		
		long t0        = this.aircraft.getLastTime() * SimWorld.getInstance().getTimeScale();
		long t         = System.currentTimeMillis() - 
							SimWorld.getInstance().getSimulator().getRtStartTime();
		
		double speed     = this.getSpeed();
		double acc       = this.getAcceleration();
		double t_acc     = speed / acc;
		
		Vector n       = new Vector(new double[] {endX - startX, endY - startY});
		n = n.normalize();
		
		System.out.println("t: " + t + " diff " + t0 + t_acc);
		if (t < t0 + t_acc) {
			Vector dir = n.multiply(0.5 * Math.pow(t - t0, 2) * acc);
			System.out.println("Dir: " + dir);
			return new Vector(new double[] {
					startX + dir.getX(),<commit_msg>Commented debug messages<commit_after>package worldgui;

import utils.Vector;
import air.SimWorld;

import com.trolltech.qt.gui.QGraphicsEllipseItem;
import com.trolltech.qt.gui.QGraphicsScene;
import com.trolltech.qt.gui.QPainter;
import com.trolltech.qt.gui.QStyleOptionGraphicsItem;
import com.trolltech.qt.gui.QWidget;

public class Aircraft extends QGraphicsEllipseItem implements WorldObject {

	private air.Aircraft aircraft;
	
	public Aircraft(air.Aircraft a) {
		super();
		this.aircraft = a;
		
		//this.setRect(this.x, this.y, 10, 10);
	}
	
	public void paint(QPainter p, QStyleOptionGraphicsItem s, QWidget w) {
		Vector pos = this.getPosition();
		
		double xPos = WorldGui.getXPos(pos.getX());
		double yPos = WorldGui.getYPos(pos.getY());
		this.setRect(xPos, yPos, 10, 10);
		p.drawEllipse((int)xPos, (int)yPos, 10, 10);
	}
	
	public void draw(QGraphicsScene scene) {
		Vector pos = this.getPosition();
		double xPos = WorldGui.getXPos(pos.getX());
		double yPos = WorldGui.getYPos(pos.getY());
		scene.addEllipse((int)xPos, (int)yPos, 10, 10);
	}

	protected Vector getPosition() {
		int state = this.aircraft.getState();
		
		switch (state) {
			case air.Aircraft.ON_FLIGHT:
				return this.getFlightPosition();
			case air.Aircraft.ON_GROUND:
			case air.Aircraft.WAITING_FOR_TAKE_OFF:
				return this.getGroundPosition();
			case air.Aircraft.TAKING_OFF:
				Vector position = this.getTakeoffPosition();
				//System.err.println(position);
				return position;
			case air.Aircraft.ON_HOLDING_LOOP:
				return this.getHoldingLoopPosition();
			case air.Aircraft.LANDING:
			case air.Aircraft.ARRIVING: 
				return this.getLandingPosition();
		}
		
		return new Vector(new double[] {500000, 200000});
	}
	
	private Vector getGroundPosition() {
		double xPos = this.aircraft.getCurrentAirPort().getX1();
		double yPos = this.aircraft.getCurrentAirPort().getY1();
		
		return new Vector(new double[] {xPos, yPos});
	}
	
	private Vector getTakeoffPosition() {
		double startX   = this.aircraft.getCurrentAirPort().getX1();
		double startY   = this.aircraft.getCurrentAirPort().getY1();
		double endX     = this.aircraft.getCurrentAirPort().getX2();
		double endY     = this.aircraft.getCurrentAirPort().getY2();
		
		long t0        = this.aircraft.getLastTime() * SimWorld.getInstance().getTimeScale();
		long t         = System.currentTimeMillis() - 
							SimWorld.getInstance().getSimulator().getRtStartTime();
		
		double speed     = this.getSpeed();
		double acc       = this.getAcceleration();
		double t_acc     = speed / acc;
		
		Vector n       = new Vector(new double[] {endX - startX, endY - startY});
		n = n.normalize();
		
		//System.out.println("t: " + t + " diff " + t0 + t_acc);
		if (t < t0 + t_acc) {
			Vector dir = n.multiply(0.5 * Math.pow(t - t0, 2) * acc);
			//System.out.println("Dir: " + dir);
			return new Vector(new double[] {
					startX + dir.getX(),
{'fraction_non_alphanumeric': 0.13423283169001904, 'fraction_numerical': 0.014184397163120567, 'mean_word_length': 3.7354627354627357, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6324853', 'n_tokens_mistral': 2291, 'n_tokens_neox': 1984, 'n_words': 407}