<commit_before>(function()
{
	'use strict';

	angular
		.module('PLMApp')
		.factory('SortingWorldSecondView', SortingWorldSecondView);

			SortingWorldSecondView.$inject = [ 'SetValOperation', 'SwapOperation','CopyOperation', 'CountOperation', 'GetValueOperation'
	];

	function SortingWorldSecondView(SetValOperation, SwapOperation, CopyOperation, CountOperation, GetValueOperation)
	{
		var ctx;
		var canvasWidth;
		var canvasHeight;

		var service = {
			draw: draw,
		};

		return service;

		function initUtils(canvas, sortingWorld)
		{
			ctx = canvas.getContext('2d');
			canvasWidth = canvas.width;
			canvasHeight = canvas.height;
		}


		function draw(canvas, sortingWorld)
		{
			initUtils(canvas, sortingWorld);
			drawChrono(sortingWorld);
		}

		function drawChrono(sortingWorld)
		{ 

			//allows you to know if you have to divided the width
			var amountOperations = sortingWorld.operations.length;

			for(var i=0; i<sortingWorld.operations.length;i++)
			{
				if(sortingWorld.operations[i].length ===  1)
					amountOperations--;


			}
			
			//String of letters
			var letters = 'ABCDEFGHIJKLMNOPQRSTWXYZ';

			//an unit of canvasHeight, divided by the number of values
			var heightUnit = canvasHeight / sortingWorld.values.length;

			//canvasWidth divided by the number of values to know the width of each rectangle
			var widthUnit = (canvasWidth-9)/ Math.max(amountOperations,1);
			
			//if the array is small enough, we display the letters
			var drawLetters = sortingWorld.values.length<=12;
			
			//2 coordinates to display the lines
			var x1,x2,y1,y2;

			//case with 0 operations to display
			if (amountOperations == 0)
			{
				for(var i = 0; i < sortingWorld.values.length;i++)
				{
					//draws letters
					y1 = i * heightUnit + 25;
					ctx.beginPath();
					ctx.strokeStyle = '#000000'
					ctx.strokeRect(0,0,canvasWidth,canvasHeight);
					ctx.closePath();
					ctx.beginPath();
					ctx.fillStyle = sortingWorld.colors[sortingWorld.values[i]];
					if(drawLetters)
					{
						ctx.closePath();
						ctx.font = '30 px sans-serif';
						ctx.fillText(letters.charAt(sortingWorld.values[i]),25,heightUnit*i+20);
						ctx.closePath();
					}
					ctx.closePath();


					//draws line
					ctx.beginPath();
					ctx.moveTo(25,y1);
					ctx.lineTo(canvasWidth-30,y1);
					ctx.strokeStyle = sortingWorld.colors[sortingWorld.values[i]];
					ctx.stroke();
					ctx.closePath();
				}
				return
			}



			//case initial if there are operations
			if(drawLetters)
			{
				for(var i = 0; i < sortingWorld.memory.length;i++)
				{
					for(var j=0;j<sortingWorld.memory[i].length;j++)
					{
						ctx.beginPath();
						ctx.fillStyle = sortingWorld.colors[sortingWorld.memory[i][j]];
						ctx.font = '10px sans-serif';
						ctx.fillText(letters.charAt(sortingWorld.memory[i][j]),widthUnit*i,heightUnit*j+20);
						ctx.closePath();
					}
				}
			}
			
			//indicates which line we are drawing
			var lineInd = 0;
			//draws lines for the unmodified values
			for(var i = 1; i<sortingWorld.memory.length;i++)
			{
				for(var j=0;j<sortingWorld.memory[i].length;j++)
				{
					if(sortingWorld.memory[i-1][j] == sortingWorld.memory[i][j])
					{
						ctx.beginPath();
						y1 = j * heightUnit + 25;
						ctx.strokeStyle = sortingWorld.colors[sortingWorld.memory[i-1][j]];
						ctx.moveTo((widthUnit*lineInd)+10,y1);
						ctx.lineTo(widthUnit*i,y1);
						ctx.stroke();
						ctx.closePath();
					}
				}
				lineInd++;
			}
			
			//indicates which operation we are drawing
			var opInd = 0;

			//indicates which copy we are drawing
			var copyInd = 0;

			var clearX;
			var clearY;

			//draws the lines for the operations
			for(var i=0; i<sortingWorld.operations.length;i++)
			{
				for(var j=0;j<sortingWorld.operations[0].length;j++)
				{
					//draws a clear rectangle erasing some elements which appear before they should 
					
					ctx.beginPath();
					clearX= 9+((sortingWorld.memory.length-1)*widthUnit)
					clearY=2;
					ctx.clearRect(clearX,clearY,canvasWidth,canvasHeight-50);
					ctx.strokeStyle = '#000000' ;
					ctx.strokeRect(0,0, canvasWidth, canvasHeight);
					ctx.moveTo(canvasWidth,0);<commit_msg>remove stepUI for countOperation, remove the space available for letters when we don't draw them in secondview<commit_after>(function()
{
	'use strict';

	angular
		.module('PLMApp')
		.factory('SortingWorldSecondView', SortingWorldSecondView);

			SortingWorldSecondView.$inject = [ 'SetValOperation', 'SwapOperation','CopyOperation', 'CountOperation', 'GetValueOperation'
	];

	function SortingWorldSecondView(SetValOperation, SwapOperation, CopyOperation, CountOperation, GetValueOperation)
	{
		var ctx;
		var canvasWidth;
		var canvasHeight;

		var service = {
			draw: draw,
		};

		return service;

		function initUtils(canvas, sortingWorld)
		{
			ctx = canvas.getContext('2d');
			canvasWidth = canvas.width;
			canvasHeight = canvas.height;
		}


		function draw(canvas, sortingWorld)
		{
			initUtils(canvas, sortingWorld);
			drawChrono(sortingWorld);
		}

		function drawChrono(sortingWorld)
		{ 

			//allows you to know if you have to divided the width
			var amountOperations = sortingWorld.operations.length;

			for(var i=0; i<sortingWorld.operations.length;i++)
			{
				if(sortingWorld.operations[i].length ===  1)
					amountOperations--;


			}
			
			//String of letters
			var letters = 'ABCDEF<KEY>';

			//an unit of canvasHeight, divided by the number of values
			var heightUnit = canvasHeight / sortingWorld.values.length;

			//canvasWidth divided by the number of values to know the width of each rectangle
			var widthUnit = (canvasWidth-9)/ Math.max(amountOperations,1);
			
			//if the array is small enough, we display the letters
			var drawLetters = sortingWorld.values.length<=12;
			
			//2 coordinates to display the lines
			var x1,x2,y1,y2;

			//case with 0 operations to display
			if (amountOperations == 0)
			{
				for(var i = 0; i < sortingWorld.values.length;i++)
				{
					//draws letters
					ctx.beginPath();
					ctx.strokeStyle = '#000000'
					ctx.strokeRect(0,0,canvasWidth,canvasHeight);
					ctx.closePath();
					ctx.beginPath();
					ctx.fillStyle = sortingWorld.colors[sortingWorld.values[i]];
					if(drawLetters)
					{
						ctx.closePath();
						y1 = i * heightUnit + 25;
						ctx.font = '30 px sans-serif';
						ctx.fillText(letters.charAt(sortingWorld.values[i]),25,heightUnit*i+20);
						ctx.closePath();
					}
					else
						y1 = i * heightUnit + 5;
					
					ctx.closePath();


					//draws line
					ctx.beginPath();
					ctx.moveTo(25,y1);
					ctx.lineTo(canvasWidth-30,y1);
					ctx.strokeStyle = sortingWorld.colors[sortingWorld.values[i]];
					ctx.stroke();
					ctx.closePath();
				}
				return
			}



			//case initial if there are operations
			if(drawLetters)
			{
				for(var i = 0; i < sortingWorld.memory.length;i++)
				{
					for(var j=0;j<sortingWorld.memory[i].length;j++)
					{
						ctx.beginPath();
						ctx.fillStyle = sortingWorld.colors[sortingWorld.memory[i][j]];
						ctx.font = '10px sans-serif';
						ctx.fillText(letters.charAt(sortingWorld.memory[i][j]),widthUnit*i,heightUnit*j+20);
						ctx.closePath();
					}
				}
			}
			
			//indicates which line we are drawing
			var lineInd = 0;
			//draws lines for the unmodified values
			for(var i = 1; i<sortingWorld.memory.length;i++)
			{
				for(var j=0;j<sortingWorld.memory[i].length;j++)
				{
					if(sortingWorld.memory[i-1][j] == sortingWorld.memory[i][j])
					{
						ctx.beginPath();

						if(drawLetters)
							y1 = j * heightUnit + 25;
						else
							y1 = j * heightUnit + 5;
						
						ctx.strokeStyle = sortingWorld.colors[sortingWorld.memory[i-1][j]];
						ctx.moveTo((widthUnit*lineInd)+10,y1);
						ctx.lineTo(widthUnit*i,y1);
						ctx.stroke();
						ctx.closePath();
					}
				}
				lineInd++;
			}
			
			//indicates which operation we are drawing
			var opInd = 0;

			//indicates which copy we are drawing
			var copyInd = 0;

			var clearX;
			var clearY;

			//draws the lines for the operations
			for(var i=0; i<sortingWorld.operations.length;i++)
			{
				for(var j=0;j<sortingWorld.operations[0].length;j++)
				{
					//draws a clear rectangle erasing some elements which appear before they should 
					ctx.beginPath();
					clearX=9+((sortingWorld.memory.length-1)*widthUnit);
					clearY=2;
					ctx.clearRect(clearX,clearY,canvasWidth,canvasHeight-50);
					ctx.strokeStyle = '#000000' ;
					ctx.strokeRect(0,0, canvasWidth, canvasHeight);
					ctx.moveTo(canvasWidth,0);
{'fraction_non_alphanumeric': 0.12812427003036675, 'fraction_numerical': 0.017986451763606633, 'mean_word_length': 3.0296470588235294, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 4, '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': '5451478', 'n_tokens_mistral': 3744, 'n_tokens_neox': 2800, 'n_words': 597}