<commit_before>define(['hbs!templates/graph','../util/events', '../graph/graph', '../graph/linkType','../layout/layout','../util/testData', '../layout/forensicColumnLayout'], function(graphTemplate,events,Graph,LINK_TYPE,Layout,testData,ForensicColumnLayout) {

	/**
	 *
	 * @param element - the parent DOM element
	 * @param context - the context for the graph view template
	 * @constructor
	 */
	function GraphView(element,context) {
		this._graph = null;
		this._jqCanvas = null;
		this._browsePathComponents = null;
		this._entitiesComponents = null;
		this._relatedLinksComponents = null;
		this._initialize(element,context);
	}

	/**
	 * Initializes the view.   Creates a canvas context and a initializes a graph in it.
	 * @param element - the parent DOM element
	 * @param context - the context for the graph view template
	 * @private
	 */
	GraphView.prototype._initialize = function(element,context) {
		this._jqCanvas = $(graphTemplate(context));
		this._graph = new Graph()
			.canvas(this._jqCanvas[0])
			.pannable()
			.nodeHover(this._onNodeOver,this._onNodeOut)
			.layouter(new ForensicColumnLayout())
			.draggable()
			.draw();

		this._bindEventHandlers();

		var self = this;
		$(window).resize(function() {
			self._onResize();
		});
		this._jqCanvas.appendTo(element);
		$(window).resize();
	};

	/**
	 * Mouseover event handler.   Adds a label/tooltip
	 * @param node
	 * @private
	 */
	GraphView.prototype._onNodeOver = function(node) {
		if (node.type === 'browse_path') {
			this.addLabel(node,node.url);
		} else {
			this.addLabel(node,node.value);
		}
	};

	/**
	 * Node out handler.   Removes the label displayed
	 * @param node
	 * @private
	 */
	GraphView.prototype._onNodeOut = function(node) {
		this.removeLabel(node);
	};

	/**
	 * Handles resizing
	 * @private
	 */
	GraphView.prototype._onResize = function() {
		var width = $(window).width();
		var height = $(window).height() - this._jqCanvas.offset().top;
		this._graph.resize(width,height);
	};

	/**
	 * Event handler for changing the active trail
	 * @param trailInfo
	 * @private
	 */
	GraphView.prototype._onTrailChange = function(trailInfo) {
		var self = this;
		this._fetchDatawakeGraphFor(trailInfo)
			.then(function(response) {
				return self._getForensicGraph(response);
			})
			.then(function(forensicGraph) {
				self._renderForensicGraph(forensicGraph);
			});
	};

	/**
	 * Adds any event handlers for custom message passing
	 * @private
	 */
	GraphView.prototype._bindEventHandlers = function() {
		events.subscribe(events.topics.TRAIL_CHANGE,this._onTrailChange,this);<commit_msg>Fix bug with resizing that caused the window height not to get updated properly.<commit_after>define(['hbs!templates/graph','../util/events', '../graph/graph', '../graph/linkType','../layout/layout','../util/testData', '../layout/forensicColumnLayout'], function(graphTemplate,events,Graph,LINK_TYPE,Layout,testData,ForensicColumnLayout) {

	/**
	 *
	 * @param element - the parent DOM element
	 * @param context - the context for the graph view template
	 * @constructor
	 */
	function GraphView(element,context) {
		this._graph = null;
		this._jqCanvas = null;
		this._browsePathComponents = null;
		this._entitiesComponents = null;
		this._relatedLinksComponents = null;
		this._initialize(element,context);
	}

	/**
	 * Initializes the view.   Creates a canvas context and a initializes a graph in it.
	 * @param element - the parent DOM element
	 * @param context - the context for the graph view template
	 * @private
	 */
	GraphView.prototype._initialize = function(element,context) {
		this._jqCanvas = $(graphTemplate(context));
		this._graph = new Graph()
			.canvas(this._jqCanvas[0])
			.pannable()
			.nodeHover(this._onNodeOver,this._onNodeOut)
			.layouter(new ForensicColumnLayout())
			.draggable()
			.draw();

		this._bindEventHandlers();

		var self = this;
		$(window).resize(function(e) {
			self._onResize(e);
		});
		this._jqCanvas.appendTo(element);
		$(window).resize();
	};

	/**
	 * Mouseover event handler.   Adds a label/tooltip
	 * @param node
	 * @private
	 */
	GraphView.prototype._onNodeOver = function(node) {
		if (node.type === 'browse_path') {
			this.addLabel(node,node.url);
		} else {
			this.addLabel(node,node.value);
		}
	};

	/**
	 * Node out handler.   Removes the label displayed
	 * @param node
	 * @private
	 */
	GraphView.prototype._onNodeOut = function(node) {
		this.removeLabel(node);
	};

	/**
	 * Handles resizing
	 * @private
	 */
	GraphView.prototype._onResize = function() {
		var width = window.innerWidth;
		var height = window.innerHeight - this._jqCanvas.offset().top;
		this._graph.resize(width,height);
	};

	/**
	 * Event handler for changing the active trail
	 * @param trailInfo
	 * @private
	 */
	GraphView.prototype._onTrailChange = function(trailInfo) {
		var self = this;
		this._fetchDatawakeGraphFor(trailInfo)
			.then(function(response) {
				return self._getForensicGraph(response);
			})
			.then(function(forensicGraph) {
				self._renderForensicGraph(forensicGraph);
			});
	};

	/**
	 * Adds any event handlers for custom message passing
	 * @private
	 */
	GraphView.prototype._bindEventHandlers = function() {
		events.subscribe(events.topics.TRAIL_CHANGE,this._onTrailChange,this);
{'fraction_non_alphanumeric': 0.1420962526155602, 'fraction_numerical': 0.00038044512079132587, 'mean_word_length': 3.8460829493087556, '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': '953734', 'n_tokens_mistral': 1824, 'n_tokens_neox': 1619, 'n_words': 336}