<commit_before>"use strict";

var SchemaView = JakeKit.Canvas.extend({
		
	mouseEvents: {
		"mousedown"		: "mousedown",
		"mouseup"		: "mouseup",
		"mousemove"		: "mousemove",
		"drop"			: "drop",
		"dragover"		: "preventDefault"
	},
		
	events: {
		//"contextmenu canvas"	: "preventDefault", // dont know if I want this event
		//"click canvas"			: "preventDefault", // not even sure if I want this either
		"mouseover canvas"		: "mouseover",
		"mouseout canvas"		: "mouseout"
	},
	
	preventDefault: function(event) {
		event.preventDefault();
		return false;
	},
	
	initialize: function(model, action_recorder) {
		JakeKit.Canvas.prototype.initialize.call(this);
		var that = this;
		
		this.action_recorder = action_recorder;
		
		this.mouse_over = false;
		this.mouse_down = false;
		this.in_drag = false;
		
		// From SchemaView
		this.model = model;
		this.dragged_object = null;
		this.drawer = new SchemaDrawer(this.model);
		this.current_hot_point = null;
		this.new_connection = null;
		this.model.drawer = this.drawer;
		this.selection = [];

	},
	
	id: function() {
		return this.model.id;
	},
	
	ready: function() {
		this.scale(30, 30);
		this.rotate(Math.PI / 2)
	},
	
	mouseover: function(event) {
		this.mouse_over = true;
	},
	
	mouseout: function(event) {
		this.mouse_over = false;
		this.cancelDrag();
		this.in_drag = false;
		this.mouse_down = false;
	},
	
	mousedown: function(event, _point) {
		var point = new Point(_point.elements[0], _point.elements[1]);
		this.mouse_down = true;
		this.mouse_down_point = point;
	},
	
	mouseup: function(event, _point) {
		var point = new Point(_point.elements[0], _point.elements[1]);
		this.mouse_down = false;
		if (this.in_drag) {
			this.endDrag(point);
		} else {
			this.click(point);
		}
		this.in_drag = false;
	},
	
	mousemove: function(event, _point) {
		var point = new Point(_point.elements[0], _point.elements[1]);
		if (this.in_drag) {
			this.continueDrag(point);
		} else {
			if (this.mouse_down) {
				this.beginDrag(this.mouse_down_point);
				this.continueDrag(point);
				this.in_drag = true;
			} else {
				this.mouseOver(point);
			}
		}
	},
	
	drop: function(event, point) {
		var type = event.originalEvent.dataTransfer.getData("Text");
		this.addObject(type, new Point(point.elements[0], point.elements[1]));
	},
	
	draw: function(ctx) {
		this.drawer.setContext(ctx); // Todo, not like this.
		this.drawer.draw();
	},

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	beginDrag: function(point) {
		if (this.current_hot_point) { // We are we creating a connection.
			this.drawer.removeHighlight(this.current_hot_point.position);
			this.invalidate();
			var input_item; var input_num; var output_item; var output_num;
			if (this.current_hot_point.type == "INPUT") {
				if (this.current_hot_point.item.hasInputConnection(this.current_hot_point.number)) {
					return;
				}
				input_item = this.current_hot_point.item;
				input_num = this.current_hot_point.number;
			} else {
				output_item = this.current_hot_point.item;
				output_num = this.current_hot_point.number;
			}
			this.new_connection = new Connection(input_item, input_num, output_item, output_num);
			this.drawer.addTempConnection(this.new_connection);
			this.new_connection.setDragPosition(point); // Not sure we need that.<commit_msg>Fix for Firefox default event problem.<commit_after>"use strict";

var SchemaView = JakeKit.Canvas.extend({
		
	mouseEvents: {
		"mousedown"		: "mousedown",
		"mouseup"		: "mouseup",
		"mousemove"		: "mousemove",
		"drop"			: "drop",
		"dragover"		: "preventDefault"
	},
		
	events: {
		//"contextmenu canvas"	: "preventDefault", // dont know if I want this event
		//"click canvas"			: "preventDefault", // not even sure if I want this either
		"mouseover canvas"		: "mouseover",
		"mouseout canvas"		: "mouseout"
	},
	
	preventDefault: function(event) {
		event.preventDefault();
		return false;
	},
	
	initialize: function(model, action_recorder) {
		JakeKit.Canvas.prototype.initialize.call(this);
		var that = this;
		
		this.action_recorder = action_recorder;
		
		this.mouse_over = false;
		this.mouse_down = false;
		this.in_drag = false;
		
		// From SchemaView
		this.model = model;
		this.dragged_object = null;
		this.drawer = new SchemaDrawer(this.model);
		this.current_hot_point = null;
		this.new_connection = null;
		this.model.drawer = this.drawer;
		this.selection = [];

	},
	
	id: function() {
		return this.model.id;
	},
	
	ready: function() {
		this.scale(30, 30);
		this.rotate(Math.PI / 2)
	},
	
	mouseover: function(event) {
		this.mouse_over = true;
	},
	
	mouseout: function(event) {
		this.mouse_over = false;
		this.cancelDrag();
		this.in_drag = false;
		this.mouse_down = false;
	},
	
	mousedown: function(event, _point) {
		var point = new Point(_point.elements[0], _point.elements[1]);
		this.mouse_down = true;
		this.mouse_down_point = point;
	},
	
	mouseup: function(event, _point) {
		var point = new Point(_point.elements[0], _point.elements[1]);
		this.mouse_down = false;
		if (this.in_drag) {
			this.endDrag(point);
		} else {
			this.click(point);
		}
		this.in_drag = false;
	},
	
	mousemove: function(event, _point) {
		var point = new Point(_point.elements[0], _point.elements[1]);
		if (this.in_drag) {
			this.continueDrag(point);
		} else {
			if (this.mouse_down) {
				this.beginDrag(this.mouse_down_point);
				this.continueDrag(point);
				this.in_drag = true;
			} else {
				this.mouseOver(point);
			}
		}
	},
	
	drop: function(event, point) {
		event.preventDefault();
		var type = event.originalEvent.dataTransfer.getData("Text");
		this.addObject(type, new Point(point.elements[0], point.elements[1]));
	},
	
	draw: function(ctx) {
		this.drawer.setContext(ctx); // Todo, not like this.
		this.drawer.draw();
	},

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	beginDrag: function(point) {
		if (this.current_hot_point) { // We are we creating a connection.
			this.drawer.removeHighlight(this.current_hot_point.position);
			this.invalidate();
			var input_item; var input_num; var output_item; var output_num;
			if (this.current_hot_point.type == "INPUT") {
				if (this.current_hot_point.item.hasInputConnection(this.current_hot_point.number)) {
					return;
				}
				input_item = this.current_hot_point.item;
				input_num = this.current_hot_point.number;
			} else {
				output_item = this.current_hot_point.item;
				output_num = this.current_hot_point.number;
			}
			this.new_connection = new Connection(input_item, input_num, output_item, output_num);
			this.drawer.addTempConnection(this.new_connection);
			this.new_connection.setDragPosition(point); // Not sure we need that.
{'fraction_non_alphanumeric': 0.1677713949035204, 'fraction_numerical': 0.003829724554426278, 'mean_word_length': 3.1836105976586566, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5122815', 'n_tokens_mistral': 2625, 'n_tokens_neox': 2309, 'n_words': 441}