Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- getOriginBox : function (originId, arbreData) {
- var finalBoxInfos = {};
- /**
- * On récupère les opérateurs en terminus de chemins
- */
- $.each(arbreData["operators"], function (operatorId) {
- var currentBox = operatorId;
- /** 0 : left ; 1 : right ; 2 : middle**/
- var currentBoxRoads = [0, 0, 0];
- /**
- * On remonte un opérateur terminus jusqu'à l'origin
- */
- while (!isNullOrEmpty(currentBox) && currentBox !== originId) {
- var upBoxId = arbreCore.getFromOperatorLink(currentBox, "input_1", arbreData["links"]);
- var upBoxConnector = arbreCore.getFromConnectorLink(upBoxId, currentBox, arbreData["links"]);
- currentBox = upBoxId;
- if (!arbreCore.isBoxMultipleOutputs(upBoxId, arbreData))
- currentBoxRoads[2] += 1;
- else if (upBoxConnector === arbreCore._leftOut)
- currentBoxRoads[0] += 1;
- else
- currentBoxRoads[1] += 1;
- }
- finalBoxInfos[operatorId] = currentBoxRoads;
- });
- /** 0 : operatorId ; 1 : left roads ; 2 : right roads ; 3 : final max height ; 4 : middle road**/
- var highestInfos = ["", 0, 0, 0, 0];
- var highestHeight = 0;
- /**
- * On récupère l'operator Id
- * le plus en bas à gauche
- */
- $.each(finalBoxInfos, function (operatorId) {
- var boxInfos = finalBoxInfos[operatorId];
- if (boxInfos[0] - boxInfos[1] > highestInfos[1] - highestInfos[2])
- highestInfos = [operatorId, boxInfos[0], boxInfos[1], 0, boxInfos[2]];
- else if (boxInfos[0] - boxInfos[1] === highestInfos[1] - highestInfos[2] && boxInfos[0] === highestInfos[1])
- highestInfos = boxInfos[2] > highestInfos[4] ? [operatorId, boxInfos[0], boxInfos[1], 0, boxInfos[2]] : highestInfos;
- else if (boxInfos[0] - boxInfos[1] === highestInfos[1] - highestInfos[2])
- highestInfos = boxInfos[0] > highestInfos[1] ? [operatorId, boxInfos[0], boxInfos[1], 0, boxInfos[2]] : highestInfos;
- var currentHeight = (boxInfos[0] + boxInfos[1] + boxInfos[2]) * (arbreCore._hEcart + arbreCore._boxHeight) + (arbreCore._plusHeight * 2) + arbreCore._boxHeight;
- highestHeight = currentHeight > highestHeight ? currentHeight : highestHeight;
- });
- /** Calcul du max height **/
- highestHeight = !highestHeight ? (arbreCore._boxHeight + (2 * arbreCore._plusHeight)) : highestHeight;
- highestInfos[3] = highestHeight;
- /**
- * Si il n'y pas de chemin sur l'arbre
- */
- if (isNullOrEmpty(highestInfos[0]))
- highestInfos = [originId, 0, 0, highestHeight, 0];
- return (highestInfos);
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement