From c9201526a9ca5c325b1a0d8284d8e0cf4b77d3c1 Mon Sep 17 00:00:00 2001 From: Oleg Sh Date: Sat, 3 Aug 2024 21:03:42 +0200 Subject: [PATCH] Fixed shrt path algorithm name for graphs with negative edges. Fix loader. --- core/config/main.php | 6 +- lang/bg/home.php | 1 + lang/ch/home.php | 1 + lang/cs/home.php | 1 + lang/de/home.php | 1 + lang/el/home.php | 1 + lang/en/home.php | 2 + lang/es/home.php | 1 + lang/fr/home.php | 1 + lang/nl/home.php | 1 + lang/pl/home.php | 1 + lang/pt/home.php | 1 + lang/ru/home.php | 2 + lang/sv/home.php | 1 + script/features/algorithms/api/index.js | 2 +- .../algorithms/model/plugins/ShortestPath.js | 2 +- .../api/index.js.cache | 1429 +-------------- .../api/index.js.cache | 1429 +-------------- .../create_graph_by_matrix/api/index.js.cache | 1575 +---------------- script/pages/editor/api/index.js.cache | 10 +- script/pages/editor/model/texts.js | 2 + script/pages/editor/ui/editor.js | 6 +- script/shared/loader.js | 2 +- tpl/admin/pack.php | 4 +- tpl/home.php | 4 +- 25 files changed, 117 insertions(+), 4369 deletions(-) diff --git a/core/config/main.php b/core/config/main.php index 7545a11..cca74b5 100755 --- a/core/config/main.php +++ b/core/config/main.php @@ -60,9 +60,9 @@ $g_config['extrapacker'] = array(); $g_config['extrapacker']['dir'] = 'auto_merge_css_js'; - $g_config['extrapacker']['packHtml'] = true; + $g_config['extrapacker']['packHtml'] = false; $g_config['extrapacker']['packCss'] = true; - $g_config['extrapacker']['packJs'] = true; + $g_config['extrapacker']['packJs'] = false; $g_config['extrapacker']['arrExeptions_js'] = array(); $g_config['extrapacker']['arrExeptionsNotAdd_js'] = array(); $g_config['extrapacker']['arrExeptions_css'] = array(); @@ -93,5 +93,5 @@ $g_config['vote'] = "./tmp/vote/vote.txt"; $g_config['voteTopics'] = "./tmp/vote/voteTopics.txt_"; $g_config['use_js_cache'] = true; - $g_config['engine_version'] = 82; + $g_config['engine_version'] = 83; ?> diff --git a/lang/bg/home.php b/lang/bg/home.php index 3ce536b..e7e5cf8 100644 --- a/lang/bg/home.php +++ b/lang/bg/home.php @@ -198,6 +198,7 @@ We have added Dutch translation 🇳🇱. Thank you Willie de Wit"; $g_lang["modern_graph_style_name"] = "Визуализация на база тегло"; $g_lang["radius_and_diameter_name"] = "Намерете радиус и диаметър на граф"; $g_lang["find_short_path_name"] = "Намерете най-краткия път с помощта на алгоритъма на Дейкстра"; + $g_lang["find_short_path_belman_ford_name"] = "Find shortest path using Bellman–Ford's algorithm"; $g_lang["vertices_degree_name"] = "Изчислете степента на връх"; $g_lang["min_spanning_tree_res_is"] = "Теглото на минималното обхващащо дърво е "; diff --git a/lang/ch/home.php b/lang/ch/home.php index 3923b13..ba33010 100644 --- a/lang/ch/home.php +++ b/lang/ch/home.php @@ -200,6 +200,7 @@ $g_lang["modern_graph_style_name"] = "根据权重的可视化"; $g_lang["radius_and_diameter_name"] = "找图的半径和直径"; $g_lang["find_short_path_name"] = "用Dijkstra算法找最短路"; + $g_lang["find_short_path_belman_ford_name"] = "Find shortest path using Bellman–Ford's algorithm"; $g_lang["vertices_degree_name"] = "计算顶点的度"; $g_lang["min_spanning_tree_res_is"] = "最小生成树的权重是 "; diff --git a/lang/cs/home.php b/lang/cs/home.php index 9540a09..e34cae0 100644 --- a/lang/cs/home.php +++ b/lang/cs/home.php @@ -199,6 +199,7 @@ $g_lang["modern_graph_style_name"] = "Vizualizace založená na váze"; $g_lang["radius_and_diameter_name"] = "Hledání poloměru a průměru grafu"; $g_lang["find_short_path_name"] = "Najít nejkratší cestu pomocí Dijkstrova algoritmu"; + $g_lang["find_short_path_belman_ford_name"] = "Find shortest path using Bellman–Ford's algorithm"; $g_lang["vertices_degree_name"] = "Výpočet stupňů vrcholů"; $g_lang["min_spanning_tree_res_is"] = "Váha minimální kostry stromu je "; diff --git a/lang/de/home.php b/lang/de/home.php index 317fc15..2c51b2b 100644 --- a/lang/de/home.php +++ b/lang/de/home.php @@ -163,6 +163,7 @@ $g_lang["modern_graph_style_name"] = "Gewicht-basierte Visualisierung"; $g_lang["radius_and_diameter_name"] = "Graphradius und Graphdiameter suchen"; $g_lang["find_short_path_name"] = "Kürzesten Weg via Dijkstra Algorithm finden"; + $g_lang["find_short_path_belman_ford_name"] = "Find shortest path using Bellman–Ford's algorithm"; $g_lang["vertices_degree_name"] = "Knotengewicht berechnen"; $g_lang["min_spanning_tree_res_is"] = "Weight of minimum spanning tree is "; $g_lang["min_spanning_tree_ignore_direction"] = "In time of calculation we have ignored the edges direction."; diff --git a/lang/el/home.php b/lang/el/home.php index af86972..5bd7c73 100644 --- a/lang/el/home.php +++ b/lang/el/home.php @@ -201,6 +201,7 @@ $g_lang["modern_graph_style_name"] = "Απεικόνιση με βάση το βάρος"; $g_lang["radius_and_diameter_name"] = "Αναζήτηση ακτίνας και διαμέτρου του γράφου"; $g_lang["find_short_path_name"] = "Εύρεση συντομότερου μονοπατιού με χρήση του αλγορίθμου Dijkstra"; + $g_lang["find_short_path_belman_ford_name"] = "Find shortest path using Bellman–Ford's algorithm"; $g_lang["vertices_degree_name"] = "Υπολογισμός βαθμών κορυφών"; $g_lang["min_spanning_tree_res_is"] = "Το βάρος του ελάχιστου ζευγνύοντος δέντρου είναι "; diff --git a/lang/en/home.php b/lang/en/home.php index f5058ce..f6586c2 100755 --- a/lang/en/home.php +++ b/lang/en/home.php @@ -200,6 +200,8 @@ We have added Dutch translation 🇳🇱. Thank you Willie de Wit"; $g_lang["modern_graph_style_name"] = "Visualisation based on weight"; $g_lang["radius_and_diameter_name"] = "Search graph radius and diameter"; $g_lang["find_short_path_name"] = "Find shortest path using Dijkstra's algorithm"; + $g_lang["find_short_path_belman_ford_name"] = "Find shortest path using Bellman–Ford's algorithm"; + $g_lang["vertices_degree_name"] = "Calculate vertices degree"; $g_lang["min_spanning_tree_res_is"] = "Weight of minimum spanning tree is "; diff --git a/lang/es/home.php b/lang/es/home.php index 6f9ba01..5b890f5 100755 --- a/lang/es/home.php +++ b/lang/es/home.php @@ -200,6 +200,7 @@ Tenemos traducciones en griego 🇬🇷. "; $g_lang["modern_graph_style_name"] = "Wizualizajca bazująca na wadze"; $g_lang["radius_and_diameter_name"] = "Znajdź średnicę i cięciwe grafu"; $g_lang["find_short_path_name"] = "Znajdź najkrótszą ścieżkę używając algiorytmu Dijkstra"; + $g_lang["find_short_path_belman_ford_name"] = "Find shortest path using Bellman–Ford's algorithm"; $g_lang["vertices_degree_name"] = "Policz stopień wierzchołków"; $g_lang["min_spanning_tree_res_is"] = "Waga minimalnego drzewa rozpinającego to "; diff --git a/lang/pt/home.php b/lang/pt/home.php index bb5e5e1..4bea43d 100644 --- a/lang/pt/home.php +++ b/lang/pt/home.php @@ -166,6 +166,7 @@ $g_lang["modern_graph_style_name"] = "Visualização baseada nos pesos"; $g_lang["radius_and_diameter_name"] = "Buscar raio e diâmetro do grafo"; $g_lang["find_short_path_name"] = "Encontrar o caminho mais curto usando o algoritmo de Dijkstra"; + $g_lang["find_short_path_belman_ford_name"] = "Find shortest path using Bellman–Ford's algorithm"; $g_lang["vertices_degree_name"] = "Calcular o grau dos vértices"; $g_lang["min_spanning_tree_res_is"] = "Peso da árvore geradora mínima é"; $g_lang["min_spanning_tree_ignore_direction"] = "Durante os cálculos ignoramos as direções dos vértices."; diff --git a/lang/ru/home.php b/lang/ru/home.php index e1adfea..95752e7 100755 --- a/lang/ru/home.php +++ b/lang/ru/home.php @@ -201,6 +201,8 @@ $g_lang["modern_graph_style_name"] = "Визуализация на основе весов"; $g_lang["radius_and_diameter_name"] = "Поиск радиуса и диаметра графа"; $g_lang["find_short_path_name"] = "Поиск кратчайший путь алгоритмом Дейкстры"; + $g_lang["find_short_path_belman_ford_name"] = "Поиск кратчайший путь алгоритмом Беллмана-Форда"; + $g_lang["vertices_degree_name"] = "Рассчитать степень вершин"; $g_lang["min_spanning_tree_res_is"] = "Вес минимального остовного дерева равен "; diff --git a/lang/sv/home.php b/lang/sv/home.php index c63dafd..8200791 100644 --- a/lang/sv/home.php +++ b/lang/sv/home.php @@ -161,6 +161,7 @@ $g_lang["modern_graph_style_name"] = "Мiktbaserad visualisering"; $g_lang["radius_and_diameter_name"] = "Hitta radien och diametern på en graf"; $g_lang["find_short_path_name"] = "Hitta den kortaste vägen med Dijkstras algoritm"; + $g_lang["find_short_path_belman_ford_name"] = "Find shortest path using Bellman–Ford's algorithm"; $g_lang["vertices_degree_name"] = "Кäkna graden av vertikaler"; $g_lang["min_spanning_tree_res_is"] = "Weight of minimum spanning tree is "; diff --git a/script/features/algorithms/api/index.js b/script/features/algorithms/api/index.js index 3647904..cf94ef9 100644 --- a/script/features/algorithms/api/index.js +++ b/script/features/algorithms/api/index.js @@ -30,7 +30,7 @@ function loadAsyncAlgorithms(onFinish) { "ShortestPath.js", "VerticesDegree.js"]; - doIncludeAsync (pluginsList.map((plugin) => include ("model/plugins/" + plugin + "?v=" + globalVersion, modulDir)), onFinish); + doIncludeAsync (pluginsList.map((plugin) => include ("model/plugins/" + plugin, modulDir)), onFinish); } } \ No newline at end of file diff --git a/script/features/algorithms/model/plugins/ShortestPath.js b/script/features/algorithms/model/plugins/ShortestPath.js index 00dd8ce..4644a19 100644 --- a/script/features/algorithms/model/plugins/ShortestPath.js +++ b/script/features/algorithms/model/plugins/ShortestPath.js @@ -23,7 +23,7 @@ FindShortPathNew.prototype.infinityValue = 1E9 - 1; FindShortPathNew.prototype.getName = function(local) { - return g_findShortPathName; //local == "ru" ? "Поиск кратчайший путь алгоритмом Дейкстры" : "Find shortest path using Dijkstra's algorithm"; + return this.graph.hasNegative() ? g_findShortPathBellmanFordName : g_findShortPathName; //local == "ru" ? "Поиск кратчайший путь алгоритмом Дейкстры" : "Find shortest path using Dijkstra's algorithm"; } FindShortPathNew.prototype.getId = function() diff --git a/script/pages/create_graph_by_edge_list/api/index.js.cache b/script/pages/create_graph_by_edge_list/api/index.js.cache index 044979a..15764da 100644 --- a/script/pages/create_graph_by_edge_list/api/index.js.cache +++ b/script/pages/create_graph_by_edge_list/api/index.js.cache @@ -1,16 +1,4 @@ -moduleLoader.beginCacheLoading(["/script/shared/utils.js?v=78","/script/entities/graph/api/index.js?v=78","/script/shared/point.js?v=78","/script/entities/edge/api/index.js?v=78","/script/entities/edge/model/BaseEdge.js?v=78","/script/entities/edge/model/EdgeModel.js?v=78","/script/entities/vertex/api/index.js?v=78","/script/entities/vertex/model/BaseVertex.js?v=78","/script/entities/vertex/model/VertexModel.js?v=78","/script/entities/graph/model/Graph.js?v=78","/script/features/draw_graph/api/index.js?v=78","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=78","/script/features/draw_graph/model/EdgeStyle.js?v=78","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=78","/script/features/draw_graph/model/VertexShape.js?v=78","/script/features/draw_graph/model/VertexStyle.js?v=78","/script/features/draw_graph/model/BaseVertexDrawer.js?v=78","/script/features/algorithms/api/index.js?v=78","/script/features/algorithms/model/Algorithms.js?v=78","/script/features/algorithms/model/BaseTraversal.js?v=78","/script/features/base_handler/index.js?v=78","/script/features/default_handler/index.js?v=78","/script/features/add_vertices_handler/index.js?v=78","/script/features/connect_vertices_handler/index.js?v=78","/script/features/delete_objects_handler/index.js?v=78","/script/features/algorithm_handler/index.js?v=78","/script/features/serialization/api/index.js?v=78","/script/features/serialization/model/GraphMLCreator.js?v=78","/script/features/enum_vertices/EnumVertices.js?v=78","/script/pages/editor/model/texts.js?v=78","/script/pages/editor/model/UndoStack.js?v=78","/script/pages/editor/model/DiskSaveLoad.js?v=78","/script/pages/editor/model/Application.js?v=78","/script/pages/editor/ui/ya_metrika.js?v=78","/script/pages/editor/ui/editor.js?v=78","/script/pages/editor/ui/main.js?v=78",]);{let modulDir="pages/create_graph_by_edge_list/";doInclude([include("entities/graph/api/index.js")]);} -function gEncodeToHTML(str) -{if(typeof str!=='string') -return str;return str.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');} -function gDecodeFromHTML(str) -{if(typeof str!=='string') -return str;return str.replace(/'/g,"'").replace(/"/g,'"').replace(/>/g,'>').replace(/</g,'<').replace(/&/g,'&');} -function FullObjectCopy(obj) -{var newObj=Object.create(Object.getPrototypeOf(obj));return Object.assign(newObj,obj);} -function FullArrayCopy(arr) -{var res=[];arr.forEach(function(element){var copyElement=FullObjectCopy(element);res.push(copyElement);});return res;} -function formatString(string,params){return string.replace(/{(\d+)}/g,(match,index)=>{return typeof params[index]!=='undefined'?params[index]:match;});} -Array.prototype.swap=function(x,y){var b=this[x];this[x]=this[y];this[y]=b;return this;} +moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=79","/script/shared/point.js?v=79","/script/entities/edge/api/index.js?v=79","/script/entities/edge/model/BaseEdge.js?v=79","/script/entities/edge/model/EdgeModel.js?v=79","/script/entities/vertex/api/index.js?v=79","/script/entities/vertex/model/BaseVertex.js?v=79","/script/entities/vertex/model/VertexModel.js?v=79","/script/entities/graph/model/Graph.js?v=79",]);{let modulDir="pages/create_graph_by_edge_list/";doInclude([include("entities/graph/api/index.js")]);} {let modulDir="entities/graph/";doInclude([include("shared/point.js"),include("entities/edge/api/index.js"),include("entities/vertex/api/index.js"),include("model/Graph.js",modulDir)])}function Point(x,y){this.x=x||0;this.y=y||0;};Point.prototype.x=null;Point.prototype.y=null;Point.prototype.add=function(v){return new Point(this.x+v.x,this.y+v.y);};Point.prototype.addValue=function(v){return new Point(this.x+v,this.y+v);};Point.prototype.clone=function(){return new Point(this.x,this.y);};Point.prototype.degreesTo=function(v){var dx=this.x-v.x;var dy=this.y-v.y;var angle=Math.atan2(dy,dx);return angle*(180/Math.PI);};Point.prototype.distance=function(v){return Math.sqrt(this.distanceSqr(v));};Point.prototype.distanceSqr=function(v){var x=this.x-v.x;var y=this.y-v.y;return x*x+y*y;};Point.prototype.equals=function(toCompare){return this.x==toCompare.x&&this.y==toCompare.y;};Point.prototype.interpolate=function(v,f){return new Point((this.x+v.x)*f,(this.y+v.y)*f);};Point.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y);};Point.prototype.normalize=function(thickness){var l=this.length();this.x=this.x/l*thickness;this.y=this.y/l*thickness;return new Point(this.x,this.y);};Point.prototype.normalizeCopy=function(thickness){var l=this.length();return new Point(this.x/l*thickness,this.y/l*thickness);};Point.prototype.orbit=function(origin,arcWidth,arcHeight,degrees){var radians=degrees*(Math.PI/180);this.x=origin.x+arcWidth*Math.cos(radians);this.y=origin.y+arcHeight*Math.sin(radians);};Point.prototype.rotate=function(center,degrees){var radians=degrees*(Math.PI/180);offset=this.subtract(center);this.x=offset.x*Math.cos(radians)-offset.y*Math.sin(radians);this.y=offset.x*Math.sin(radians)+offset.y*Math.cos(radians);this.x=this.x+center.x;this.y=this.y+center.y;return this;};Point.prototype.offset=function(dx,dy){this.x+=dx;this.y+=dy;};Point.prototype.subtract=function(v){return new Point(this.x-v.x,this.y-v.y);};Point.prototype.subtractValue=function(value){return new Point(this.x-value,this.y-value);};Point.prototype.multiply=function(value){return new Point(this.x*value,this.y*value);};Point.prototype.toString=function(){return"(x="+this.x+", y="+this.y+")";};Point.prototype.normal=function(){return new Point(-this.y,this.x);};Point.prototype.min=function(point) {return new Point(Math.min(this.x,point.x),Math.min(this.y,point.y));};Point.prototype.max=function(point) {return new Point(Math.max(this.x,point.x),Math.max(this.y,point.y));};Point.prototype.inverse=function() @@ -611,1417 +599,4 @@ Graph.prototype.makeAllEdgesUndirected=function() {if(this.edges[i].isDirect) {this.edges[i].isDirect=false;}} this.isMultiGraph=this.checkMutiGraph();} -{let modulDir="features/draw_graph/";doInclude([include("model/BaseBackgroundDrawer.js",modulDir),include("model/EdgeStyle.js",modulDir),include("model/BaseEdgeDrawer.js",modulDir),include("model/VertexShape.js",modulDir),include("model/VertexStyle.js",modulDir),include("model/BaseVertexDrawer.js",modulDir)])} -function CommonBackgroundStyle() -{this.commonColor='#ffffff';this.commonOpacity=1.0;this.image=null;} -CommonBackgroundStyle.prototype.Clear=function() -{delete this.commonColor;delete this.commonOpacity;delete this.image;} -CommonBackgroundStyle.prototype.ShouldLoad=function(field) -{return true;} -CommonBackgroundStyle.prototype.saveToJson=function(field) -{return JSON.stringify({commonColor:this.commonColor,commonOpacity:this.commonOpacity,image:this.image!=null?this.image.src:null});} -CommonBackgroundStyle.prototype.loadFromJson=function(json,callbackOnLoaded) -{this.commonColor=json["commonColor"];this.commonOpacity=json["commonOpacity"];this.image=null;if(typeof json["image"]==='string'){this.image=new Image();this.image.onload=function(){callbackOnLoaded();} -this.image.src=json["image"];}} -PrintBackgroundStyle.prototype=Object.create(CommonBackgroundStyle.prototype);function PrintBackgroundStyle() -{CommonBackgroundStyle.apply(this,arguments);this.commonColor='#ffffff';this.commonOpacity=1.0;this.image=null;} -function BaseBackgroundDrawer(context) -{this.context=context;} -BaseBackgroundDrawer.prototype.Draw=function(style,width,height,position,scale) -{var context=this.context;var rect=new Rect(position,position.add(new Point(width/scale,height/scale)));context.clearRect(-rect.minPoint.x,-rect.minPoint.y,rect.size().x+1,rect.size().y+1);var oldOpacity=context.globalAlpha;if(style.commonOpacity>0.0) -{context.globalAlpha=style.commonOpacity;context.fillStyle=style.commonColor;context.fillRect(-rect.minPoint.x,-rect.minPoint.y,rect.size().x+1,rect.size().y+1);this.DrawImage(style,width,height,position,scale);} -context.globalAlpha=oldOpacity;} -BaseBackgroundDrawer.prototype.DrawImage=function(style,width,height,position,scale) -{if(style.image==null){return;} -var context=this.context;context.clearRect(0,0,style.image.width,style.image.height);context.drawImage(style.image,0,0)} -const lineDashTypes=[[],[4,4],[12,12],[16,4,4,4],];const WeightTextCenter=0,WeightTextUp=1;const DefaultFontEdge="px sans-serif",DefaultMainTextFontSizeEdge=16,TopTextFontSizeDeltaEdge=-4;function BaseEdgeStyle() -{this.baseStyles=[];} -BaseEdgeStyle.prototype.GetStyle=function(baseStyle,object) -{this.baseStyles.forEach(function(element){var styleObject=globalApplication.GetStyle("edge",element,object);baseStyle=styleObject.GetStyle(baseStyle,object);});if(this.hasOwnProperty('weightText')) -baseStyle.weightText=this.weightText;if(this.hasOwnProperty('strokeStyle')) -baseStyle.strokeStyle=this.strokeStyle;if(this.hasOwnProperty('fillStyle')) -baseStyle.fillStyle=this.fillStyle;if(this.hasOwnProperty('textPadding')) -baseStyle.textPadding=this.textPadding;if(this.hasOwnProperty('textStrokeWidth')) -baseStyle.textStrokeWidth=this.textStrokeWidth;if(this.hasOwnProperty('lineDash')) -baseStyle.lineDash=this.lineDash;if(this.hasOwnProperty('additionalTextColor')) -baseStyle.additionalTextColor=this.additionalTextColor;if(this.hasOwnProperty('weightPosition')) -baseStyle.weightPosition=this.weightPosition;if(this.hasOwnProperty('mainTextFontSize')) -baseStyle.mainTextFontSize=this.mainTextFontSize;return this.FixNewFields(baseStyle);} -BaseEdgeStyle.prototype.FixNewFields=function(style) -{if(!style.hasOwnProperty('lineDash')) -style.lineDash=0;if(!style.hasOwnProperty('weightPosition')) -style.weightPosition=WeightTextCenter;if(!style.hasOwnProperty('mainTextFontSize')) -style.mainTextFontSize=DefaultMainTextFontSizeEdge;return style;} -BaseEdgeStyle.prototype.Clear=function() -{delete this.weightText;delete this.strokeStyle;delete this.fillStyle;delete this.textPadding;delete this.textStrokeWidth;delete this.lineDash;delete this.additionalTextColor;delete this.weightPosition;delete this.mainTextFontSize;} -BaseEdgeStyle.prototype.ShouldLoad=function(field) -{return field!="baseStyles";} -function CommonEdgeStyle() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#c7b7c7';this.weightText='#f0d543';this.fillStyle='#68aeba';this.textPadding=4;this.textStrokeWidth=2;this.lineDash=0;this.additionalTextColor='#c7b7c7';this.weightPosition=WeightTextCenter;} -CommonEdgeStyle.prototype=Object.create(BaseEdgeStyle.prototype);function CommonPrintEdgeStyle() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#000000';this.weightText='#000000';this.fillStyle='#FFFFFF';this.textPadding=4;this.textStrokeWidth=2;this.baseStyles.push("common");} -CommonPrintEdgeStyle.prototype=Object.create(BaseEdgeStyle.prototype);function SelectedEdgeStyle0() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#f0d543';this.weightText='#f0d543';this.fillStyle='#c7627a';this.baseStyles.push("common");} -SelectedEdgeStyle0.prototype=Object.create(BaseEdgeStyle.prototype);function SelectedEdgeStyle1() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#8FBF83';this.weightText='#8FBF83';this.fillStyle='#F9F9D5';this.baseStyles.push("selected");} -SelectedEdgeStyle1.prototype=Object.create(BaseEdgeStyle.prototype);function SelectedEdgeStyle2() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#8C4C86';this.weightText='#8C4C86';this.fillStyle='#253267';this.baseStyles.push("selected");} -SelectedEdgeStyle2.prototype=Object.create(BaseEdgeStyle.prototype);function SelectedEdgeStyle3() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#6188FF';this.weightText='#6188FF';this.fillStyle='#E97CF9';this.baseStyles.push("selected");} -SelectedEdgeStyle3.prototype=Object.create(BaseEdgeStyle.prototype);function SelectedEdgeStyle4() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#C6B484';this.weightText='#C6B484';this.fillStyle='#E0DEE1';this.baseStyles.push("selected");} -SelectedEdgeStyle4.prototype=Object.create(BaseEdgeStyle.prototype);function SelectedEdgePrintStyle() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#AAAAAA';this.weightText='#000000';this.fillStyle='#AAAAAA';this.baseStyles.push("printed");} -SelectedEdgePrintStyle.prototype=Object.create(BaseEdgeStyle.prototype);var DefaultSelectedEdgeStyles=[new SelectedEdgeStyle0(),new SelectedEdgeStyle1(),new SelectedEdgeStyle2(),new SelectedEdgeStyle3(),new SelectedEdgeStyle4()];var DefaultPrintSelectedEdgeStyles=[new SelectedEdgePrintStyle()];function BaseEdgeDrawer(context,drawObjects) -{if(drawObjects===undefined) -{drawObjects=null;} -this.context=context;this.drawObject=null;this.drawArc=null;this.startArrowDirection=null;this.finishArrowDirection=null;this.textCenterObject=null;this.getPointOnArc=null;if(drawObjects) -{if(drawObjects.hasOwnProperty("drawObject")) -this.drawObject=drawObjects.drawObject;if(drawObjects.hasOwnProperty("drawArc")) -this.drawArc=drawObjects.drawArc;if(drawObjects.hasOwnProperty("startArrowDirection")) -this.startArrowDirection=drawObjects.startArrowDirection;if(drawObjects.hasOwnProperty("finishArrowDirection")) -this.finishArrowDirection=drawObjects.finishArrowDirection;if(drawObjects.hasOwnProperty("textCenterObject")) -this.textCenterObject=drawObjects.textCenterObject;if(drawObjects.hasOwnProperty("getPointOnArc")) -this.getPointOnArc=drawObjects.getPointOnArc;}} -BaseEdgeDrawer.prototype.Draw=function(baseEdge,arcStyle) -{if(this.drawObject&&this.drawObject!=this) -{this.drawObject.Draw(baseEdge,arcStyle);return;} -this.SetupStyle(baseEdge,arcStyle);var lengthArrow=Math.max(baseEdge.model.width*4,8);var widthArrow=Math.max(baseEdge.model.width*2,4);var position1=baseEdge.vertex1.position;var position2=baseEdge.vertex2.position;var direction=position1.subtract(position2);direction.normalize(1.0);var positions=baseEdge.GetEdgePositionsShift();var hasStartStyle=!position1.equals(position2)&&baseEdge.GetStartEdgeStyle()!="";var hasFinishStyle=!position1.equals(position2)&&baseEdge.GetFinishEdgeStyle()!="";var arcPos1=positions[0];var arcPos2=positions[1];if(hasStartStyle) -{var dirArrow=this.GetStartArrowDirection(positions[0],positions[1],lengthArrow);arcPos1=arcPos1.add(dirArrow.multiply(lengthArrow/2));} -if(hasFinishStyle) -{var dirArrow=this.GetFinishArrowDirection(positions[0],positions[1],lengthArrow);arcPos2=arcPos2.add(dirArrow.multiply(-lengthArrow/2));} -this.DrawArc(arcPos1,arcPos2,arcStyle);this.context.fillStyle=this.context.strokeStyle;this.context.lineWidth=0;if(hasStartStyle) -{this.DrawArrow(positions[0],this.GetStartArrowDirection(positions[0],positions[1],lengthArrow),lengthArrow,widthArrow);} -if(hasFinishStyle) -{this.DrawArrow(positions[1],this.GetFinishArrowDirection(positions[0],positions[1],lengthArrow),lengthArrow,widthArrow);} -this.SetupStyle(baseEdge,arcStyle);if(arcStyle.weightPosition==WeightTextCenter) -{if(baseEdge.GetText().length>0) -{this.DrawWeight(positions[0],positions[1],baseEdge.GetText(),arcStyle,false);} -if(baseEdge.GetUpText().length>0) -{this.DrawUpText(positions[0],positions[1],baseEdge.GetUpText(),arcStyle,false,arcStyle.additionalTextColor,baseEdge.model.width/2+arcStyle.mainTextFontSize+4,arcStyle.mainTextFontSize);}} -else if(arcStyle.weightPosition==WeightTextUp) -{if(baseEdge.GetText().length>0) -{this.DrawUpText(positions[0],positions[1],baseEdge.GetText(),arcStyle,false,arcStyle.weightText,baseEdge.model.width/2+arcStyle.mainTextFontSize/2,arcStyle.mainTextFontSize);} -if(baseEdge.GetUpText().length>0) -{this.DrawUpText(positions[0],positions[1],baseEdge.GetUpText(),arcStyle,false,arcStyle.additionalTextColor,-baseEdge.model.width/2-(arcStyle.mainTextFontSize/2+4),arcStyle.mainTextFontSize);}}} -BaseEdgeDrawer.prototype.SetupStyle=function(baseEdge,arcStyle) -{this.context.lineWidth=baseEdge.model.width;this.context.strokeStyle=arcStyle.strokeStyle;this.context.fillStyle=arcStyle.fillStyle;this.model=baseEdge.model;this.style=arcStyle;} -BaseEdgeDrawer.prototype.DrawArc=function(position1,position2,arcStyle) -{if(this.drawArc&&this.drawArc!=this) -{this.drawArc.DrawArc(position1,position2,arcStyle);return;} -this.context.setLineDash(lineDashTypes[arcStyle.lineDash]);if(position1.equals(position2)) -{this.context.beginPath();this.context.arc(position1.x-Math.cos(this.model.GetLoopShiftAngel())*this.model.GetLoopSize(),position1.y-Math.sin(this.model.GetLoopShiftAngel())*this.model.GetLoopSize(),this.model.GetLoopSize(),0,2*Math.PI);this.context.stroke();} -else -{this.context.beginPath();this.context.moveTo(position1.x,position1.y);this.context.lineTo(position2.x,position2.y);this.context.stroke();} -this.context.setLineDash([]);} -BaseEdgeDrawer.prototype.DrawWeight=function(position1,position2,text,arcStyle,hasPair) -{var centerPoint=this.GetTextCenterPoint(position1,position2,hasPair,arcStyle);this.context.font="bold "+arcStyle.mainTextFontSize+"px sans-serif";this.context.textBaseline="middle";this.context.lineWidth=arcStyle.textStrokeWidth;this.context.fillStyle=arcStyle.fillStyle;var widthText=this.context.measureText(text).width;this.context.beginPath();this.context.rect(centerPoint.x-widthText/2-arcStyle.textPadding/2,centerPoint.y-arcStyle.mainTextFontSize/1.7-arcStyle.textPadding/2,widthText+arcStyle.textPadding,arcStyle.mainTextFontSize+arcStyle.textPadding);this.context.closePath();this.context.fill();this.context.stroke();this.context.fillStyle=arcStyle.weightText;this.context.fillText(text,centerPoint.x-widthText/2,centerPoint.y);} -BaseEdgeDrawer.prototype.DrawUpText=function(position1,position2,text,arcStyle,hasPair,color,offset,fontSize) -{var centerPoint=this.GetTextCenterPoint(position1,position2,hasPair,arcStyle);this.context.font=fontSize==null?"bold "+(DefaultMainTextFontSizeEdge+TopTextFontSizeDeltaEdge)+"px sans-serif":"bold "+(fontSize+TopTextFontSizeDeltaEdge)+"px sans-serif";this.context.textBaseline="middle";var widthText=this.context.measureText(text).width;this.context.fillStyle=color;var vectorEdge=new Point(position2.x-position1.x,position2.y-position1.y);var angleRadians=Math.atan2(vectorEdge.y,vectorEdge.x);if(angleRadians>Math.PI/2||angleRadians<-Math.PI/2) -{vectorEdge=new Point(position1.x-position2.x,position1.y-position2.y);angleRadians=Math.atan2(vectorEdge.y,vectorEdge.x);} -var normalize=vectorEdge.normal().normalizeCopy(offset);this.context.save();this.context.translate(centerPoint.x-normalize.x,centerPoint.y-normalize.y);this.context.rotate(angleRadians);this.context.textAlign="center";this.context.fillText(text,0,0);this.context.restore();} -BaseEdgeDrawer.prototype.DrawArrow=function(position,direction,length,width) -{var normal=direction.normal();var pointOnLine=position.subtract(direction.multiply(length));var point1=pointOnLine.add(normal.multiply(width));var point2=pointOnLine.add(normal.multiply(-width));this.context.beginPath();this.context.moveTo(position.x,position.y);this.context.lineTo(point1.x,point1.y);this.context.lineTo(point2.x,point2.y);this.context.lineTo(position.x,position.y);this.context.closePath();this.context.fill();} -BaseEdgeDrawer.prototype.GetStartArrowDirection=function(position1,position2,lengthArrow) -{if(this.startArrowDirection&&this.startArrowDirection!=this) -{return this.startArrowDirection.GetStartArrowDirection(position1,position2,lengthArrow);} -var direction=position1.subtract(position2);direction.normalize(1.0);return direction;} -BaseEdgeDrawer.prototype.GetFinishArrowDirection=function(position1,position2,lengthArrow) -{if(this.finishArrowDirection&&this.finishArrowDirection!=this) -{return this.finishArrowDirection.GetFinishArrowDirection(position1,position2,lengthArrow);} -var direction=position2.subtract(position1);direction.normalize(1.0);return direction;} -BaseEdgeDrawer.prototype.GetTextCenterPoint=function(position1,position2,hasPair,arcStyle) -{if(this.textCenterObject&&this.textCenterObject!=this) -{return this.textCenterObject.GetTextCenterPoint(position1,position2,hasPair,arcStyle);} -var textShift=Math.min(12/position1.subtract(position2).length(),0.4);var centerPoint=Point.interpolate(position1,position2,0.5);if(position1.equals(position2)) -{let sinVal=Math.sin(this.model.GetLoopShiftAngel());let cosVal=Math.cos(this.model.GetLoopShiftAngel());centerPoint.x=centerPoint.x-cosVal*this.model.GetLoopSize();centerPoint.y=centerPoint.y-(sinVal+Math.sign(sinVal)*1.0)*this.model.GetLoopSize();} -return centerPoint;} -BaseEdgeDrawer.prototype.GetPointOnArc=function(position1,position2,percent) -{if(this.getPointOnArc&&this.getPointOnArc!=this) -{return this.getPointOnArc.GetPointOnArc(position1,position2,percent);} -return Point.interpolate(position1,position2,percent);} -function ProgressArcDrawer(context,baseDrawer,progress) -{this.context=context;this.baseDrawer=baseDrawer;this.progress=progress;} -ProgressArcDrawer.prototype=Object.create(BaseEdgeDrawer.prototype);ProgressArcDrawer.prototype.Draw=function(baseEdge,arcStyle) -{this.baseDrawer.Draw(baseEdge,arcStyle);this.context.lineWidth=10;var positions=baseEdge.GetEdgePositionsShift();var progressSize=10;if(positions[0].equals(positions[1])) -{var sizeInRadian=progressSize/(2*Math.PI*this.baseDrawer.model.GetLoopSize())*6;this.context.beginPath();this.context.arc(positions[0].x-Math.cos(this.baseDrawer.model.GetLoopShiftAngel())*this.baseDrawer.model.GetLoopSize(),positions[0].y-Math.sin(this.baseDrawer.model.GetLoopShiftAngel())*this.baseDrawer.model.GetLoopSize(),this.baseDrawer.model.GetLoopSize(),this.progress*2*Math.PI,this.progress*2*Math.PI+sizeInRadian);this.context.stroke();} -else -{var startPosition=this.baseDrawer.GetPointOnArc(positions[0],positions[1],this.progress);var vectorOffset=positions[0].subtract(positions[1]).normalizeCopy(progressSize);var finishPosition=startPosition.add(vectorOffset);this.context.beginPath();this.context.moveTo(startPosition.x,startPosition.y);this.context.lineTo(finishPosition.x,finishPosition.y);this.context.stroke();}} -function CurvedArcDrawer(context,model) -{this.context=context;this.model=model;} -CurvedArcDrawer.prototype=Object.create(BaseEdgeDrawer.prototype);CurvedArcDrawer.prototype.DrawArc=function(position1,position2,arcStyle) -{this.context.setLineDash(lineDashTypes[arcStyle.lineDash]);if(position1.equals(position2)) -{this.context.beginPath();this.context.arc(position1.x-Math.cos(this.model.GetLoopShiftAngel())*this.model.GetLoopSize(),position1.y-Math.sin(this.model.GetLoopShiftAngel())*this.model.GetLoopSize(),this.model.GetLoopSize(),0,2*Math.PI);this.context.closePath();this.context.stroke();} -else -{var points=this.model.GetBezierPoints(position1,position2);var firstBezierPoint=points[0];var secondBezierPoint=points[1];this.context.beginPath();this.context.moveTo(position1.x,position1.y);this.context.bezierCurveTo(firstBezierPoint.x,firstBezierPoint.y,secondBezierPoint.x,secondBezierPoint.y,position2.x,position2.y);this.context.stroke();} -this.context.setLineDash([]);} -CurvedArcDrawer.prototype.GetStartArrowDirection=function(position1,position2,lengthArrow) -{var dist=position1.distance(position2);var direction=position1.subtract(this.model.GetCurvePoint(position1,position2,lengthArrow/dist));direction.normalize(1.0);return direction;} -CurvedArcDrawer.prototype.GetFinishArrowDirection=function(position1,position2,lengthArrow) -{var dist=position1.distance(position2);var direction=position2.subtract(this.model.GetCurvePoint(position1,position2,1.0-lengthArrow/dist));direction.normalize(1.0);return direction;} -CurvedArcDrawer.prototype.GetTextCenterPoint=function(position1,position2,hasPair,arcStyle) -{var centerPoint=this.model.GetCurvePoint(position1,position2,0.5) -if(position1.equals(position2)) -{let sinVal=Math.sin(this.model.GetLoopShiftAngel());let cosVal=Math.cos(this.model.GetLoopShiftAngel());centerPoint.x=centerPoint.x-cosVal*this.model.GetLoopSize();centerPoint.y=centerPoint.y-(sinVal+Math.sign(sinVal)*1.0)*this.model.GetLoopSize();} -return centerPoint;} -CurvedArcDrawer.prototype.GetPointOnArc=function(position1,position2,percent) -{return this.model.GetCurvePoint(position1,position2,percent);} -const VertexCircleShape=0,VertexSquareShape=1,VertexTriangleShape=2,VertexPentagonShape=3,VertexHomeShape=4,VertexTextboxShape=5;VertexSnowflakeShape=6;function GetSquarePoints(diameter) -{var res=[];var a=diameter;res.push(new Point(-a/2,-a/2));res.push(new Point(a/2,-a/2));res.push(new Point(a/2,a/2));res.push(new Point(-a/2,a/2));return res;} -function GetTrianglePoints(diameter) -{var res=[];var effectiveDiameter=diameter*1.5;var upOffset=effectiveDiameter/2;var downOffset=effectiveDiameter/4;var lrOffset=effectiveDiameter*3/(Math.sqrt(3)*4);res.push(new Point(0,-upOffset));res.push(new Point(lrOffset,downOffset));res.push(new Point(-lrOffset,downOffset));return res;} -function GetPentagonPoints(diameter) -{var res=[];var baseValue=diameter/2*1.2;res.push(new Point(0,-baseValue));res.push((new Point(0,-baseValue)).rotate(new Point(0,0),72));res.push((new Point(0,-baseValue)).rotate(new Point(0,0),72*2));res.push((new Point(0,-baseValue)).rotate(new Point(0,0),72*3));res.push((new Point(0,-baseValue)).rotate(new Point(0,0),72*4));res.push((new Point(0,-baseValue)).rotate(new Point(0,0),72*5));return res;} -function GetTextboxPoints(diameter,additional_data) -{var res=[];var width=diameter;var height=diameter;if(additional_data) -{var tempContext=document.createElement('canvas').getContext('2d');tempContext.font="bold "+additional_data.style.mainTextFontSize+ -DefaultFont;let metrics=tempContext.measureText(additional_data.text);width=metrics.width+diameter/2;let actualHeight=metrics.actualBoundingBoxAscent*1.6;height=Math.max(height,actualHeight);} -res.push(new Point(-width/2,-height/2));res.push(new Point(width/2,-height/2));res.push(new Point(width/2,height/2));res.push(new Point(-width/2,height/2));return res;} -function GetShowflakePoints(diameter) -{var res=[];var superSmallRadius=diameter*0.8/2;var smallRadius=diameter*0.95/2;var bigRadius=diameter*1.5/2;let angel=8;res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),-angel));res.push(new Point(smallRadius,0));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),angel));res.push(new Point(bigRadius,0).rotate(new Point(0,0),30));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60-angel));res.push(new Point(smallRadius,0).rotate(new Point(0,0),60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+angel));res.push(new Point(bigRadius,0).rotate(new Point(0,0),30+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60-angel));res.push(new Point(smallRadius,0).rotate(new Point(0,0),60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+angel));res.push(new Point(bigRadius,0).rotate(new Point(0,0),30+60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+60-angel));res.push(new Point(smallRadius,0).rotate(new Point(0,0),60+60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+60+angel));res.push(new Point(bigRadius,0).rotate(new Point(0,0),30+60+60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+60+60-angel));res.push(new Point(smallRadius,0).rotate(new Point(0,0),60+60+60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+60+60+angel));res.push(new Point(bigRadius,0).rotate(new Point(0,0),30+60+60+60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+60+60+60-angel));res.push(new Point(smallRadius,0).rotate(new Point(0,0),60+60+60+60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+60+60+60+angel));res.push(new Point(bigRadius,0).rotate(new Point(0,0),30+60+60+60+60+60));return res;} -function GetPointsForShape(shape,diameter,additional_data=null) -{switch(parseInt(shape)) -{case VertexSquareShape:return GetSquarePoints(diameter);break;case VertexTriangleShape:return GetTrianglePoints(diameter);break;case VertexPentagonShape:return GetPentagonPoints(diameter);break;case VertexTextboxShape:return GetTextboxPoints(diameter,additional_data);break;case VertexSnowflakeShape:return GetShowflakePoints(diameter);break;default:return null;break;}} -function GetSizeForShape(shape,diameter) -{switch(parseInt(shape)) -{case VertexSquareShape:return diameter;break;case VertexTriangleShape:return diameter*1.5;break;case VertexPentagonShape:return diameter*1.2;break;case VertexTextboxShape:return diameter;break;case VertexSnowflakeShape:return diameter*1.5;break;default:return diameter;break;}} -const CommonTextCenter=0,CommonTextUp=1;const DefaultFont="px sans-serif",DefaultMainTextFontSize=16,TopTextFontSizeDelta=-4;function BaseVertexStyle() -{this.baseStyles=[];} -BaseVertexStyle.prototype.GetStyle=function(baseStyle,object) -{this.baseStyles.forEach(function(element){var styleObject=globalApplication.GetStyle("vertex",element,object);baseStyle=styleObject.GetStyle(baseStyle,object);});if(this.hasOwnProperty('lineWidth')) -baseStyle.lineWidth=this.lineWidth;if(this.hasOwnProperty('strokeStyle')) -baseStyle.strokeStyle=this.strokeStyle;if(this.hasOwnProperty('fillStyle')) -baseStyle.fillStyle=this.fillStyle;if(this.hasOwnProperty('mainTextColor')) -baseStyle.mainTextColor=this.mainTextColor;if(this.hasOwnProperty('shape')) -baseStyle.shape=this.shape;if(this.hasOwnProperty('upTextColor')) -baseStyle.upTextColor=this.upTextColor;if(this.hasOwnProperty('commonTextPosition')) -baseStyle.commonTextPosition=this.commonTextPosition;if(this.hasOwnProperty('mainTextFontSize')) -baseStyle.mainTextFontSize=this.mainTextFontSize;baseStyle.lineWidth=parseInt(baseStyle.lineWidth);return this.FixNewFields(baseStyle);} -BaseVertexStyle.prototype.FixNewFields=function(style) -{if(!style.hasOwnProperty('shape')) -style.shape=VertexCircleShape;if(!style.hasOwnProperty('commonTextPosition')) -style.commonTextPosition=CommonTextCenter;if(!style.hasOwnProperty('mainTextFontSize')) -style.mainTextFontSize=DefaultMainTextFontSize;return style;} -BaseVertexStyle.prototype.Clear=function() -{delete this.lineWidth;delete this.strokeStyle;delete this.fillStyle;delete this.mainTextColor;delete this.shape;delete this.upTextColor;delete this.commonTextPosition;delete this.lineWidth;delete this.mainTextFontSize;} -BaseVertexStyle.prototype.ShouldLoad=function(field) -{return field!="baseStyles";} -function CommonVertexStyle() -{BaseVertexStyle.apply(this,arguments);this.lineWidth=2;this.strokeStyle='#c7b7c7';this.fillStyle='#68aeba';this.mainTextColor='#f0d543';this.shape=VertexCircleShape;this.upTextColor='#68aeba';this.commonTextPosition=CommonTextCenter;this.baseStyles=[];} -CommonVertexStyle.prototype=Object.create(BaseVertexStyle.prototype);function CommonPrintVertexStyle() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#000000';this.fillStyle='#FFFFFF';this.mainTextColor='#000000';this.baseStyles.push("common");} -CommonPrintVertexStyle.prototype=Object.create(BaseVertexStyle.prototype);function SelectedVertexStyle0() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#f0d543';this.mainTextColor='#f0d543';this.fillStyle='#c7627a';this.baseStyles.push("common");} -SelectedVertexStyle0.prototype=Object.create(BaseVertexStyle.prototype);function SelectedVertexStyle1() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#7a9ba0';this.mainTextColor='#c3d2d5';this.fillStyle='#534641';this.baseStyles.push("selected");} -SelectedVertexStyle1.prototype=Object.create(BaseVertexStyle.prototype);function SelectedVertexStyle2() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#8C4C86';this.mainTextColor='#dbbdd8';this.fillStyle='#253267';this.baseStyles.push("selected");} -SelectedVertexStyle2.prototype=Object.create(BaseVertexStyle.prototype);function SelectedVertexStyle3() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#6188FF';this.mainTextColor='#6188FF';this.fillStyle='#E97CF9';this.baseStyles.push("selected");} -SelectedVertexStyle3.prototype=Object.create(BaseVertexStyle.prototype);function SelectedVertexStyle4() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#C6B484';this.mainTextColor='#C6B484';this.fillStyle='#E0DEE1';this.baseStyles.push("selected");} -SelectedVertexStyle4.prototype=Object.create(BaseVertexStyle.prototype);function SelectedPrintVertexStyle() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#000000';this.mainTextColor='#000000';this.fillStyle='#AAAAAA';this.baseStyles.push("printed");} -SelectedPrintVertexStyle.prototype=Object.create(BaseVertexStyle.prototype);var DefaultSelectedGraphStyles=[new SelectedVertexStyle0(),new SelectedVertexStyle1(),new SelectedVertexStyle2(),new SelectedVertexStyle3(),new SelectedVertexStyle4()];var DefaultPrintSelectedGraphStyles=[new SelectedPrintVertexStyle()];function BaseVertexDrawer(context) -{this.context=context;} -BaseVertexDrawer.prototype.Draw=function(baseGraph,graphStyle) -{this.SetupStyle(graphStyle);this.DrawShape(baseGraph);if(this.currentStyle.lineWidth!=0) -this.context.stroke();this.context.fill();var shapeSize=GetSizeForShape(graphStyle.shape,baseGraph.model.diameter+graphStyle.lineWidth);if(graphStyle.commonTextPosition==CommonTextCenter) -{this.DrawCenterText(baseGraph.position,baseGraph.mainText,graphStyle.mainTextColor,graphStyle.fillStyle,true,true,graphStyle.mainTextFontSize);this.DrawCenterText(baseGraph.position.add(new Point(0,-shapeSize/2.0-graphStyle.mainTextFontSize/2.2)),baseGraph.upText,graphStyle.upTextColor,graphStyle.strokeStyle,false,false,graphStyle.mainTextFontSize+TopTextFontSizeDelta);} -else if(graphStyle.commonTextPosition==CommonTextUp) -{this.DrawCenterText(baseGraph.position.add(new Point(0,-shapeSize/2.0-graphStyle.mainTextFontSize/2.2)),baseGraph.mainText,graphStyle.mainTextColor,graphStyle.fillStyle,true,false,graphStyle.mainTextFontSize);this.DrawCenterText(baseGraph.position.add(new Point(0,shapeSize/2.0+graphStyle.mainTextFontSize/1.7)),baseGraph.upText,graphStyle.upTextColor,graphStyle.strokeStyle,false,false,graphStyle.mainTextFontSize+TopTextFontSizeDelta);}} -BaseVertexDrawer.prototype.SetupStyle=function(style) -{this.currentStyle=style;this.context.lineWidth=style.lineWidth;this.context.strokeStyle=style.strokeStyle;this.context.fillStyle=style.fillStyle;} -BaseVertexDrawer.prototype.DrawShape=function(baseGraph) -{this.context.beginPath();if(this.currentStyle.shape==VertexCircleShape) -{this.context.arc(baseGraph.position.x,baseGraph.position.y,baseGraph.model.diameter/2.0,0,2*Math.PI);} -else -{var points=GetPointsForShape(this.currentStyle.shape,baseGraph.model.diameter,{style:this.currentStyle,text:baseGraph.mainText});this.context.moveTo(baseGraph.position.x+points[points.length-1].x,baseGraph.position.y+points[points.length-1].y);var context=this.context;points.forEach(function(point){context.lineTo(baseGraph.position.x+point.x,baseGraph.position.y+point.y);});} -this.context.closePath();} -BaseVertexDrawer.prototype.DrawText=function(position,text,color,outlineColor,outline,font) -{this.context.fillStyle=color;this.context.font=font;this.context.lineWidth=4;this.context.strokeStyle=outlineColor;if(outline) -{this.context.save();this.context.lineJoin='round';this.context.strokeText(text,position.x,position.y);this.context.restore();} -this.context.fillText(text,position.x,position.y);} -BaseVertexDrawer.prototype.DrawCenterText=function(position,text,color,outlineColor,bold,outline,size) -{this.context.textBaseline="middle";this.context.font=(bold?"bold ":"")+size+DefaultFont;var textWidth=this.context.measureText(text).width;this.DrawText(new Point(position.x-textWidth/2,position.y),text,color,outlineColor,outline,this.context.font);} -{let modulDir="features/algorithms/";doInclude([include("model/Algorithms.js",modulDir),include("model/BaseTraversal.js",modulDir)]) -function loadAsyncAlgorithms(onFinish){let modulDir="features/algorithms/";let pluginsList=["BFS.js","Coloring.js","ConnectedComponent.js","DFS.js","EulerianLoop.js","EulerianPath.js","FindAllPatches.js","FindLongestPath.js","FindShortPatchsFromOne.js","Floid.js","GraphReorder.js","HamiltonianLoop.js","HamiltonianPath.js","IsomorphismCheck.js","MaxClique.js","MaxFlow.js","MinimumSpanningTree.js","ModernGraphStyle.js","RadiusAndDiameter.js","ShortestPath.js","VerticesDegree.js"];doIncludeAsync(pluginsList.map((plugin)=>include("model/plugins/"+plugin+"?v="+globalVersion,modulDir)),onFinish);}} -function getVertexToVertexArray(graph,ignoreDirection) -{res={};for(var i=0;iprocessData+=delimiter+param.name+delimiter+param.value);var res=this.app.processEmscripten(processData);processResult(res);}else{console.log("Use new CGI");var queryString=algorithmName+"=cgiInput&report=xml";otherParams.forEach((param)=>queryString+="&"+param.name+"="+param.value);$.ajax({type:"POST",url:"/"+SiteDir+"cgi-bin/GraphCGI.exe?"+queryString,data:xml,dataType:"text",}).done(function(msg) -{processResult(msg);});} -return true;} -BaseAlgorithmEx.prototype.GetNodesPath=function(array,start,count) -{var res=[];for(var index=start;index"+"";for(var i=0;i";} -return res+"";} -BaseHandler.prototype.GetSelect2VertexMenu=function() -{return""+ -this.GetSelectVertexMenu("Vertex1")+" → "+this.GetSelectVertexMenu("Vertex2")+"";} -BaseHandler.prototype.SelectFirstVertexMenu=function(vertex1Text,vertex) -{} -BaseHandler.prototype.UpdateFirstVertexMenu=function() -{} -BaseHandler.prototype.SelectSecondVertexMenu=function(vertex2Text,vertex) -{} -BaseHandler.prototype.UpdateSecondVertexMenu=function() -{} -BaseHandler.prototype.GetSelectedVertex=function() -{return null;} -BaseHandler.prototype.addContextMenu=function() -{var $contextMenu=$("#contextMenu");var handler=this;$("#Context_Delete").click(function(){if(handler.contextMenuObject!=null){handler.app.PushToStack("DeleteObject");handler.app.DeleteObject(handler.contextMenuObject);handler.app.redrawGraph();userAction("DeleteObject_contextMenu");}});$("#Context_Rename").click(function(){if(handler.contextMenuObject!=null){var callback=function(enumType){handler.RenameVertex(enumType.GetVertexText(0),handler.contextMenuObject);userAction("RenameVertex_contextMenu");};var customEnum=new TextEnumVerticesCustom(handler.app);customEnum.ShowDialog(callback,g_rename,g_renameVertex,handler.contextMenuObject.mainText);}});$("#Context_Connect").click(function(){if(handler.contextMenuObject!=null&&handler.GetSelectedVertex()!=null){var addFunc=function(firstVertex,secondVertex,direct){handler.app.CreateNewArc(firstVertex,secondVertex,direct,document.getElementById('EdgeWeight').value,$("#RadiosReplaceEdge").prop("checked"),document.getElementById('EdgeLable').value);handler.app.redrawGraph();} -handler.ShowCreateEdgeDialog(handler.GetSelectedVertex(),handler.contextMenuObject,addFunc);}});$("#Context_Delete_Edge").click(function(){if(handler.contextMenuObject!=null){handler.app.PushToStack("DeleteObject");handler.app.DeleteObject(handler.contextMenuObject);handler.app.redrawGraph();userAction("DeleteObject_contextMenu");}});$("#Context_Edit_Edge").click(function(){if(handler.contextMenuObject!=null){handler.ShowEditEdgeDialog(handler.contextMenuObject);}});$("#Context_Add_Vertex").click(function(){handler.app.PushToStack("Add");handler.app.CreateNewGraph(handler.contextMenuPoint.x,handler.contextMenuPoint.y);handler.app.redrawGraph();});$("#Context_Back_Color").click(function(){var setupBackgroundStyle=new SetupBackgroundStyle(handler.app);setupBackgroundStyle.show();});$("body").on("contextmenu","canvas",function(e){handler.contextMenuPoint=handler.app.getMousePos(handler.app.canvas,e);handler.contextMenuObject=handler.GetSelectedObject(handler.contextMenuPoint);if(handler.contextMenuObject instanceof BaseVertex){$("#edgeContextMenu").hide();$("#backgroundContextMenu").hide();$("#vertexContextMenu").show();if(handler.GetSelectedVertex()==null){$("#Context_Connect").hide();}else{$("#Context_Connect").show();}}else if(handler.contextMenuObject instanceof BaseEdge){$("#vertexContextMenu").hide();$("#backgroundContextMenu").hide();$("#edgeContextMenu").show();}else{$("#vertexContextMenu").hide();$("#edgeContextMenu").hide();$("#backgroundContextMenu").show();} -$contextMenu.css({display:"block",left:e.offsetX,top:e.offsetY});return false;});$("body").click(function(){$contextMenu.hide();});} -BaseHandler.prototype.removeContextMenu=function() -{$("body").off("contextmenu");$("#Context_Delete").off("click");$("#Context_Rename").off("click");$("#Context_Connect").off("click");$("#Context_Delete_Edge").off("click");$("#Context_Edit_Edge").off("click");$("#Context_Add_Vertex").off("click");$("#Context_Back_Color").off("click");} -BaseHandler.prototype.RenameVertex=function(text,object) -{if(object!=null&&(object instanceof BaseVertex)) -{this.app.PushToStack("RenameVertex");object.mainText=text;this.app.redrawGraph();}} -BaseHandler.prototype.ShowCreateEdgeDialog=function(firstVertex,secondVertex,addEdgeCallBack){if(!this.app.graph.isMulti()) -{var hasEdge=this.app.graph.FindEdgeAny(firstVertex.id,secondVertex.id);var hasReverseEdge=this.app.graph.FindEdgeAny(secondVertex.id,firstVertex.id);if(hasEdge==null&&hasReverseEdge==null) -{$("#RadiosReplaceEdge").prop("checked",true);$("#NewEdgeAction").hide();} -else{$("#NewEdgeAction").show();}} -else -{$("#RadiosAddEdge").prop("checked",true);$("#NewEdgeAction").hide();} -var dialogButtons={};var handler=this;$("#CheckSaveDefaultEdge").prop("checked",false);$("#defaultEdgeDialogBlock").show();dialogButtons[g_orintEdge]=function(){handler.app.PushToStack("Connect");addEdgeCallBack(firstVertex,secondVertex,true);$(this).dialog("close");};dialogButtons[g_notOrintEdge]=function(){handler.app.PushToStack("Connect");addEdgeCallBack(firstVertex,secondVertex,false);$(this).dialog("close");};var edgePresets=this.app.GetEdgePresets();var presetsStr=""+g_DefaultWeightPreset+"";for(var i=0;i"+edgePreset+"";} -document.getElementById("EdgesPresets").innerHTML=presetsStr;document.getElementById('EdgeLable').value="";$("#addEdge").dialog({resizable:false,height:"auto",width:"auto",modal:true,title:g_addEdge,buttons:dialogButtons,dialogClass:'EdgeDialog',open:function(){$(this).off('submit').on('submit',function(){return false;});setTimeout(function(){const weightInput=document.getElementById('EdgeWeight');if(weightInput) -{weightInput.focus();weightInput.select();}},0);}});} -BaseHandler.prototype.ShowEditEdgeDialog=function(edgeObject){var dialogButtons={};var handler=this;dialogButtons[g_save]=function(){handler.app.PushToStack("ChangeEdge");edgeObject.SetWeight(document.getElementById('EdgeWeight').value);edgeObject.SetUpText(document.getElementById('EdgeLable').value);handler.needRedraw=true;handler.app.redrawGraph();userAction("ChangeWeight");$(this).dialog("close");};document.getElementById('EdgeWeight').value=edgeObject.useWeight?edgeObject.weight:g_noWeight;document.getElementById('EdgeWeightSlider').value=edgeObject.useWeight?edgeObject.weight:0;var edgePresets=handler.app.GetEdgePresets();var presetsStr=""+g_DefaultWeightPreset+"";for(var i=0;i"+edgePreset+"";} -document.getElementById("EdgesPresets").innerHTML=presetsStr;document.getElementById('EdgeLable').value=edgeObject.upText;$("#CheckSaveDefaultEdge").prop("checked",false);$("#defaultEdgeDialogBlock").hide();$("#addEdge").dialog({resizable:false,height:"auto",width:"auto",modal:true,title:g_editWeight,buttons:dialogButtons,dialogClass:'EdgeDialog',open:function(){$(handler).off('submit').on('submit',function(){return false;});}});} -doInclude([include("features/base_handler/index.js")]) -function DefaultHandler(app) -{this.removeStack=true;BaseHandler.apply(this,arguments);this.message=g_textsSelectAndMove+" "+g_selectGroupText+""+" "+g_useContextMenuText+"";this.selectedObjects=[];this.dragObject=null;this.selectedObject=null;this.prevPosition=null;this.groupingSelect=false;this.selectedLogRect=false;this.selectedLogCtrl=false;this.saveUndo=false;this.addContextMenu();} -DefaultHandler.prototype=Object.create(BaseHandler.prototype);DefaultHandler.prototype.pressed=false;DefaultHandler.prototype.curveValue=0.1;DefaultHandler.prototype.GetSelectedVertex=function() -{return(this.selectedObject instanceof BaseVertex)?this.selectedObject:null;} -DefaultHandler.prototype.MouseMove=function(pos) -{if(this.dragObject) -{if(!this.saveUndo) -{this.app.PushToStack("Move");this.saveUndo=true;} -this.dragObject.position.x=pos.x;this.dragObject.position.y=pos.y;this.needRedraw=true;} -else if(this.selectedObjects.length>0&&this.pressed&&!this.groupingSelect) -{if(!this.saveUndo) -{this.app.PushToStack("Move");this.saveUndo=true;} -var offset=(new Point(pos.x,pos.y)).subtract(this.prevPosition);for(var i=0;i0||this.selectedObject!=null)&&selectedObject!=null) -{if(this.selectedObjects.length==0) -{this.selectedObjects.push(this.selectedObject);this.selectedObject=null;this.selectedObjects.push(selectedObject);} -else if(!this.selectedObjects.includes(selectedObject)) -{this.selectedObjects.push(selectedObject);} -else if(severalSelect&&this.selectedObjects.includes(selectedObject)) -{var index=this.selectedObjects.indexOf(selectedObject);this.selectedObjects.splice(index,1);} -if(!this.selectedLogCtrl) -{userAction("GroupSelected.SelectCtrl");this.selectedLogCtrl=true;}} -else -{if(selectedObject!=null) -{this.selectedObject=selectedObject;} -if((selectedObject instanceof BaseVertex)&&selectedObject!=null) -{this.dragObject=selectedObject;this.message=g_moveCursorForMoving;}} -this.needRedraw=true;this.pressed=true;this.prevPosition=pos;this.app.canvas.style.cursor="move";} -DefaultHandler.prototype.MouseUp=function(pos) -{this.saveUndo=false;this.message=g_textsSelectAndMove+" "+g_selectGroupText+""+" "+g_useContextMenuText+"";this.dragObject=null;this.pressed=false;this.app.canvas.style.cursor="auto";this.app.SetSelectionRect(null);this.groupingSelect=false;if(this.selectedObject!=null&&(this.selectedObject instanceof BaseVertex)) -{this.message=g_textsSelectAndMove -+"
" -+"" -+"" -+"
";var handler=this;var callback=function(enumType){handler.RenameVertex(enumType.GetVertexText(0),handler.selectedObject);userAction("RenameVertex");};$('#message').unbind();$('#message').on('click','#renameButton',function(){var customEnum=new TextEnumVerticesCustom(handler.app);customEnum.ShowDialog(callback,g_rename,g_renameVertex,handler.selectedObject.mainText);});$('#message').on('click','#changeCommonStyle',function(){var selectedVertices=handler.app.GetSelectedVertices();var setupVertexStyle=new SetupVertexStyle(handler.app);setupVertexStyle.show(0,selectedVertices);});$('#message').on('click','#changeSelectedStyle',function(){var selectedVertices=handler.app.GetSelectedVertices();var setupVertexStyle=new SetupVertexStyle(handler.app);setupVertexStyle.show(1,selectedVertices);});} -else if(this.selectedObject!=null&&(this.selectedObject instanceof BaseEdge)) -{this.message=g_textsSelectAndMove -+"" -+" "+g_curveEdge+" " -+"   " -+"
" -+"" -+"" -+"
";var handler=this;$('#message').unbind();$('#message').on('click','#editEdge',function(){handler.ShowEditEdgeDialog(handler.selectedObject);});$('#message').on('click','#incCurvel',function(){handler.app.PushToStack("ChangeCurvelEdge");handler.selectedObject.model.ChangeCurveValue(DefaultHandler.prototype.curveValue);handler.needRedraw=true;handler.app.redrawGraph();userAction("Edge.Bend");});$('#message').on('click','#decCurvel',function(){handler.app.PushToStack("ChangeCurvelEdge");handler.selectedObject.model.ChangeCurveValue(-DefaultHandler.prototype.curveValue);handler.needRedraw=true;handler.app.redrawGraph();userAction("Edge.Bend");});$('#message').on('click','#changeCommonStyle',function(){var selectedEdges=handler.app.GetSelectedEdges();var setupVertexStyle=new SetupEdgeStyle(handler.app);setupVertexStyle.show(0,selectedEdges);});$('#message').on('click','#changeSelectedStyle',function(){var selectedEdges=handler.app.GetSelectedEdges();var setupVertexStyle=new SetupEdgeStyle(handler.app);setupVertexStyle.show(1,selectedEdges);});} -else if(this.selectedObjects.length>0) -{this.message=g_dragGroupText+" "+g_selectGroupText+"";var hasVertices=false;var hasEdges=false;for(var i=0;i";this.message=this.message -+"    " -+"" -this.message=this.message -+"     " -+"" -+"
";var handler=this;$('#message').unbind();$('#message').on('click','#DublicateSelected',function(){handler.app.PushToStack("DublicateSelection");userAction("GroupSelected.Dublicate");var newSelected=[];var copyVertex={};for(var i=0;i=1) -{var curve=handler.app.GetAvailableCurveValue(neighborEdges,newObject);newObject.model.SetCurveValue(curve);}} -newSelected.push(newObject);}} -handler.selectedObjects=newSelected;handler.needRedraw=true;handler.app.redrawGraph();});$('#message').on('click','#RemoveSelected',function(){handler.app.PushToStack("RemoveSelection");userAction("GroupSelected.Remove");for(var i=0;i"+g_selectGroupText+"";});if(hasEdges){$('#message').on('click','#changeCommonStyleEdge',function(){var selectedEdges=handler.app.GetSelectedEdges();var setupVertexStyle=new SetupEdgeStyle(handler.app);setupVertexStyle.show(0,selectedEdges);});$('#message').on('click','#changeSelectedStyleEdge',function(){var selectedEdges=handler.app.GetSelectedEdges();var setupVertexStyle=new SetupEdgeStyle(handler.app);setupVertexStyle.show(1,selectedEdges);});} -if(hasVertices){$('#message').on('click','#changeCommonStyleVertex',function(){var selectedVertices=handler.app.GetSelectedVertices();var setupVertexStyle=new SetupVertexStyle(handler.app);setupVertexStyle.show(0,selectedVertices);});$('#message').on('click','#changeSelectedStyleVertex',function(){var selectedVertices=handler.app.GetSelectedVertices();var setupVertexStyle=new SetupVertexStyle(handler.app);setupVertexStyle.show(1,selectedVertices);});}} -this.needRedraw=true;} -DefaultHandler.prototype.GetSelectedGroup=function(object) -{return(object==this.dragObject)||(object==this.selectedObject)?1:0||this.selectedObjects.includes(object);} -DefaultHandler.prototype.SelectObjectInRect=function(rect) -{this.selectedObjects=[];var vertices=this.app.graph.vertices;for(var i=0;i" -+" " -+"" -+" "+baseMessage;} -ConnectionGraphHandler.checkUseDefaultEdge=function(elem,app) -{app.setUseDefaultEdge(elem.checked);app.updateMessage();};ConnectionGraphHandler.prototype.GetUseDefaultEdgeCheckBox=function(){if(!this.app.hasDefaultEdge()){return"";} -return"
"+""+" "+"
";} -ConnectionGraphHandler.prototype.InitControls=function(){BaseHandler.prototype.InitControls.call(this) -if(!this.app.hasDefaultEdge()){return;} -let app=this.app;$('#useDefaultEdge').unbind();$('#useDefaultEdge').change(function(){app.setUseDefaultEdge(this.checked);});$("#useDefaultEdge").prop("checked",this.app.getUseDefaultEdge());} -doInclude([include("features/base_handler/index.js")]) -function DeleteGraphHandler(app) -{this.removeStack=true;BaseHandler.apply(this,arguments);this.message=g_selectObjectToDelete;this.addContextMenu();} -DeleteGraphHandler.prototype=Object.create(BaseHandler.prototype);DeleteGraphHandler.prototype.MouseDown=function(pos) -{var selectedObject=this.GetSelectedObject(pos);if(!this.app.IsCorrectObject(selectedObject)) -return;this.app.PushToStack("Delete");this.app.DeleteObject(selectedObject);this.needRedraw=true;} -function DeleteAllHandler(app) -{BaseHandler.apply(this,arguments);} -DeleteAllHandler.prototype=Object.create(BaseHandler.prototype);DeleteAllHandler.prototype.clear=function() -{this.app.PushToStack("DeleteAll");this.app.graph=new Graph();this.app.savedGraphName="";this.needRedraw=true;} -doInclude([include("features/base_handler/index.js")]) -function AlgorithmGraphHandler(app,algorithm) -{BaseHandler.apply(this,arguments);this.algorithm=algorithm;this.SaveUpText();this.UpdateResultAndMessage();} -AlgorithmGraphHandler.prototype=Object.create(BaseHandler.prototype);AlgorithmGraphHandler.prototype.MouseMove=function(pos){} -AlgorithmGraphHandler.prototype.MouseDown=function(pos) -{this.app.setRenderPath([]);if(this.algorithm.instance()) -{this.app.SetDefaultHandler();} -else -{var selectedObject=this.GetSelectedGraph(pos);if(selectedObject&&(selectedObject instanceof BaseVertex)) -{if(this.algorithm.selectVertex(selectedObject)) -{this.needRedraw=true;} -this.UpdateResultAndMessage();} -else if(selectedObject&&(selectedObject instanceof BaseEdge)) -{if(this.algorithm.selectEdge(selectedObject)) -{this.needRedraw=true;} -this.UpdateResultAndMessage();} -else -{if(this.algorithm.deselectAll()) -{this.needRedraw=true;this.UpdateResultAndMessage();}}}} -AlgorithmGraphHandler.prototype.MouseUp=function(pos){} -AlgorithmGraphHandler.prototype.GetSelectedGroup=function(object) -{return this.algorithm.getObjectSelectedGroup(object);} -AlgorithmGraphHandler.prototype.RestoreAll=function() -{this.app.setRenderPath([]);if(this.algorithm.needRestoreUpText()) -{this.RestoreUpText();} -if(this.algorithm.wantRestore()) -{this.algorithm.restore();}} -AlgorithmGraphHandler.prototype.SaveUpText=function() -{this.vertexUpText={};var graph=this.app.graph;for(i=0;i";var directedHeader="";var undirectedHeader="";var defaultWeight=1.0;var weightKeyId="\"d0\"";var weightNode=""+""+defaultWeight+""+"";var xmlBody="";for(var i=0;i";} -var hasDirected=false;for(var i=0;i"+arc.weight+"";} -xmlBody=xmlBody+""+weightData+"":"/>")} -xml=mainHeader+weightNode+(hasDirected?directedHeader:undirectedHeader)+xmlBody+"" -return xml;} -function BaseEnumVertices(app,startNumber) -{this.app=app;this.startNumber=startNumber;} -BaseEnumVertices.prototype.GetVertexText=function(id) -{return this.startNumber+id;} -BaseEnumVertices.prototype.GetVertexTextAsync=function(callback) -{callback(this);} -BaseEnumVertices.prototype.GetText=function() -{return this.startNumber+", "+(this.startNumber+1)+", "+(this.startNumber+2)+"...";} -BaseEnumVertices.prototype.GetValue=function() -{return"Numbers"+this.startNumber;} -function TextEnumTitle(app,title) -{BaseEnumVertices.apply(this,arguments);this.pattern="";this.title=title;} -TextEnumTitle.prototype=Object.create(BaseEnumVertices.prototype);TextEnumTitle.prototype.GetVertexText=function(id) -{return this.title;} -function TextEnumVertices(app) -{BaseEnumVertices.apply(this,arguments);this.pattern="ABCDEFGHIJKLMNOPQRSTUVWXYZ";} -TextEnumVertices.prototype=Object.create(BaseEnumVertices.prototype);TextEnumVertices.prototype.GetVertexText=function(id) -{var res="";res=this.pattern[id%this.pattern.length]+res;while(id>=this.pattern.length) -{id=Math.floor(id/this.pattern.length)-1;res=this.pattern[id%this.pattern.length]+res;} -return res;} -TextEnumVertices.prototype.GetText=function() -{return"A, B, ... Z";} -TextEnumVertices.prototype.GetValue=function() -{return"Latin";} -function TextEnumVerticesCyr(app) -{TextEnumVertices.apply(this,arguments);this.pattern="АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ";} -TextEnumVerticesCyr.prototype=Object.create(TextEnumVertices.prototype);TextEnumVerticesCyr.prototype.GetText=function() -{return"А, Б, ... Я";} -TextEnumVerticesCyr.prototype.GetValue=function() -{return"Cyrillic";} -function TextEnumVerticesGreek(app) -{TextEnumVertices.apply(this,arguments);this.pattern="ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ";} -TextEnumVerticesGreek.prototype=Object.create(TextEnumVertices.prototype);TextEnumVerticesGreek.prototype.GetText=function() -{return"Α, Β, ... Ω";} -TextEnumVerticesGreek.prototype.GetValue=function() -{return"Greek";} -function TextEnumVerticesCustom(app) -{BaseEnumVertices.apply(this,arguments);this.pattern="";} -TextEnumVerticesCustom.prototype=Object.create(BaseEnumVertices.prototype);TextEnumVerticesCustom.prototype.GetText=function() -{return g_customEnumVertex;} -TextEnumVerticesCustom.prototype.GetValue=function() -{return"Custom";} -TextEnumVerticesCustom.prototype.GetVertexTextAsync=function(callback) -{this.ShowDialog(callback,g_addVertex,g_addVertex,"A");} -TextEnumVerticesCustom.prototype.ShowDialog=function(callback,buttonText,titleTitle,title) -{var dialogButtons={};app=this.app;dialogButtons[buttonText]=function(){app.PushToStack("RenameVertex");callback(new TextEnumTitle(app,$("#VertexTitle").val()));$(this).dialog("close");};$("#addVertex").dialog({resizable:false,height:"auto",width:"auto",modal:true,title:titleTitle,buttons:dialogButtons,dialogClass:'EdgeDialog',open:function(){$(this).off('submit').on('submit',function(){return false;});$("#VertexTitle").val(title);$("#VertexTitle").focus();}});} -var g_textsSelectAndMove="Drag objects";var g_moveCursorForMoving="Move cursor";var g_clickToAddVertex="Click to add vertex";var g_selectFirstVertexToConnect="Select first vertex to connect";var g_selectSecondVertexToConnect="Select second vertex to connect";var g_selectStartVertexForShortPath="Select start vertex for shortest path";var g_selectFinishVertexForShortPath="Select finish vertex for shortest path";var g_shortestPathResult="Shortest path is %d";var g_pathNotExists="Path does not exists";var g_selectObjectToDelete="Select object to delete";var g_addEdge="Add edge";var g_orintEdge="Directed";var g_notOrintEdge="Undirected";var g_adjacencyMatrixText="Adjacency Matrix";var g_save="Save";var g_cancel="Cancel";var g_save_graph="Save Graph";var g_shortestDistance="lowest-distance is ";var g_incidenceMatrixText="Incidence Matrix";var g_save_dialog="Save dialog";var g_close="close";var g_sickConnectedComponent="Sick connected component is ";var g_connectedComponent="Connected component is ";var g_what_do_you_think="What do you think about site?";var g_name="Name";var g_feedback="Feedback";var g_send="Send";var g_write_to_us="Write to us";var g_fixMatrix="Fix matrix";var g_readMatrixHelp="Matrix format help";var g_matrixWrongFormat="Matrix is wrong";var g_pairWrongFormat="Edge List is wrong";var g_fix="Fix" -var g_save_image_dialog="Save graph image";var g_fullReport="Full report";var g_shortReport="Short report";var g_hasEulerianLoop="Graph has Eulerian Loop";var g_hasNotEulerianLoop="Graph has not Eulerian Loop";var g_hasEulerianPath="Graph has Eulerian Path";var g_hasNotEulerianPath="Graph has not Eulerian Path";var g_processing="Processing...";var g_customEnumVertex="Custom";var g_addVertex="Add vertex";var g_renameVertex="Rename vertex";var g_rename="Rename";var g_language="en";var g_editWeight="Edit weight";var g_noWeight="No weight";var g_groupRename="Group rename";var g_vote="Vote";var g_recommendAlgorithm="Recommend algorithm";var g_graphOfMinDist="Graph of minimal distances.";var g_checkToSave="Check to save";var g_showDistMatrix="Show Distance matrix";var g_minDistMatrixText="Minimal distances matrix";var g_selectStartVertexForMaxFlow="Select source vertex for max flow";var g_selectFinishVertexForMaxFlow="Select sink vertex for max flow";var g_maxFlowResult="Maximum flow from %2 to %3 is %1";var g_flowNotExists="Flow from %1 to %2 does not exists";var g_sourceVertex="Source";var g_sinkVertex="Sink";var g_hasHamiltonianLoop="Graph has Hamiltonian Loop";var g_hasNotHamiltonianLoop="Graph has not Hamiltonian Loop";var g_hasHamiltonianPath="Graph has Hamiltonian Path";var g_hasNotHamiltonianPath="Graph has not Hamiltonian Path";var g_startTraversal="Select start traversal vector";var g_traversalOrder="Traversal order: ";var g_curveEdge="Curved edge";var g_Undo="Undo";var g_default="default";var g_vertexDraw="Vertex draw style";var g_edgeDraw="Edge draw style";var g_backgroundStyle="Background style";var g_GraphIsMultiMessage="Graph is multigraph";var g_GraphIsGeneralMessage="";var g_DefaultWeightPreset="no weight";var g_dragGroupText="Drag group.";var g_selectGroupText="Select using ctrl";var g_copyGroupeButton="Duplicate";var g_removeGroupeButton="Remove objects";var g_BFSName="Breadth-first search";var g_ColoringName="Graph coloring";var g_findConnectedComponent="Find connected components";var g_DFSName="Depth-first search";var g_EulerinLoopName="Find Eulerian cycle";var g_EulerinPath="Find Eulerian path";var g_FloidName="Floyd–Warshall algorithm";var g_GraphReorder="Arrange the graph";var g_HamiltoianCycleName="Find Hamiltonian cycle";var g_HamiltonianPath="Find Hamiltonian path";var g_MaxFlowName="Find Maximum flow";var g_minimumSpanningTree="Search of minimum spanning tree";var g_modernGraphStyleName="Visualization based on weight";var g_RadiusAndDiameter="Search graph radius and diameter";var g_findShortPathName="Find shortest path using Dijkstra's algorithm";var g_VerticesDegreeName="Calculate vertices degree";var g_SpanningTreeResult="Min Spanning Tree is";var g_SpanningTreeIgnoreDir="We ignored edges direction for calculation";var g_SpanningTreeNotConnected="Graph is not connected";var g_selectFirstGraphIsomorphismCheck="Select first graph for isomorphic check. Click to any node of graph";var g_selectSecondGraphIsomorphismCheck="Select second graph for isomorphic check. Click to any node of graph";var g_selectFirstGraphPatternCheck="Select a template graph by clicking to any node of graph";var g_selectSecondGraphForSearchSubgraph="Choose a graph in which we will look for isomorphic subgraphs. Click to any node of this graph";var g_graphsIsomorph="Graphs are isomorphic";var g_graphsNotIsomorph="Graphs are not isomorphic";var g_numberOfIsomorphSubgraphIs="Number of isomorphic subgraphs are ";var g_graphHasNoIsomorphSubgraph="Graph don't contain isomorphic subgraphs";var g_searchIsomorphSubgraph="Search isomorphic subgraphs";var g_subgraphNo="Isomorphic subgraph # ";var g_graphHasNoAtleast2Graphs="To use the algorithm, you need to create 2 separate graphs";var g_IsomorphismCheck="Check Graphs Isomorphism";var g_graphIsDisconnected="Graph is disconnected";var g_graphIsTrivial="Graph contains only one vertex";var g_graphRadius="Graph radius";var g_graphDiameter="Graph diameter";var g_vertexCentral="Central";var g_vertexPeripheral="Peripheral";var g_maximumDegreeOfGraph="The maximum degree of a graph is";var g_colorNumber="Color number is";var g_done="Done";var g_action="Action";var g_commonEdgeStyle="Common Edge Style";var g_selectedEdgeStyle="Selected Edge Style";var g_commonVertexStyle="Common Vertex Style";var g_selectedVertexStyle="Selected Vertex Style";var g_findAllPathes="Find all paths";var g_numberOfPathesFrom="Number of paths from " -var g_to=" to ";var g_are=" are ";var g_pathN="Path #";var g_selectFinishVertex="Select finish vertex";var g_selectStartVertex="Select start vertex";var g_findAllPathesFromVertex="Find all shortest paths from vertex";var g_distanceFrom="Distance from ";var g_pathTo="Path to ";var g_useContextMenuText="Use context menu for addition actions." -var g_findLongestPath="Find the longest path";var g_LengthOfLongestPathFrom="Length of the longest path from ";var g_additionalActions="Additional actions";var g_reverseAllEdges="Reverse all edges";var g_makeAllUndirected="Make all edges undirected";var g_makeAllDirected="Make all edges directed";var g_reuseSavedEdge="Reuse saved edge";var g_MaxClique="Max Clique";var g_MaxCliqueNotFound="Max Clique is not found";var g_MaxCliqueSizeIs="Max Clique size is ";var g_MaxCliqueContains=". Clique contains these vertecies: ";var g_wrongImageFormatPNGAndJPEG="Wrong image format. We support only JPEG and PNG.";var g_wrongImageSizeP1="Image size is too big. Image size must be less than {0} pixels.";function loadTexts() -{g_textsSelectAndMove=document.getElementById("SelectAndMoveObject").innerHTML;g_moveCursorForMoving=document.getElementById("MoveCursorForMoving").innerHTML;g_clickToAddVertex=document.getElementById("clickToAddVertex").innerHTML;g_selectFirstVertexToConnect=document.getElementById("selectFisrtVertextToConnect").innerHTML;g_selectSecondVertexToConnect=document.getElementById("selectSecondVertextToConnect").innerHTML;g_selectStartVertexForShortPath=document.getElementById("selectStartShortPathVertex").innerHTML;g_selectFinishVertexForShortPath=document.getElementById("selectFinishShortPathVertex").innerHTML;g_shortestPathResult=document.getElementById("shortPathResult").innerHTML;g_pathNotExists=document.getElementById("pathNotExists").innerHTML;g_selectObjectToDelete=document.getElementById("selectObjectToDelete").innerHTML;g_addEdge=document.getElementById("AddEdge").innerHTML;g_orintEdge=document.getElementById("OrintEdge").innerHTML;g_notOrintEdge=document.getElementById("NotOrintdge").innerHTML;g_adjacencyMatrixText=document.getElementById("AdjacencyMatrixText").innerHTML;g_save=document.getElementById("Save").innerHTML;g_cancel=document.getElementById("Cancel").innerHTML;g_shortestDistance=document.getElementById("shortestDist").innerHTML;g_incidenceMatrixText=document.getElementById("IncidenceMatrixText").innerHTML;g_save_dialog=document.getElementById("saveDialogTitle").innerHTML;g_close=document.getElementById("closeButton").innerHTML;g_sickConnectedComponent=document.getElementById("sickConnectedComponentResult").innerHTML;g_connectedComponent=document.getElementById("connectedComponentResult").innerHTML;g_what_do_you_think=document.getElementById("whatDoYouThink").innerHTML;g_name=document.getElementById("name").innerHTML;g_feedback=document.getElementById("feedback").innerHTML;g_send=document.getElementById("send").innerHTML;g_write_to_us=document.getElementById("writeToUs").innerHTML;g_fixMatrix=document.getElementById("fixMatrixButton").innerHTML;g_readMatrixHelp=document.getElementById("matrixHelp").innerHTML;g_matrixWrongFormat=document.getElementById("wronMatrixTitle").innerHTML;g_save_image_dialog=document.getElementById("saveImageDialogTitle").innerHTML;g_fullReport=document.getElementById("fullReport").innerHTML;g_shortReport=document.getElementById("shortReport").innerHTML;g_hasEulerianLoop=document.getElementById("hasEulerianLoop").innerHTML;g_hasNotEulerianLoop=document.getElementById("hasNotEulerianLoop").innerHTML;g_processing=document.getElementById("processing").innerHTML;g_customEnumVertex=document.getElementById("customEnumVertex").innerHTML;g_addVertex=document.getElementById("addVertexText").innerHTML;g_renameVertex=document.getElementById("renameVertex").innerHTML;g_rename=document.getElementById("renameText").innerHTML;g_language=document.getElementById("currentLanguage").innerHTML;g_editWeight=document.getElementById("editWeight").innerHTML;g_noWeight=document.getElementById("noWeight").innerHTML;g_groupRename=document.getElementById("groupeRenameText").innerHTML;g_vote=document.getElementById("voteText").innerHTML;g_recommendAlgorithm=document.getElementById("recommend_algorithm").innerHTML;g_hasEulerianPath=document.getElementById("hasEulerianPath").innerHTML;g_hasNotEulerianPath=document.getElementById("hasNotEulerianPath").innerHTML;g_graphOfMinDist=document.getElementById("graphOfMinDist").innerHTML;g_checkToSave=document.getElementById("checkToSave").innerHTML;g_showDistMatrix=document.getElementById("showDistMatrix").innerHTML;g_minDistMatrixText=document.getElementById("distMatrixText").innerHTML;g_selectStartVertexForMaxFlow=document.getElementById("selectStartVertexForMaxFlow").innerHTML;g_selectFinishVertexForMaxFlow=document.getElementById("selectFinishVertexForMaxFlow").innerHTML;g_maxFlowResult=document.getElementById("maxFlowResult").innerHTML;g_flowNotExists=document.getElementById("flowNotExists").innerHTML;g_sourceVertex=document.getElementById("sourceVertex").innerHTML;g_sinkVertex=document.getElementById("sinkVertex").innerHTML;g_hasHamiltonianLoop=document.getElementById("hasHamiltonianLoop").innerHTML;g_hasNotHamiltonianLoop=document.getElementById("hasNotHamiltonianLoop").innerHTML;g_hasHamiltonianPath=document.getElementById("hasHamiltonianPath").innerHTML;g_hasNotHamiltonianPath=document.getElementById("hasNotHamiltonianPath").innerHTML;g_startTraversal=document.getElementById("startTraversal").innerHTML;g_traversalOrder=document.getElementById("traversalOrder").innerHTML;g_curveEdge=document.getElementById("curveEdge").innerHTML;g_Undo=document.getElementById("undoTranslate").innerHTML;g_save_graph=document.getElementById("saveGraph").innerHTML;g_default=document.getElementById("default").innerHTML;g_vertexDraw=document.getElementById("vertexDrawStyle").innerHTML;g_edgeDraw=document.getElementById("edgeDrawStyle").innerHTML;g_backgroundStyle=document.getElementById("backgroundStyle").innerHTML;g_GraphIsMultiMessage=document.getElementById("graphIsMultiMessage").innerHTML;g_GraphIsGeneralMessage=document.getElementById("graphIsGeneralMessage").innerHTML;g_DefaultWeightPreset=document.getElementById("defaultWeightPreset").innerHTML;var isMac=navigator.platform.toUpperCase().indexOf('MAC')>=0;if(isMac) -g_selectGroupText=document.getElementById("selectGroupMac").innerHTML;else -g_selectGroupText=document.getElementById("selectGroupWin").innerHTML;g_dragGroupText=document.getElementById("dragSelectedGroup").innerHTML;g_copyGroupeButton=document.getElementById("copySelectedGroup").innerHTML;g_removeGroupeButton=document.getElementById("removeSelectedGroup").innerHTML;g_BFSName=document.getElementById("BFSName").innerHTML;g_ColoringName=document.getElementById("ColoringName").innerHTML;g_findConnectedComponent=document.getElementById("findConnectedComponent").innerHTML;g_DFSName=document.getElementById("DFSName").innerHTML;g_EulerinLoopName=document.getElementById("EulerinLoopName").innerHTML;g_EulerinPath=document.getElementById("EulerinPath").innerHTML;g_FloidName=document.getElementById("FloidName").innerHTML;g_GraphReorder=document.getElementById("GraphReorder").innerHTML;g_HamiltoianCycleName=document.getElementById("HamiltoianCycleName").innerHTML;g_HamiltonianPath=document.getElementById("HamiltonianPath").innerHTML;g_MaxFlowName=document.getElementById("MaxFlowName").innerHTML;g_minimumSpanningTree=document.getElementById("minimumSpanningTree").innerHTML;g_modernGraphStyleName=document.getElementById("modernGraphStyleName").innerHTML;g_RadiusAndDiameter=document.getElementById("RadiusAndDiameter").innerHTML;g_findShortPathName=document.getElementById("findShortPathName").innerHTML;g_VerticesDegreeName=document.getElementById("VerticesDegreeName").innerHTML;g_SpanningTreeResult=document.getElementById("MinSpanningTreeResult").innerHTML;g_SpanningTreeIgnoreDir=document.getElementById("MinSpanningIgnoreDir").innerHTML;g_SpanningTreeNotConnected=document.getElementById("MinSpanningNotConnected").innerHTML;g_selectFirstGraphIsomorphismCheck=document.getElementById("SelectFirstGraphIsomorphismCheck").innerHTML;g_selectSecondGraphIsomorphismCheck=document.getElementById("SelectSecondGraphIsomorphismCheck").innerHTML;g_selectFirstGraphPatternCheck=document.getElementById("SelectFirstGraphPatternCheck").innerHTML;g_selectSecondGraphForSearchSubgraph=document.getElementById("SelectSecondGraphForSearchSubgraph").innerHTML;g_graphsIsomorph=document.getElementById("GraphsIsomorph").innerHTML;g_graphsNotIsomorph=document.getElementById("GraphsNotIsomorph").innerHTML;g_numberOfIsomorphSubgraphIs=document.getElementById("NumberOfIsomorphSubgraphIs").innerHTML;g_graphHasNoIsomorphSubgraph=document.getElementById("GraphHasNoIsomorphSubgraph").innerHTML;g_searchIsomorphSubgraph=document.getElementById("SearchIsomorphSubgraph").innerHTML;g_subgraphNo=document.getElementById("SubgraphNo").innerHTML;g_graphHasNoAtleast2Graphs=document.getElementById("GraphHasNoAtleast2Graphs").innerHTML;g_IsomorphismCheck=document.getElementById("IsomorphismCheck").innerHTML;g_graphIsDisconnected=document.getElementById("GraphIsDisconnected").innerHTML;g_graphIsTrivial=document.getElementById("GraphIsTrivial").innerHTML;g_graphRadius=document.getElementById("GraphRadius").innerHTML;g_graphDiameter=document.getElementById("GraphDiameter").innerHTML;g_vertexCentral=document.getElementById("VertexCentral").innerHTML;g_vertexPeripheral=document.getElementById("VertexPeripheral").innerHTML;g_maximumDegreeOfGraph=document.getElementById("MaximumDegreeOfGraph").innerHTML;g_colorNumber=document.getElementById("ColorNumber").innerHTML;g_done=document.getElementById("Done").innerHTML;g_action=document.getElementById("ActionText").innerHTML;g_commonEdgeStyle=document.getElementById("CommonEdgeStyleText").innerHTML;g_selectedEdgeStyle=document.getElementById("SelectedEdgeStyleText").innerHTML;g_commonVertexStyle=document.getElementById("CommonVertexStyleText").innerHTML;g_selectedVertexStyle=document.getElementById("SelectedVertexStyleText").innerHTML;g_findAllPathes=document.getElementById("FindAllPathes").innerHTML;g_numberOfPathesFrom=document.getElementById("NumberOfPathesFrom").innerHTML;g_to=document.getElementById("To").innerHTML;g_are=document.getElementById("Are").innerHTML;g_pathN=document.getElementById("PathN").innerHTML;g_selectFinishVertex=document.getElementById("SelectFinishVertex").innerHTML;g_selectStartVertex=document.getElementById("SelectStartVertex").innerHTML;g_findAllPathesFromVertex=document.getElementById("findAllPathsFromVertex").innerHTML;g_distanceFrom=document.getElementById("distanceFrom").innerHTML;g_pathTo=document.getElementById("pathTo").innerHTML;g_useContextMenuText=document.getElementById("UseContextMenuText").innerHTML;g_findLongestPath=document.getElementById("findLongestPath").innerHTML;g_LengthOfLongestPathFrom=document.getElementById("LengthOfLongestPathFrom").innerHTML;g_additionalActions=document.getElementById("additionlActions").innerHTML;g_reverseAllEdges=document.getElementById("reverseAllEdges").innerHTML;g_makeAllUndirected=document.getElementById("makeAllUndirected").innerHTML;g_makeAllDirected=document.getElementById("makeAllDirected").innerHTML;g_pairWrongFormat=document.getElementById("pairWrongFormat").innerHTML;g_fix=document.getElementById("fixButton").innerHTML;g_reuseSavedEdge=document.getElementById("reuseSavedEdge").innerHTML;g_MaxClique=document.getElementById("maxClique").innerHTML;g_MaxCliqueNotFound=document.getElementById("maxCliqueNotFound").innerHTML;g_MaxCliqueSizeIs=document.getElementById("maxCliqueSizeIs").innerHTML;g_MaxCliqueContains=document.getElementById("maxCliqueContains").innerHTML;g_wrongImageFormatPNGAndJPEG=document.getElementById("wrongImageFormatPNGAndJPEG").innerHTML;g_wrongImageSizeP1=document.getElementById("wrongImageSizeP1").innerHTML;} -function UndoStack(maxUndoStackSize){this.undoStack=[];this.maxUndoStackSize=maxUndoStackSize;} -UndoStack.prototype.PushToStack=function(actionName,dataToSave) -{var object={};object.actionName=actionName;object.data=dataToSave;this.undoStack.push(object);while(this.undoStack.length>this.maxUndoStackSize) -{this.undoStack.shift();}} -UndoStack.prototype.Undo=function() -{if(this.IsUndoStackEmpty()) -return null;var state=this.undoStack.pop();return state.data;} -UndoStack.prototype.ClearUndoStack=function() -{this.undoStack=[];} -UndoStack.prototype.IsUndoStackEmpty=function() -{return(this.undoStack.length<=0);} -var DiskSaveLoad=function(){};DiskSaveLoad.LoadGraphFromDisk=function(graphName,callback) -{$.ajax({type:"GET",url:"/"+SiteDir+"cgi-bin/loadGraph.php?name="+graphName}).done(callback);} -DiskSaveLoad.SaveSVGGraphOnDisk=function(imageName,svgText,callback) -{$.ajax({type:"POST",url:"/"+SiteDir+"cgi-bin/saveSvg.php?name="+imageName,data:{svgdata:svgText},dataType:"text",success:callback});return imageName;} -DiskSaveLoad.SaveGraphOnDisk=function(savedGraphName,graphAsString,callback) -{$.ajax({type:"POST",url:"/"+SiteDir+"cgi-bin/saveGraph.php?name="+savedGraphName,data:graphAsString,dataType:"text"}).done(callback);} -DiskSaveLoad.SaveGraphImageOnDisk=function(imageName,rectParams,imageBase64Data,callback) -{$.ajax({type:"POST",url:"/"+SiteDir+"cgi-bin/saveImage.php?name="+imageName+rectParams,data:{base64data:imageBase64Data},dataType:"text",success:callback});} -var globalApplication=null;function Application(document,window,listener) -{this.document=document;this.listener=listener;this.canvas=this.document.getElementById('canvas');this.handler=new DefaultHandler(this);this.savedGraphName="";this.currentEnumVerticesType=new BaseEnumVertices(this,1);this.findPathReport=1;this.isTimerRender=false;globalApplication=this;this.renderPath=[];this.renderTimer=0;this.renderPathLength=0;this.renderPathCounter=0;this.renderPathLoops=0;this.enumVerticesTextList=[new BaseEnumVertices(this,1),new BaseEnumVertices(this,0),new TextEnumVertices(this),new TextEnumVerticesCyr(this),new TextEnumVerticesGreek(this),new TextEnumVerticesCustom(this)];this.SetDefaultTransformations();this.algorithmsValues={};this.undoStack=new UndoStack(this.maxUndoStackSize);this.edgeCommonStyle=new CommonEdgeStyle();this.isEdgeCommonStyleCustom=false;this.edgeSelectedStyles=FullArrayCopy(DefaultSelectedEdgeStyles);this.isEdgeSelectedStylesCustom=false;this.edgePrintCommonStyle=new CommonPrintEdgeStyle();this.edgePrintSelectedStyles=FullArrayCopy(DefaultPrintSelectedEdgeStyles);this.vertexCommonStyle=new CommonVertexStyle();this.isVertexCommonStyleCustom=false;this.vertexSelectedVertexStyles=FullArrayCopy(DefaultSelectedGraphStyles);this.isVertexSelectedVertexStylesCustom=false;this.vertexPrintCommonStyle=new CommonPrintVertexStyle();this.vertexPrintSelectedVertexStyles=FullArrayCopy(DefaultPrintSelectedGraphStyles);this.backgroundCommonStyle=new CommonBackgroundStyle();this.backgroundPrintStyle=new PrintBackgroundStyle();this.isBackgroundCommonStyleCustom=false;this.renderPathWithEdges=false;this.edgePresets=[1,3,5,7,11,42];this.maxEdgePresets=6;this.selectionRect=null;this.defaultVertexSize=null;this.defaultEdgeWidth=null;this.processEmscriptenFunction=null;this.defaultEdge=null;this.useDefaultEdge=false;};Application.prototype.graph=new Graph();Application.prototype.dragObject=-1;Application.prototype.handler=null;Application.prototype.status={};Application.prototype.graphNameLength=16;Application.prototype.maxUndoStackSize=8;Application.prototype.getMousePos=function(canvas,e) -{var rect=canvas.getBoundingClientRect();return{x:(e.clientX-rect.left)/this.canvasScale-this.canvasPosition.x,y:(e.clientY-rect.top)/this.canvasScale-this.canvasPosition.y};} -Application.prototype.redrawGraph=function() -{if(!this.isTimerRender) -{this._redrawGraphInWindow();this.GraphTypeChanged();}} -Application.prototype.redrawGraphTimer=function() -{if(this.isTimerRender) -{var context=this._redrawGraphInWindow();if(this.renderPath.length>1) -{context.save();context.scale(this.canvasScale,this.canvasScale);context.translate(this.canvasPosition.x,this.canvasPosition.y);var movePixelStep=16;var currentLength=0;var i=0 -for(i=0;ithis.renderPathCounter) -{currentLength-=edge.GetPixelLength();break;}} -if(i>=this.renderPath.length-1) -{i=0;if(this.renderPathWithEdges) -i=1;this.renderPathCounter=0;currentLength=0;this.renderPathLoops+=1;} -var edge=null;var currentVertexId=this.renderPath[i];if(this.renderPathWithEdges) -{edge=this.graph.FindEdgeById(this.renderPath[i]);currentVertexId=this.renderPath[i-1];} -else if(this.renderMinPath) -{edge=this.graph.FindEdgeMin(this.renderPath[i],this.renderPath[i+1]);} -else -{edge=this.graph.FindEdge(this.renderPath[i],this.renderPath[i+1]);} -var progress=(this.renderPathCounter-currentLength)/edge.GetPixelLength();this.RedrawEdgeProgress(context,edge,edge.vertex1.id==currentVertexId?progress:1.0-progress);this.renderPathCounter+=movePixelStep;context.restore();}} -if(this.renderPathLoops>=5) -{this.stopRenderTimer();}} -Application.prototype._redrawGraphInWindow=function() -{var context=this.canvas.getContext('2d');context.save();context.scale(this.canvasScale,this.canvasScale);context.translate(this.canvasPosition.x,this.canvasPosition.y);this._RedrawGraph(context,this.canvasPosition,this.backgroundCommonStyle,true);context.restore();return context;} -Application.prototype._OffscreenRedrawGraph=function() -{var bbox=this.graph.getGraphBBox();var canvas=document.createElement('canvas');canvas.width=bbox.size().x;canvas.height=bbox.size().y;var context=canvas.getContext('2d');context.save();context.translate(bbox.minPoint.inverse().x,bbox.minPoint.inverse().y);this._RedrawGraph(context,bbox.minPoint.inverse(),this.backgroundCommonStyle,false);context.restore();return canvas;} -Application.prototype._PrintRedrawGraph=function() -{var bbox=this.graph.getGraphBBox();var canvas=document.createElement('canvas');canvas.width=bbox.size().x;canvas.height=bbox.size().y;var context=canvas.getContext('2d');context.save();context.translate(bbox.minPoint.inverse().x,bbox.minPoint.inverse().y);this._RedrawGraph(context,bbox.minPoint.inverse(),this.backgroundPrintStyle,false,this.vertexPrintCommonStyle,this.vertexPrintSelectedVertexStyles,this.edgePrintCommonStyle,this.edgePrintSelectedStyles);context.restore();return canvas;} -Application.prototype._printToSVG=function() -{var bbox=this.graph.getGraphBBox();var context=new C2S(bbox.size().x,bbox.size().y);context.save();context.translate(bbox.minPoint.inverse().x,bbox.minPoint.inverse().y);this._RedrawGraph(context,bbox.minPoint.inverse(),this.backgroundCommonStyle,false);context.restore();return context.getSerializedSvg();} -Application.prototype.updateRenderPathLength=function() -{this.renderPathLength=0;this.renderPathCounter=0;if(this.renderPath.length>1) -{for(var i=0;i0) -{this.startRenderTimer();} -else -{this.stopRenderTimer();}} -Application.prototype.setRenderPathWithEdges=function(renderPath) -{this.renderPath=renderPath;this.renderMinPath=false;this.renderPathWithEdges=true;if(this.renderPath.length>0) -{this.startRenderTimer();} -else -{this.stopRenderTimer();}} -Application.prototype.GetBaseArcDrawer=function(context,edge) -{var arcDrawer=new BaseEdgeDrawer(context);if(edge.model.type==EdgeModels.curve) -{var curvedArcDrawer=new CurvedArcDrawer(context,edge.model);arcDrawer=new BaseEdgeDrawer(context,{drawArc:curvedArcDrawer,startArrowDirection:curvedArcDrawer,finishArrowDirection:curvedArcDrawer,textCenterObject:curvedArcDrawer,getPointOnArc:curvedArcDrawer});} -return arcDrawer;} -Application.prototype.UpdateEdgeCurrentStyle=function(edge,ForceCommonStyle,ForceSelectedStyle) -{var commonStyle=(ForceCommonStyle===undefined)?this.edgeCommonStyle:ForceCommonStyle;var selectedStyle=(ForceSelectedStyle===undefined)?this.edgeSelectedStyles:ForceSelectedStyle;var selectedGroup=this.handler.GetSelectedGroup(edge);var selected=false;if(selectedGroup>0) -{selectedGroup=(selectedGroup-1)%selectedStyle.length;selected=true;} -var currentStyle=null;if(edge.hasOwnStyleFor((selected?1:0)+selectedGroup)) -currentStyle=edge.getStyleFor((selected?1:0)+selectedGroup);else -currentStyle=selected?selectedStyle[selectedGroup]:commonStyle;edge.currentStyle=currentStyle;} -Application.prototype.RedrawEdge=function(context,edge) -{var curvedArcDrawer=new CurvedArcDrawer(context,edge.model) -var arcDrawer=this.GetBaseArcDrawer(context,edge);this._RedrawEdge(edge,arcDrawer);} -Application.prototype._RedrawEdge=function(edge,arcDrawer,commonStyle,selectedStyles) -{this._RedrawEdgeWithStyle(edge,edge.currentStyle,arcDrawer,commonStyle,selectedStyles);} -Application.prototype._RedrawEdgeWithStyle=function(edge,style,arcDrawer,commonStyle,selectedStyles) -{arcDrawer.Draw(edge,style.GetStyle({},edge));} -Application.prototype.RedrawEdgeProgress=function(context,edge,progress) -{var progressDraw=new ProgressArcDrawer(context,this.GetBaseArcDrawer(context,edge),progress);var arcDrawer=new BaseEdgeDrawer(context,{drawObject:progressDraw});this._RedrawEdge(edge,arcDrawer,this.edgeCommonStyle,this.edgeSelectedStyles);} -Application.prototype.UpdateEdgesCurrentStyle=function(ForceCommonStyle,ForceSelectedStyle) -{for(i=0;i0) -{selectedGroup=(selectedGroup-1)%selectedStyle.length;selected=true;} -var currentStyle=null;if(this.graph.vertices[i].hasOwnStyleFor((selected?1:0)+selectedGroup)&&!force) -currentStyle=this.graph.vertices[i].getStyleFor((selected?1:0)+selectedGroup);else -currentStyle=selected?selectedStyle[selectedGroup]:commonStyle;this.graph.vertices[i].currentStyle=currentStyle;}} -Application.prototype.RedrawSelectionRect=function(context) -{context.lineWidth=1.0/this.canvasScale;context.strokeStyle=this.edgeSelectedStyles[0].strokeStyle;context.setLineDash([6,3]);context.beginPath();context.rect(this.selectionRect.left(),this.selectionRect.top(),this.selectionRect.size().x,this.selectionRect.size().y);context.closePath();context.stroke();context.setLineDash([]);} -Application.prototype.updateMessage=function() -{this.listener.updateMessage(this.handler.GetMessage());this.handler.InitControls();} -Application.prototype.CanvasOnMouseMove=function(e) -{var pos=this.getMousePos(this.canvas,e);this.handler.MouseMove(pos);if(this.handler.IsNeedRedraw()) -{this.handler.RestRedraw();this.redrawGraph();} -this.updateMessage();} -Application.prototype.CanvasOnMouseDown=function(e) -{if(e.which!==1)return;var pos=this.getMousePos(this.canvas,e);this.handler.MouseDown(pos);if(this.handler.IsNeedRedraw()) -{this.handler.RestRedraw();this.redrawGraph();} -this.updateMessage();} -Application.prototype.CanvasOnMouseUp=function(e) -{if(e.which!==1)return;var pos=this.getMousePos(this.canvas,e);this.handler.MouseUp(pos);if(this.handler.IsNeedRedraw()) -{this.handler.RestRedraw();this.redrawGraph();} -this.updateMessage();} -Application.prototype.multCanvasScale=function(factor,zoom_to=null) -{if(zoom_to) -{var pos1=this.getMousePos(this.canvas,zoom_to);this.canvasScale*=factor;var pos2=this.getMousePos(this.canvas,zoom_to);this.canvasPosition=this.canvasPosition.add(new Point(pos2.x-pos1.x,pos2.y-pos1.y));} -else -{var oldRealWidth=this.GetRealWidth();var oldRealHeight=this.GetRealHeight();this.canvasScale*=factor;this.canvasPosition=this.canvasPosition.add(new Point((this.GetRealWidth()-oldRealWidth)/2.0,(this.GetRealHeight()-oldRealHeight)/2.0));} -this.redrawGraph();} -Application.prototype.setCanvasScale=function(factor) -{var oldRealWidth=this.GetRealWidth();var oldRealHeight=this.GetRealHeight();this.canvasScale=factor;this.canvasPosition=this.canvasPosition.add(new Point((this.GetRealWidth()-oldRealWidth)/2.0,(this.GetRealHeight()-oldRealHeight)/2.0));this.redrawGraph();} -Application.prototype.onCanvasMove=function(point) -{this.canvasPosition=this.canvasPosition.add(point.multiply(1/this.canvasScale));this.redrawGraph();} -Application.prototype.AddNewVertex=function(vertex) -{return this.graph.AddNewVertex(vertex);} -Application.prototype.AddNewEdge=function(edge,replaceIfExists) -{return this.graph.AddNewEdge(edge,replaceIfExists);} -Application.prototype.CreateNewGraph=function(x,y) -{var app=this;this.currentEnumVerticesType.GetVertexTextAsync(function(enumType) -{app.graph.AddNewVertex(new BaseVertex(x,y,enumType));app.redrawGraph();});} -Application.prototype.CreateNewGraphEx=function(x,y,vertexEnume) -{return this.graph.AddNewVertex(new BaseVertex(x,y,vertexEnume));} -Application.prototype.CreateNewArc=function(graph1,graph2,isDirect,weight,replaceIfExist,upText) -{var edge=this.AddNewEdge(new BaseEdge(graph1,graph2,isDirect,weight,upText),replaceIfExist);this.graph.FixEdgeCurve(edge);var edgeObject=this.graph.edges[edge];if(edgeObject.useWeight) -this.UpdateEdgePresets(edgeObject.weight);return edge;} -Application.prototype.DeleteEdge=function(edgeObject) -{var vertex1=edgeObject.vertex1;var vertex2=edgeObject.vertex2;var hasPair=this.graph.hasPair(edgeObject);this.graph.DeleteEdge(edgeObject);if(hasPair) -{var pairEdges=this.FindAllEdges(vertex2.id,vertex1.id);if(pairEdges.length==1&&pairEdges[0].model.default) -pairEdges[0].model.type=EdgeModels.line;}} -Application.prototype.DeleteVertex=function(graphObject) -{this.graph.DeleteVertex(graphObject);} -Application.prototype.DeleteObject=function(object) -{if(object instanceof BaseVertex) -{this.DeleteVertex(object);} -else if(object instanceof BaseEdge) -{this.DeleteEdge(object);}} -Application.prototype.IsCorrectObject=function(object) -{return(object instanceof BaseVertex)||(object instanceof BaseEdge);} -Application.prototype.FindVertex=function(id) -{return this.graph.FindVertex(id);} -Application.prototype.FindEdge=function(id1,id2) -{return this.graph.FindEdge(id1,id2);} -Application.prototype.FindEdgeAny=function(id1,id2) -{return this.graph.FindEdgeAny(id1,id2);} -Application.prototype.FindAllEdges=function(id1,id2) -{return this.graph.FindAllEdges(id1,id2);} -Application.prototype.SetHandler=function(newHandler) -{if(this.handler) -{this.handler.RestoreAll();} -this.handler=newHandler;this.ToDefaultStateAndRedraw();} -Application.prototype.ToDefaultStateAndRedraw=function() -{this.setRenderPath([]);this.updateMessage();this.redrawGraph();} -Application.prototype.getParameterByName=function(name) -{name=name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var regex=new RegExp("[\\?&]"+name+"=([^&#]*)"),results=regex.exec(location.search);return results===null?"":decodeURIComponent(results[1].replace(/\+/g," "));} -Application.prototype.onPostLoadEvent=function() -{this.SetEnumVerticesType(document.cookie.replace(/(?:(?:^|.*;\s*)enumType\s*\=\s*([^;]*).*$)|^.*$/,"$1"));var wasLoad=false;var matrix=document.getElementById("inputMatrix").innerHTML;var separator=document.getElementById("separator").innerHTML=="space"?" ":",";console.log(matrix);console.log("separator: \""+separator+"\"");matrix=(matrix.length<=0)?this.getParameterByName("matrix"):matrix;if(matrix.length>0) -{if(!this.SetAdjacencyMatrixSmart(matrix,separator)) -{userAction("AdjacencyMatrix.Failed");this.listener.ShowAdjacencyMatrixErrorDialog(matrix);} -else -{userAction("AdjacencyMatrix.Success");} -this.updateMessage();this.redrawGraph();wasLoad=true;} -var matrix=document.getElementById("inputIncidenceMatrix").innerHTML;matrix=(matrix.length<=0)?this.getParameterByName("incidenceMatrix"):matrix;if(matrix.length>0) -{if(!this.SetIncidenceMatrixSmart(matrix)) -{userAction("IncidenceMatrix.Failed");this.listener.ShowIncidenceMatrixErrorDialog(matrix);} -else -{userAction("IncidenceMatrix.Success");} -this.updateMessage();this.redrawGraph();wasLoad=true;} -var pairs=document.getElementById("inputPair").innerHTML;if(pairs.length>0) -{pairs=pairs.replaceAll('>','>');pairs=pairs.replaceAll('<','<');if(!this.SetPairSmart(pairs)) -{userAction("Pair.Failed");this.listener.ShowPairErrorDialog(pairs);} -else -{userAction("Pair.Success");} -this.updateMessage();this.redrawGraph();wasLoad=true;} -if(!wasLoad) -{var graphName=this.getParameterByName("graph");if(graphName.length<=0) -{graphName=document.cookie.replace(/(?:(?:^|.*;\s*)graphName\s*\=\s*([^;]*).*$)|^.*$/,"$1");} -if(graphName.length>0) -{userAction("LoadGraphFromDisk");this.LoadGraphFromDisk(graphName);}} -if(this.undoStack.IsUndoStackEmpty()) -document.getElementById('GraphUndo').style.display='none';this.updateMessage();this.redrawGraph();} -Application.prototype.onLoad=function() -{this.canvas=this.document.getElementById('canvas');this.SetDefaultHandler() -this.updateMessage();this.redrawGraph();} -Application.prototype.NeedRedraw=function() -{this.updateMessage();this.redrawGraph();} -Application.prototype.SetStatus=function(name,value) -{this.status[name]=value;} -Application.prototype.GetStatus=function() -{return this.status[name];} -Application.prototype.GetAdjacencyMatrix=function() -{return this.graph.GetAdjacencyMatrixStr();} -Application.prototype.TestAdjacencyMatrix=function(matrix,rowsObj,colsObj,separator) -{if(separator===undefined) -{separator=",";} -return this.graph.TestAdjacencyMatrix(matrix,rowsObj,colsObj,separator);} -Application.prototype.SetAdjacencyMatrix=function(matrix,separator) -{if(separator===undefined) -{separator=",";} -var res=true;var r={};var c={};if(!this.TestAdjacencyMatrix(matrix,r,c,separator)) -{$.get("/"+SiteDir+"cgi-bin/addFailedMatrix.php?text=adjacency&matrix="+encodeURIComponent(matrix),function(data){;});res=false;} -this.graph.SetAdjacencyMatrix(matrix,new Point(this.GetRealWidth(),this.GetRealHeight()),this.currentEnumVerticesType,separator);this.AutoAdjustViewport();this.redrawGraph();return res;} -Application.prototype.SetPair=function(pair) -{var res=true;var r={};var c={};if(!this.TestPair(pair)) -{$.get("/"+SiteDir+"cgi-bin/addFailedMatrix.php?text=pair&matrix="+encodeURIComponent(pair),function(data){;});res=false;} -this.graph.SetPair(pair,new Point(this.GetRealWidth(),this.GetRealHeight()),this.currentEnumVerticesType);this.AutoAdjustViewport();this.redrawGraph();return res;} -Application.prototype.GetIncidenceMatrix=function() -{return this.graph.GetIncidenceMatrix();} -Application.prototype.TestIncidenceMatrix=function(matrix,rowsObj,colsObj) -{return this.graph.TestIncidenceMatrix(matrix,rowsObj,colsObj);} -Application.prototype.TestPair=function(pair) -{return this.graph.TestPair(pair);} -Application.prototype.SetIncidenceMatrix=function(matrix) -{var res=true;var r={};var c={};if(!this.TestIncidenceMatrix(matrix,r,c)) -{$.get("/"+SiteDir+"cgi-bin/addFailedMatrix.php?text=incidence&matrix="+encodeURIComponent(matrix),function(data){;});res=false;} -this.graph.SetIncidenceMatrix(matrix,new Point(this.GetRealWidth(),this.GetRealHeight()),this.currentEnumVerticesType);this.AutoAdjustViewport();this.redrawGraph();return res;} -Application.prototype.Test=function() -{this.graph.VerticesReposition(new Point(this.GetRealWidth(),this.GetRealHeight()),this.graph.vertices);this.redrawGraph();} -Application.prototype.SetAdjacencyMatrixSmart=function(matrix,separator) -{if(separator===undefined) -{separator=",";} -var res=false;if(this.TestAdjacencyMatrix(matrix,{},{},separator)) -{res=this.SetAdjacencyMatrix(matrix,separator);} -else if(this.TestIncidenceMatrix(matrix,{},{})) -{res=this.SetIncidenceMatrix(matrix);} -else -{res=this.SetAdjacencyMatrix(matrix);} -return res;} -Application.prototype.SetIncidenceMatrixSmart=function(matrix) -{var res=false;if(this.TestIncidenceMatrix(matrix,{},{})) -{res=this.SetIncidenceMatrix(matrix);} -else if(this.TestAdjacencyMatrix(matrix,{},{})) -{res=this.SetAdjacencyMatrix(matrix);} -else -{res=this.SetIncidenceMatrix(matrix);} -return res;} -Application.prototype.SetPairSmart=function(pair) -{var res=false;if(this.TestPair(pair)) -{res=this.SetPair(pair);} -else -{res=false;} -return res;} -Application.prototype.SaveGraphOnDisk=function() -{var graphAsString=this.graph.SaveToXML(this.SaveUserSettings());if(this.savedGraphName.length<=0) -{this.savedGraphName=this.GetNewGraphName();} -var app=this;DiskSaveLoad.SaveGraphOnDisk(this.savedGraphName,graphAsString,function(msg) -{document.cookie="graphName="+app.savedGraphName;});} -Application.prototype.SaveGraphImageOnDisk=function(showDialogCallback) -{var imageName=this.GetNewName();this.stopRenderTimer();this.redrawGraph();var bbox=this.graph.getGraphBBox();var rectParams="";if(this.IsGraphFitOnViewport()) -{var canvasWidth=this.GetRealWidth();var canvasHeight=this.GetRealHeight();var canvasPositionInverse=this.canvasPosition.inverse();var pos=bbox.minPoint.subtract(canvasPositionInverse);rectParams="&x="+Math.round(pos.x*this.canvasScale)+"&y="+Math.round(pos.y*this.canvasScale) -+"&width="+Math.round(bbox.size().x*this.canvasScale)+"&height="+Math.round(bbox.size().y*this.canvasScale);} -var imageBase64Data=this.canvas.toDataURL();DiskSaveLoad.SaveGraphImageOnDisk(imageName,rectParams,imageBase64Data,showDialogCallback);return imageName;} -Application.prototype.SaveFullGraphImageOnDisk=function(showDialogCallback,forPrint) -{var imageName=this.GetNewName();this.stopRenderTimer();var canvas=forPrint?this._PrintRedrawGraph():this._OffscreenRedrawGraph();var bbox=this.graph.getGraphBBox();var rectParams="";rectParams="&x=0"+"&y=0"+"&width="+bbox.size().x+"&height="+bbox.size().y;var imageBase64Data=canvas.toDataURL();DiskSaveLoad.SaveGraphImageOnDisk(imageName,rectParams,imageBase64Data,showDialogCallback);return imageName;} -Application.prototype.SaveSVGGraphOnDisk=function(showDialogCallback) -{var imageName=this.GetNewName();this.stopRenderTimer();var svgText=this._printToSVG();DiskSaveLoad.SaveSVGGraphOnDisk(imageName,svgText,showDialogCallback);return imageName;} -Application.prototype.LoadGraphFromString=function(str) -{var graph=new Graph();var userSettings={};graph.LoadFromXML(str,userSettings);if(userSettings.hasOwnProperty("data")&&userSettings["data"].length>0) -this.LoadUserSettings(userSettings["data"]);this.SetDefaultTransformations();this.graph=graph;if(this.graph.isNeedReposition()) -{this.graph.VerticesReposition(new Point(this.GetRealWidth(),this.GetRealHeight()),this.graph.vertices);} -this.AutoAdjustViewport();this.updateMessage();this.redrawGraph();} -Application.prototype.LoadGraphFromDisk=function(graphName) -{var app=this;DiskSaveLoad.LoadGraphFromDisk(graphName,function(msg) -{app.LoadGraphFromString(msg);});} -Application.prototype.GetNewGraphName=function() -{var name=this.GetNewName();if(this.isVertexCommonStyleCustom||this.isVertexSelectedVertexStylesCustom||this.isBackgroundCommonStyleCustom||this.isEdgeCommonStyleCustom||this.isEdgeSelectedStylesCustom) -{name=name+"ZZcst";} -return name;} -Application.prototype.GetNewName=function() -{var name="";var possible="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(var i=0;i0) -{if(bboxSize.x>this.GetRealWidth()||bboxSize.y>this.GetRealHeight()) -{this.canvasScale=Math.min(this.GetRealWidth()/bboxSize.x,this.GetRealHeight()/bboxSize.y);} -if(graphBBox.minPoint.x<0.0||graphBBox.minPoint.y<0.0||graphBBox.maxPoint.x>this.GetRealWidth()||graphBBox.maxPoint.y>this.GetRealHeight()) -{this.canvasPosition=graphBBox.minPoint.inverse();}}} -Application.prototype.OnAutoAdjustViewport=function() -{this.SetDefaultTransformations();this.AutoAdjustViewport();this.redrawGraph();} -Application.prototype.getAlgorithmNames=function() -{var res=[];for(var i=0;i=Math.floor(graphBBox.maxPoint.x)&&Math.floor(canvasPositionInverse.y+canvasHeight)>=Math.floor(graphBBox.maxPoint.y));} -Application.prototype.PushToStack=function(actionName) -{this.undoStack.PushToStack(actionName,this.graph.SaveToXML(this.SaveUserSettings()));document.getElementById('GraphUndo').style.display='inline-block';} -Application.prototype.Undo=function() -{let data=this.undoStack.Undo();if(data==null) -return;this.graph=new Graph();var userSettings={};this.graph.LoadFromXML(data,userSettings);if(userSettings.hasOwnProperty("data")&&userSettings["data"].length>0) -this.LoadUserSettings(userSettings["data"]);this.redrawGraph();if(this.undoStack.IsUndoStackEmpty()) -document.getElementById('GraphUndo').style.display='none';} -Application.prototype.SaveUserSettings=function() -{var res="{";var needEnd=false;var checkValue=[];checkValue.push({field:"edgeCommonStyle",value:this.edgeCommonStyle,check:this.isEdgeCommonStyleCustom});checkValue.push({field:"edgeSelectedStyles",value:this.edgeSelectedStyles,check:this.isEdgeSelectedStylesCustom});checkValue.push({field:"vertexCommonStyle",value:this.vertexCommonStyle,check:this.isVertexCommonStyleCustom});checkValue.push({field:"vertexSelectedVertexStyles",value:this.vertexSelectedVertexStyles,check:this.isVertexSelectedVertexStylesCustom});checkValue.push({field:"backgroundCommonStyle",value:this.backgroundCommonStyle,check:this.isBackgroundCommonStyleCustom});checkValue.push({field:"defaultVertexSize",value:this.defaultVertexSize,check:this.defaultVertexSize!=null});checkValue.push({field:"defaultEdgeWidth",value:this.defaultEdgeWidth,check:this.defaultEdgeWidth!=null});checkValue.forEach(function(entry){if(!entry.check) -return;if(needEnd) -res=res+",";let valueJson="";if(typeof entry.value.saveToJson==="function"){valueJson=entry.value.saveToJson();}else{valueJson=JSON.stringify(entry.value);} -res=res+"\""+entry.field+"\""+":"+valueJson;needEnd=true;});res=res+"}";return this.EncodeToHTML(res);} -Application.prototype.LoadUserSettings=function(json) -{var checkValue=[];checkValue.push({field:"edgeCommonStyle",value:this.edgeCommonStyle,check:"isEdgeCommonStyleCustom",deep:false});checkValue.push({field:"edgeSelectedStyles",value:this.edgeSelectedStyles,check:"isEdgeSelectedStylesCustom",deep:true});checkValue.push({field:"vertexCommonStyle",value:this.vertexCommonStyle,check:"isVertexCommonStyleCustom",deep:false});checkValue.push({field:"vertexSelectedVertexStyles",value:this.vertexSelectedVertexStyles,check:"isVertexSelectedVertexStylesCustom",deep:true});checkValue.push({field:"defaultVertexSize",value:"defaultVertexSize",check:null,deep:false});checkValue.push({field:"defaultEdgeWidth",value:"defaultEdgeWidth",check:null,deep:false});checkValue.push({field:"backgroundCommonStyle",value:this.backgroundCommonStyle,check:this.isBackgroundCommonStyleCustom,deep:false});var decoderStr=this.DecodeFromHTML(json);var parsedSave=JSON.parse(decoderStr);var app=this;checkValue.forEach(function(entry){if(parsedSave.hasOwnProperty(entry.field)) -{if(typeof parsedSave[entry.field]==='number') -{app[entry.value]=parseInt(parsedSave[entry.field]);} -else -{if(typeof entry.value.loadFromJson==="function"){entry.value.loadFromJson(parsedSave[entry.field],function(){setTimeout(function(){app.redrawGraph()},1000);});return;} -if(!entry.deep) -entry.value.Clear();for(var k in parsedSave[entry.field]) -{if(!entry.deep) -{if(entry.value.ShouldLoad(k)) -{entry.value[k]=parsedSave[entry.field][k];}} -else -{if(k%1!=0) -continue;entry.value[k].Clear();for(var deepK in parsedSave[entry.field][k]) -{if(k=this.maxEdgePresets) -break;}} -Application.prototype.GetEdgePresets=function() -{return this.edgePresets;} -Application.prototype.SetSelectionRect=function(rect) -{this.selectionRect=rect;} -Application.prototype.GetSelectionRect=function(rect) -{return this.selectionRect;} -Application.prototype.GetStyle=function(type,styleName,object,index) -{var correctIndex=index;if(correctIndex==undefined) -correctIndex=0;if(type=="vertex") -{if(styleName=="common") -{return object!==undefined?object.getStyleFor(0):this.vertexCommonStyle;} -else if(styleName=="selected") -{return object!==undefined&&object.hasOwnStyleFor(correctIndex+1)?object.getStyleFor(correctIndex+1):this.vertexSelectedVertexStyles[correctIndex];} -else if(styleName=="printed") -{return this.vertexPrintCommonStyle;} -else if(styleName=="printedSelected") -{return this.vertexPrintSelectedVertexStyles[correctIndex];} -return null;} -else if(type=="edge") -{if(styleName=="common") -{return object!==undefined?object.getStyleFor(0):this.edgeCommonStyle;} -else if(styleName=="selected") -{return object!==undefined&&object.hasOwnStyleFor(correctIndex+1)?object.getStyleFor(correctIndex+1):this.edgeSelectedStyles[correctIndex];} -else if(styleName=="printed") -{return this.edgePrintCommonStyle;} -else if(styleName=="printedSelected") -{return this.edgePrintSelectedStyles[correctIndex];} -return null;} -return null;} -Application.prototype._RedrawGraph=function(context,backgroundPosition,backgroundStyle,bDrawSelectedRect,forceVertexCommon,forceVertexSelected,forceEdgeCommon,forceEdgeSelected) -{var backgroundDrawer=new BaseBackgroundDrawer(context);backgroundDrawer.Draw(backgroundStyle,Math.max(this.canvas.width,this.GetRealWidth()),Math.max(this.canvas.height,this.GetRealHeight()),backgroundPosition,this.canvasScale);this.UpdateEdgesCurrentStyle(forceEdgeCommon,forceEdgeSelected);this.UpdateNodesCurrentStyle(forceVertexCommon,forceVertexSelected);this.RedrawEdges(context);this.RedrawNodes(context);if(bDrawSelectedRect&&this.selectionRect!=null) -this.RedrawSelectionRect(context);} -Application.prototype.GetSelectedVertices=function() -{var res=[];for(i=0;i0) -{res.push(this.graph.vertices[i]);}} -return res;} -Application.prototype.GetSelectedEdges=function() -{var res=[];for(i=0;i0) -{res.push(this.graph.edges[i]);}} -return res;} -Application.prototype.SetDefaultVertexSize=function(diameter) -{var oldDefaultDiameter=this.GetDefaultVertexSize();this.defaultVertexSize=diameter;for(i=0;i0) -{self.application.multCanvasScale(1.3,e);} -else -{self.application.multCanvasScale(1.0/1.3,e);}}} -Editor.prototype.initKeyActions=function(){let self=this;function getCharCode(event){if(event.which==null){return event.keyCode;} -if(event.which!=0&&event.charCode!=0){return event.which;} -return null;} -function getChar(event){return String.fromCharCode(getCharCode(event));} -function selectHandler(buttonName,handler) -{userAction(buttonName+"_shortcut");self.restButtons(buttonName);self.application.SetHandler(handler);} -document.onkeypress=function(e) -{if(event.defaultPrevented||($('#addVertex').hasClass('ui-dialog-content')&&$('#addVertex').dialog('isOpen'))||($('#adjacencyMatrix').hasClass('ui-dialog-content')&&$('#adjacencyMatrix').dialog('isOpen'))||($('#addEdge').hasClass('ui-dialog-content')&&$('#addEdge').dialog('isOpen'))||($('#incidenceMatrix').hasClass('ui-dialog-content')&&$('#incidenceMatrix').dialog('isOpen'))||($('#saveDialog').hasClass('ui-dialog-content')&&$('#saveDialog').dialog('isOpen'))||($('#saveImageDialog').hasClass('ui-dialog-content')&&$('#saveImageDialog').dialog('isOpen'))||($('#GroupRenameDialog').hasClass('ui-dialog-content')&&$('#GroupRenameDialog').dialog('isOpen'))||$('#developerTools').css("display")!="none"||($('#NeedAlgorithm').hasClass('ui-dialog-content')&&$('#NeedAlgorithm').dialog('isOpen'))) -{console.log("prevent");return;} -var key=getChar(event);var code=getCharCode(event);console.log(key+" code="+code);var evtobj=window.event?event:e;var isCtrl=evtobj?evtobj.ctrlKey:false;var moveValue=10;if(code==61||code==43) -{self.application.multCanvasScale(1.5);} -else if(code==45) -{self.application.multCanvasScale(1/1.5);} -else if(key=='w'||key=='ц') -{self.application.onCanvasMove(new Point(0,moveValue));} -else if(key=='s'||key=='ы') -{self.application.onCanvasMove(new Point(0,-moveValue));} -else if(key=='a'||key=='ф') -{self.application.onCanvasMove(new Point(moveValue,0));} -else if(key=='d'||key=='в') -{self.application.onCanvasMove(new Point(-moveValue,0));} -else if(key=='v'||key=='м') -{selectHandler('AddGraph',new AddGraphHandler(self.application));} -else if(key=='e'||key=='у') -{selectHandler('ConnectGraphs',new ConnectionGraphHandler(self.application));} -else if(key=='r'||key=='к') -{selectHandler('DeleteObject',new DeleteGraphHandler(self.application));} -else if(key=='m'||key=='ь') -{selectHandler('Default',new DefaultHandler(self.application));} -else if(code==26&&isCtrl) -{userAction("Key_GraphUndo");self.application.Undo();}} -$(document).keydown(function(event){if(event.which=="17"||event.which=="91") -g_ctrlPressed=true;});$(document).keyup(function(){g_ctrlPressed=false;});} -Editor.prototype.initButtonActions=function() -{let self=this;document.getElementById('ShowAdjacencyMatrix').onclick=function() -{userAction(this.id);var showAdjacencyMatrix=new ShowAdjacencyMatrix(self.application);showAdjacencyMatrix.show();} -document.getElementById('ShowIncidenceMatrix').onclick=function() -{userAction(this.id);var showIncidenceMatrix=new ShowIncidenceMatrix(self.application);showIncidenceMatrix.show();} -document.getElementById('ShowDistanceMatrix').onclick=function() -{userAction(this.id);var showDistanceMatrix=new ShowDistanceMatrix(self.application);showDistanceMatrix.show();} -document.getElementById('GroupRename').onclick=function() -{userAction(this.id);var groupRenameVertices=new GroupRenameVertices(self.application);groupRenameVertices.show();} -document.getElementById('groupRenameButton').onclick=function() -{userAction(this.id);var groupRenameVertices=new GroupRenameVertices(self.application);groupRenameVertices.show();} -document.getElementById('Default').onclick=function() -{userAction(this.id);self.restButtons('Default');self.application.SetHandler(new DefaultHandler(self.application));document.getElementById('Default').className="btn btn-primary btn-sm";} -document.getElementById('AddGraph').onclick=function() -{userAction(this.id);self.restButtons('AddGraph');self.application.SetHandler(document.getElementById('AddGraph').className!=""?new AddGraphHandler(self.application):new DefaultHandler(self.application));} -document.getElementById('ConnectGraphs').onclick=function() -{userAction(this.id);self.restButtons('ConnectGraphs');self.application.SetHandler(document.getElementById('ConnectGraphs').className!=""?new ConnectionGraphHandler(self.application):new DefaultHandler(self.application));} -document.getElementById('DeleteObject').onclick=function() -{userAction(this.id);self.restButtons('DeleteObject');self.application.SetHandler(document.getElementById('DeleteObject').className!=""?new DeleteGraphHandler(self.application):new DefaultHandler(self.application));} -document.getElementById('DeleteAll').onclick=function() -{userAction(this.id);var removeAll=new DeleteAllHandler(self.application);removeAll.clear();self.application.ToDefaultStateAndRedraw();} -document.getElementById('SaveGraph').onclick=function() -{userAction(this.id);var savedDialogGraphHandler=new SavedDialogGraphHandler(self.application);savedDialogGraphHandler.show();} -document.getElementById('NewGraph').onclick=function() -{userAction(this.id);var removeAll=new DeleteAllHandler(self.application);removeAll.clear();self.application.ToDefaultStateAndRedraw();self.application.SetDefaultTransformations();} -document.getElementById('SaveGraphImage').onclick=function() -{userAction(this.id);var savedDialogGraphImageHandler=new SavedDialogGraphImageHandler(self.application);savedDialogGraphImageHandler.showWorkspace();} -document.getElementById('SaveFullGraphImage').onclick=function() -{userAction(this.id);var savedDialogGraphImageHandler=new SavedDialogGraphImageHandler(self.application);savedDialogGraphImageHandler.showFullgraph();} -document.getElementById('SavePrintGraphImage').onclick=function() -{userAction(this.id);var savedDialogGraphImageHandler=new SavedDialogGraphImageHandler(self.application);savedDialogGraphImageHandler.showPrint();} -document.getElementById('SaveSvgGraphImage').onclick=function() -{userAction(this.id);var savedDialogGraphImageHandler=new SavedDialogGraphImageHandler(self.application);savedDialogGraphImageHandler.showSvg();} -document.getElementById('Zoom100').onclick=function() -{userAction(this.id);self.application.setCanvasScale(1.0);} -document.getElementById('Zoom50').onclick=function() -{userAction(this.id);self.application.setCanvasScale(50/100);} -document.getElementById('Zoom25').onclick=function() -{userAction(this.id);self.application.setCanvasScale(25/100);} -document.getElementById('ZoomFit').onclick=function() -{userAction(this.id);self.application.OnAutoAdjustViewport();} -document.getElementById('ZoomIn').onclick=function() -{userAction(this.id);self.application.multCanvasScale(1.5);} -document.getElementById('ZoomOut').onclick=function() -{userAction(this.id);self.application.multCanvasScale(1.0/1.5);} -document.getElementById('MoveWorspace').onclick=function() -{userAction(this.id);self.restButtons('Default');self.application.SetHandler(new DefaultHandler(self.application));document.getElementById('Default').className="btn btn-primary btn-sm";} -document.getElementById('SetupVertexStyle').onclick=function() -{userAction(this.id);var setupVertexStyle=new SetupVertexStyle(self.application);setupVertexStyle.show(0);} -document.getElementById('SetupVertexStyleSelected').onclick=function() -{userAction(this.id);var setupVertexStyle=new SetupVertexStyle(self.application);setupVertexStyle.show(1);} -document.getElementById('SetupEdgeStyle').onclick=function() -{userAction(this.id);var setupEdgeStyle=new SetupEdgeStyle(self.application);setupEdgeStyle.show(0);} -document.getElementById('SetupEdgeStyleSelected').onclick=function() -{userAction(this.id);var setupEdgeStyle=new SetupEdgeStyle(self.application);setupEdgeStyle.show(1);} -document.getElementById('SetupBackgroundStyle').onclick=function() -{userAction(this.id);var setupBackgroundStyle=new SetupBackgroundStyle(self.application);setupBackgroundStyle.show();} -document.getElementById('GraphUndo').onclick=function() -{userAction(this.id);self.application.Undo();} -document.getElementById('runUserScript').onclick=function() -{} -document.getElementById('submitUserScript').onclick=function() -{var script=document.getElementById('userScript');var data="message="+script.value+"&";$.ajax({type:"POST",url:"/feedback",data:data});$("#sentAlgorithm").dialog({resizable:false,height:"auto",width:400,modal:true,dialogClass:'EdgeDialog'});} -document.getElementById('devToolsZoom').onclick=function() -{var devTools=document.getElementById('developerTools');if(devTools.hasOwnProperty("isMin")&&!devTools["isMin"]) -{devTools["isMin"]=true;devTools.style.width="30%";} -else -{devTools["isMin"]=false;devTools.style.width="100%";}} -document.getElementById('ExportGraph').onclick=function() -{userAction(this.id);var graphAsString=self.application.graph.SaveToXML("");var savedGraphName=self.application.GetNewGraphName();var element=document.createElement('a');element.setAttribute('href','data:text/plain;charset=utf-8,'+encodeURIComponent(graphAsString));element.setAttribute('download',"graph_"+savedGraphName+".graphml");element.style.display='none';document.body.appendChild(element);element.click();document.body.removeChild(element);} -document.getElementById('ImportGraph').onclick=function() -{userAction(this.id);if(ImportGraphFiles){ImportGraphFiles.click();}} -document.getElementById('openAlgorithmList').onclick=function() -{setTimeout(function() -{var button=document.getElementById('openAlgorithmList');var buttonRect=button.getBoundingClientRect();var algorithmList=document.getElementById('algorithmList');var delta=buttonRect.right-algorithmList.offsetWidth;if(delta<0) -{var value=(delta-4)+"px";algorithmList.style.right=value;} -else -{algorithmList.style.right="0";}},1);} -document.getElementById('Fullscreen').onclick=function() -{var idList=["h1Header","h1Text","navigation","footerContent","bottom_adv"];self.fullscreen=!self.fullscreen -userAction(self.fullscreen?"fullscreen_on":"fullscreen_off");for(var i=0;i','>');pair=pair.replaceAll('<','<');dialogButtons[g_readMatrixHelp]=function(){window.location.assign(g_language=="ru"?"./wiki/Справка/СписокРебер":"./wiki/Help/EdgeList");};dialogButtons[g_fix]=function(){window.location.assign("./create_graph_by_edge_list?pair="+pair);};dialogButtons[g_close]=function(){$(this).dialog("close");};$("#pairErrorInc").dialog({resizable:false,title:g_pairWrongFormat,width:400,modal:true,dialogClass:'EdgeDialog',buttons:dialogButtons,});} -Editor.prototype.ShowAdjacencyMatrixErrorDialog=function(matrix) -{var dialogButtons={};matrixRes=matrix.replace(/\n/g,'%0A');dialogButtons[g_readMatrixHelp]=function(){window.location.assign(g_language=="ru"?"./wiki/Справка/МатрицаСмежности#matrixFormat":"./wiki/Help/AdjacencyMatrix#matrixFormat");};dialogButtons[g_fixMatrix]=function(){window.location.assign("./create_graph_by_matrix?matrix="+matrixRes);};dialogButtons[g_close]=function(){$(this).dialog("close");};$("#matrixError").dialog({resizable:false,title:g_matrixWrongFormat,width:400,modal:true,dialogClass:'EdgeDialog',buttons:dialogButtons,});} -Editor.prototype.SetDefaultHandler=function() -{this.restButtons('Default');this.application.SetHandler(new DefaultHandler(this.application));} -Editor.prototype.OnGraphTypeChanged=function(isMulti) -{$("#CanvasMessage").text(isMulti?g_GraphIsMultiMessage:g_GraphIsGeneralMessage);} -Editor.prototype.updateMessage=function(message) -{$("#message").html(message);} -let DisableEmscripten=false;let PostLoadedCalled=false;let editor=new Editor(document,window);function resizeCanvas() -{var adv=document.getElementById('bottom_info');var canvas=document.getElementById('canvas');canvas.width=document.getElementById('canvasSection').offsetWidth;var mainContainer=document.getElementById('mainContainer');var offset=(mainContainer.offsetTop+mainContainer.offsetHeight)-(canvas.offsetTop+canvas.offsetHeight)+ -($("#footerContent").css("display")==='block'?0:24);canvas.height=$(window).height()-document.getElementById('canvas').offsetTop- -(adv&&$("#bottom_info").css("display")==='block'?document.getElementById('bottom_info').offsetHeight:0)- -($("#footer").css("display")==='block'?document.getElementById('footer').offsetHeight:0)-offset;editor.redraw();} -function touchHandler(event) -{var touches=event.changedTouches,first=touches[0],type="";switch(event.type) -{case"touchstart":type="mousedown";break;case"touchmove":type="mousemove";break;case"touchend":type="mouseup";break;default:return;} -var simulatedEvent=document.createEvent("MouseEvent");simulatedEvent.initMouseEvent(type,true,true,window,1,first.screenX,first.screenY,first.clientX,first.clientY,false,false,false,false,0,null);first.target.dispatchEvent(simulatedEvent);event.preventDefault();} -function handelImportGraph(files){var graphFileToLoad=files[0];var fileReader=new FileReader();fileReader.onload=function(fileLoadedEvent){var textFromFileLoaded=fileLoadedEvent.target.result;console.log(textFromFileLoaded);editor.application.LoadGraphFromString(textFromFileLoaded);ImportGraphFiles.value="";};fileReader.readAsText(graphFileToLoad,"UTF-8");} -function postLoadPage() -{if(!PostLoadedCalled) -{loadTexts();editor.init();PostLoadedCalled=true;}} -$(document).ready(function() -{window.onresize=function(event) -{resizeCanvas();} -document.getElementById('canvas').addEventListener("touchstart",touchHandler,true);document.getElementById('canvas').addEventListener("touchmove",touchHandler,true);document.getElementById('canvas').addEventListener("touchend",touchHandler,true);document.getElementById('canvas').addEventListener("touchcancel",touchHandler,true);var isMobile=navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i);if(!isMobile&&!DisableEmscripten){let fullPathToGraphffoline="features/graphoffline/Graphoffline.Emscripten.js"+"?v="+globalVersion;doIncludeAsync([include(fullPathToGraphffoline),],()=>{Module['onRuntimeInitialized']=onRuntimeInitialized;var process=Module.cwrap('ProcessAlgorithm','string',['string']);function onRuntimeInitialized(){editor.application.setEmscripten(process);}})}});moduleLoader.endCacheLoading(); \ No newline at end of file +moduleLoader.endCacheLoading(); \ No newline at end of file diff --git a/script/pages/create_graph_by_incidence_matrix/api/index.js.cache b/script/pages/create_graph_by_incidence_matrix/api/index.js.cache index 28be5ae..e0a2cb1 100644 --- a/script/pages/create_graph_by_incidence_matrix/api/index.js.cache +++ b/script/pages/create_graph_by_incidence_matrix/api/index.js.cache @@ -1,16 +1,4 @@ -moduleLoader.beginCacheLoading(["/script/shared/utils.js?v=78","/script/entities/graph/api/index.js?v=78","/script/shared/point.js?v=78","/script/entities/edge/api/index.js?v=78","/script/entities/edge/model/BaseEdge.js?v=78","/script/entities/edge/model/EdgeModel.js?v=78","/script/entities/vertex/api/index.js?v=78","/script/entities/vertex/model/BaseVertex.js?v=78","/script/entities/vertex/model/VertexModel.js?v=78","/script/entities/graph/model/Graph.js?v=78","/script/features/draw_graph/api/index.js?v=78","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=78","/script/features/draw_graph/model/EdgeStyle.js?v=78","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=78","/script/features/draw_graph/model/VertexShape.js?v=78","/script/features/draw_graph/model/VertexStyle.js?v=78","/script/features/draw_graph/model/BaseVertexDrawer.js?v=78","/script/features/algorithms/api/index.js?v=78","/script/features/algorithms/model/Algorithms.js?v=78","/script/features/algorithms/model/BaseTraversal.js?v=78","/script/features/base_handler/index.js?v=78","/script/features/default_handler/index.js?v=78","/script/features/add_vertices_handler/index.js?v=78","/script/features/connect_vertices_handler/index.js?v=78","/script/features/delete_objects_handler/index.js?v=78","/script/features/algorithm_handler/index.js?v=78","/script/features/serialization/api/index.js?v=78","/script/features/serialization/model/GraphMLCreator.js?v=78","/script/features/enum_vertices/EnumVertices.js?v=78","/script/pages/editor/model/texts.js?v=78","/script/pages/editor/model/UndoStack.js?v=78","/script/pages/editor/model/DiskSaveLoad.js?v=78","/script/pages/editor/model/Application.js?v=78","/script/pages/editor/ui/ya_metrika.js?v=78","/script/pages/editor/ui/editor.js?v=78","/script/pages/editor/ui/main.js?v=78",]);{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js")]);} -function gEncodeToHTML(str) -{if(typeof str!=='string') -return str;return str.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');} -function gDecodeFromHTML(str) -{if(typeof str!=='string') -return str;return str.replace(/'/g,"'").replace(/"/g,'"').replace(/>/g,'>').replace(/</g,'<').replace(/&/g,'&');} -function FullObjectCopy(obj) -{var newObj=Object.create(Object.getPrototypeOf(obj));return Object.assign(newObj,obj);} -function FullArrayCopy(arr) -{var res=[];arr.forEach(function(element){var copyElement=FullObjectCopy(element);res.push(copyElement);});return res;} -function formatString(string,params){return string.replace(/{(\d+)}/g,(match,index)=>{return typeof params[index]!=='undefined'?params[index]:match;});} -Array.prototype.swap=function(x,y){var b=this[x];this[x]=this[y];this[y]=b;return this;} +moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=79","/script/shared/point.js?v=79","/script/entities/edge/api/index.js?v=79","/script/entities/edge/model/BaseEdge.js?v=79","/script/entities/edge/model/EdgeModel.js?v=79","/script/entities/vertex/api/index.js?v=79","/script/entities/vertex/model/BaseVertex.js?v=79","/script/entities/vertex/model/VertexModel.js?v=79","/script/entities/graph/model/Graph.js?v=79",]);{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js")]);} {let modulDir="entities/graph/";doInclude([include("shared/point.js"),include("entities/edge/api/index.js"),include("entities/vertex/api/index.js"),include("model/Graph.js",modulDir)])}function Point(x,y){this.x=x||0;this.y=y||0;};Point.prototype.x=null;Point.prototype.y=null;Point.prototype.add=function(v){return new Point(this.x+v.x,this.y+v.y);};Point.prototype.addValue=function(v){return new Point(this.x+v,this.y+v);};Point.prototype.clone=function(){return new Point(this.x,this.y);};Point.prototype.degreesTo=function(v){var dx=this.x-v.x;var dy=this.y-v.y;var angle=Math.atan2(dy,dx);return angle*(180/Math.PI);};Point.prototype.distance=function(v){return Math.sqrt(this.distanceSqr(v));};Point.prototype.distanceSqr=function(v){var x=this.x-v.x;var y=this.y-v.y;return x*x+y*y;};Point.prototype.equals=function(toCompare){return this.x==toCompare.x&&this.y==toCompare.y;};Point.prototype.interpolate=function(v,f){return new Point((this.x+v.x)*f,(this.y+v.y)*f);};Point.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y);};Point.prototype.normalize=function(thickness){var l=this.length();this.x=this.x/l*thickness;this.y=this.y/l*thickness;return new Point(this.x,this.y);};Point.prototype.normalizeCopy=function(thickness){var l=this.length();return new Point(this.x/l*thickness,this.y/l*thickness);};Point.prototype.orbit=function(origin,arcWidth,arcHeight,degrees){var radians=degrees*(Math.PI/180);this.x=origin.x+arcWidth*Math.cos(radians);this.y=origin.y+arcHeight*Math.sin(radians);};Point.prototype.rotate=function(center,degrees){var radians=degrees*(Math.PI/180);offset=this.subtract(center);this.x=offset.x*Math.cos(radians)-offset.y*Math.sin(radians);this.y=offset.x*Math.sin(radians)+offset.y*Math.cos(radians);this.x=this.x+center.x;this.y=this.y+center.y;return this;};Point.prototype.offset=function(dx,dy){this.x+=dx;this.y+=dy;};Point.prototype.subtract=function(v){return new Point(this.x-v.x,this.y-v.y);};Point.prototype.subtractValue=function(value){return new Point(this.x-value,this.y-value);};Point.prototype.multiply=function(value){return new Point(this.x*value,this.y*value);};Point.prototype.toString=function(){return"(x="+this.x+", y="+this.y+")";};Point.prototype.normal=function(){return new Point(-this.y,this.x);};Point.prototype.min=function(point) {return new Point(Math.min(this.x,point.x),Math.min(this.y,point.y));};Point.prototype.max=function(point) {return new Point(Math.max(this.x,point.x),Math.max(this.y,point.y));};Point.prototype.inverse=function() @@ -611,1417 +599,4 @@ Graph.prototype.makeAllEdgesUndirected=function() {if(this.edges[i].isDirect) {this.edges[i].isDirect=false;}} this.isMultiGraph=this.checkMutiGraph();} -{let modulDir="features/draw_graph/";doInclude([include("model/BaseBackgroundDrawer.js",modulDir),include("model/EdgeStyle.js",modulDir),include("model/BaseEdgeDrawer.js",modulDir),include("model/VertexShape.js",modulDir),include("model/VertexStyle.js",modulDir),include("model/BaseVertexDrawer.js",modulDir)])} -function CommonBackgroundStyle() -{this.commonColor='#ffffff';this.commonOpacity=1.0;this.image=null;} -CommonBackgroundStyle.prototype.Clear=function() -{delete this.commonColor;delete this.commonOpacity;delete this.image;} -CommonBackgroundStyle.prototype.ShouldLoad=function(field) -{return true;} -CommonBackgroundStyle.prototype.saveToJson=function(field) -{return JSON.stringify({commonColor:this.commonColor,commonOpacity:this.commonOpacity,image:this.image!=null?this.image.src:null});} -CommonBackgroundStyle.prototype.loadFromJson=function(json,callbackOnLoaded) -{this.commonColor=json["commonColor"];this.commonOpacity=json["commonOpacity"];this.image=null;if(typeof json["image"]==='string'){this.image=new Image();this.image.onload=function(){callbackOnLoaded();} -this.image.src=json["image"];}} -PrintBackgroundStyle.prototype=Object.create(CommonBackgroundStyle.prototype);function PrintBackgroundStyle() -{CommonBackgroundStyle.apply(this,arguments);this.commonColor='#ffffff';this.commonOpacity=1.0;this.image=null;} -function BaseBackgroundDrawer(context) -{this.context=context;} -BaseBackgroundDrawer.prototype.Draw=function(style,width,height,position,scale) -{var context=this.context;var rect=new Rect(position,position.add(new Point(width/scale,height/scale)));context.clearRect(-rect.minPoint.x,-rect.minPoint.y,rect.size().x+1,rect.size().y+1);var oldOpacity=context.globalAlpha;if(style.commonOpacity>0.0) -{context.globalAlpha=style.commonOpacity;context.fillStyle=style.commonColor;context.fillRect(-rect.minPoint.x,-rect.minPoint.y,rect.size().x+1,rect.size().y+1);this.DrawImage(style,width,height,position,scale);} -context.globalAlpha=oldOpacity;} -BaseBackgroundDrawer.prototype.DrawImage=function(style,width,height,position,scale) -{if(style.image==null){return;} -var context=this.context;context.clearRect(0,0,style.image.width,style.image.height);context.drawImage(style.image,0,0)} -const lineDashTypes=[[],[4,4],[12,12],[16,4,4,4],];const WeightTextCenter=0,WeightTextUp=1;const DefaultFontEdge="px sans-serif",DefaultMainTextFontSizeEdge=16,TopTextFontSizeDeltaEdge=-4;function BaseEdgeStyle() -{this.baseStyles=[];} -BaseEdgeStyle.prototype.GetStyle=function(baseStyle,object) -{this.baseStyles.forEach(function(element){var styleObject=globalApplication.GetStyle("edge",element,object);baseStyle=styleObject.GetStyle(baseStyle,object);});if(this.hasOwnProperty('weightText')) -baseStyle.weightText=this.weightText;if(this.hasOwnProperty('strokeStyle')) -baseStyle.strokeStyle=this.strokeStyle;if(this.hasOwnProperty('fillStyle')) -baseStyle.fillStyle=this.fillStyle;if(this.hasOwnProperty('textPadding')) -baseStyle.textPadding=this.textPadding;if(this.hasOwnProperty('textStrokeWidth')) -baseStyle.textStrokeWidth=this.textStrokeWidth;if(this.hasOwnProperty('lineDash')) -baseStyle.lineDash=this.lineDash;if(this.hasOwnProperty('additionalTextColor')) -baseStyle.additionalTextColor=this.additionalTextColor;if(this.hasOwnProperty('weightPosition')) -baseStyle.weightPosition=this.weightPosition;if(this.hasOwnProperty('mainTextFontSize')) -baseStyle.mainTextFontSize=this.mainTextFontSize;return this.FixNewFields(baseStyle);} -BaseEdgeStyle.prototype.FixNewFields=function(style) -{if(!style.hasOwnProperty('lineDash')) -style.lineDash=0;if(!style.hasOwnProperty('weightPosition')) -style.weightPosition=WeightTextCenter;if(!style.hasOwnProperty('mainTextFontSize')) -style.mainTextFontSize=DefaultMainTextFontSizeEdge;return style;} -BaseEdgeStyle.prototype.Clear=function() -{delete this.weightText;delete this.strokeStyle;delete this.fillStyle;delete this.textPadding;delete this.textStrokeWidth;delete this.lineDash;delete this.additionalTextColor;delete this.weightPosition;delete this.mainTextFontSize;} -BaseEdgeStyle.prototype.ShouldLoad=function(field) -{return field!="baseStyles";} -function CommonEdgeStyle() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#c7b7c7';this.weightText='#f0d543';this.fillStyle='#68aeba';this.textPadding=4;this.textStrokeWidth=2;this.lineDash=0;this.additionalTextColor='#c7b7c7';this.weightPosition=WeightTextCenter;} -CommonEdgeStyle.prototype=Object.create(BaseEdgeStyle.prototype);function CommonPrintEdgeStyle() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#000000';this.weightText='#000000';this.fillStyle='#FFFFFF';this.textPadding=4;this.textStrokeWidth=2;this.baseStyles.push("common");} -CommonPrintEdgeStyle.prototype=Object.create(BaseEdgeStyle.prototype);function SelectedEdgeStyle0() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#f0d543';this.weightText='#f0d543';this.fillStyle='#c7627a';this.baseStyles.push("common");} -SelectedEdgeStyle0.prototype=Object.create(BaseEdgeStyle.prototype);function SelectedEdgeStyle1() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#8FBF83';this.weightText='#8FBF83';this.fillStyle='#F9F9D5';this.baseStyles.push("selected");} -SelectedEdgeStyle1.prototype=Object.create(BaseEdgeStyle.prototype);function SelectedEdgeStyle2() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#8C4C86';this.weightText='#8C4C86';this.fillStyle='#253267';this.baseStyles.push("selected");} -SelectedEdgeStyle2.prototype=Object.create(BaseEdgeStyle.prototype);function SelectedEdgeStyle3() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#6188FF';this.weightText='#6188FF';this.fillStyle='#E97CF9';this.baseStyles.push("selected");} -SelectedEdgeStyle3.prototype=Object.create(BaseEdgeStyle.prototype);function SelectedEdgeStyle4() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#C6B484';this.weightText='#C6B484';this.fillStyle='#E0DEE1';this.baseStyles.push("selected");} -SelectedEdgeStyle4.prototype=Object.create(BaseEdgeStyle.prototype);function SelectedEdgePrintStyle() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#AAAAAA';this.weightText='#000000';this.fillStyle='#AAAAAA';this.baseStyles.push("printed");} -SelectedEdgePrintStyle.prototype=Object.create(BaseEdgeStyle.prototype);var DefaultSelectedEdgeStyles=[new SelectedEdgeStyle0(),new SelectedEdgeStyle1(),new SelectedEdgeStyle2(),new SelectedEdgeStyle3(),new SelectedEdgeStyle4()];var DefaultPrintSelectedEdgeStyles=[new SelectedEdgePrintStyle()];function BaseEdgeDrawer(context,drawObjects) -{if(drawObjects===undefined) -{drawObjects=null;} -this.context=context;this.drawObject=null;this.drawArc=null;this.startArrowDirection=null;this.finishArrowDirection=null;this.textCenterObject=null;this.getPointOnArc=null;if(drawObjects) -{if(drawObjects.hasOwnProperty("drawObject")) -this.drawObject=drawObjects.drawObject;if(drawObjects.hasOwnProperty("drawArc")) -this.drawArc=drawObjects.drawArc;if(drawObjects.hasOwnProperty("startArrowDirection")) -this.startArrowDirection=drawObjects.startArrowDirection;if(drawObjects.hasOwnProperty("finishArrowDirection")) -this.finishArrowDirection=drawObjects.finishArrowDirection;if(drawObjects.hasOwnProperty("textCenterObject")) -this.textCenterObject=drawObjects.textCenterObject;if(drawObjects.hasOwnProperty("getPointOnArc")) -this.getPointOnArc=drawObjects.getPointOnArc;}} -BaseEdgeDrawer.prototype.Draw=function(baseEdge,arcStyle) -{if(this.drawObject&&this.drawObject!=this) -{this.drawObject.Draw(baseEdge,arcStyle);return;} -this.SetupStyle(baseEdge,arcStyle);var lengthArrow=Math.max(baseEdge.model.width*4,8);var widthArrow=Math.max(baseEdge.model.width*2,4);var position1=baseEdge.vertex1.position;var position2=baseEdge.vertex2.position;var direction=position1.subtract(position2);direction.normalize(1.0);var positions=baseEdge.GetEdgePositionsShift();var hasStartStyle=!position1.equals(position2)&&baseEdge.GetStartEdgeStyle()!="";var hasFinishStyle=!position1.equals(position2)&&baseEdge.GetFinishEdgeStyle()!="";var arcPos1=positions[0];var arcPos2=positions[1];if(hasStartStyle) -{var dirArrow=this.GetStartArrowDirection(positions[0],positions[1],lengthArrow);arcPos1=arcPos1.add(dirArrow.multiply(lengthArrow/2));} -if(hasFinishStyle) -{var dirArrow=this.GetFinishArrowDirection(positions[0],positions[1],lengthArrow);arcPos2=arcPos2.add(dirArrow.multiply(-lengthArrow/2));} -this.DrawArc(arcPos1,arcPos2,arcStyle);this.context.fillStyle=this.context.strokeStyle;this.context.lineWidth=0;if(hasStartStyle) -{this.DrawArrow(positions[0],this.GetStartArrowDirection(positions[0],positions[1],lengthArrow),lengthArrow,widthArrow);} -if(hasFinishStyle) -{this.DrawArrow(positions[1],this.GetFinishArrowDirection(positions[0],positions[1],lengthArrow),lengthArrow,widthArrow);} -this.SetupStyle(baseEdge,arcStyle);if(arcStyle.weightPosition==WeightTextCenter) -{if(baseEdge.GetText().length>0) -{this.DrawWeight(positions[0],positions[1],baseEdge.GetText(),arcStyle,false);} -if(baseEdge.GetUpText().length>0) -{this.DrawUpText(positions[0],positions[1],baseEdge.GetUpText(),arcStyle,false,arcStyle.additionalTextColor,baseEdge.model.width/2+arcStyle.mainTextFontSize+4,arcStyle.mainTextFontSize);}} -else if(arcStyle.weightPosition==WeightTextUp) -{if(baseEdge.GetText().length>0) -{this.DrawUpText(positions[0],positions[1],baseEdge.GetText(),arcStyle,false,arcStyle.weightText,baseEdge.model.width/2+arcStyle.mainTextFontSize/2,arcStyle.mainTextFontSize);} -if(baseEdge.GetUpText().length>0) -{this.DrawUpText(positions[0],positions[1],baseEdge.GetUpText(),arcStyle,false,arcStyle.additionalTextColor,-baseEdge.model.width/2-(arcStyle.mainTextFontSize/2+4),arcStyle.mainTextFontSize);}}} -BaseEdgeDrawer.prototype.SetupStyle=function(baseEdge,arcStyle) -{this.context.lineWidth=baseEdge.model.width;this.context.strokeStyle=arcStyle.strokeStyle;this.context.fillStyle=arcStyle.fillStyle;this.model=baseEdge.model;this.style=arcStyle;} -BaseEdgeDrawer.prototype.DrawArc=function(position1,position2,arcStyle) -{if(this.drawArc&&this.drawArc!=this) -{this.drawArc.DrawArc(position1,position2,arcStyle);return;} -this.context.setLineDash(lineDashTypes[arcStyle.lineDash]);if(position1.equals(position2)) -{this.context.beginPath();this.context.arc(position1.x-Math.cos(this.model.GetLoopShiftAngel())*this.model.GetLoopSize(),position1.y-Math.sin(this.model.GetLoopShiftAngel())*this.model.GetLoopSize(),this.model.GetLoopSize(),0,2*Math.PI);this.context.stroke();} -else -{this.context.beginPath();this.context.moveTo(position1.x,position1.y);this.context.lineTo(position2.x,position2.y);this.context.stroke();} -this.context.setLineDash([]);} -BaseEdgeDrawer.prototype.DrawWeight=function(position1,position2,text,arcStyle,hasPair) -{var centerPoint=this.GetTextCenterPoint(position1,position2,hasPair,arcStyle);this.context.font="bold "+arcStyle.mainTextFontSize+"px sans-serif";this.context.textBaseline="middle";this.context.lineWidth=arcStyle.textStrokeWidth;this.context.fillStyle=arcStyle.fillStyle;var widthText=this.context.measureText(text).width;this.context.beginPath();this.context.rect(centerPoint.x-widthText/2-arcStyle.textPadding/2,centerPoint.y-arcStyle.mainTextFontSize/1.7-arcStyle.textPadding/2,widthText+arcStyle.textPadding,arcStyle.mainTextFontSize+arcStyle.textPadding);this.context.closePath();this.context.fill();this.context.stroke();this.context.fillStyle=arcStyle.weightText;this.context.fillText(text,centerPoint.x-widthText/2,centerPoint.y);} -BaseEdgeDrawer.prototype.DrawUpText=function(position1,position2,text,arcStyle,hasPair,color,offset,fontSize) -{var centerPoint=this.GetTextCenterPoint(position1,position2,hasPair,arcStyle);this.context.font=fontSize==null?"bold "+(DefaultMainTextFontSizeEdge+TopTextFontSizeDeltaEdge)+"px sans-serif":"bold "+(fontSize+TopTextFontSizeDeltaEdge)+"px sans-serif";this.context.textBaseline="middle";var widthText=this.context.measureText(text).width;this.context.fillStyle=color;var vectorEdge=new Point(position2.x-position1.x,position2.y-position1.y);var angleRadians=Math.atan2(vectorEdge.y,vectorEdge.x);if(angleRadians>Math.PI/2||angleRadians<-Math.PI/2) -{vectorEdge=new Point(position1.x-position2.x,position1.y-position2.y);angleRadians=Math.atan2(vectorEdge.y,vectorEdge.x);} -var normalize=vectorEdge.normal().normalizeCopy(offset);this.context.save();this.context.translate(centerPoint.x-normalize.x,centerPoint.y-normalize.y);this.context.rotate(angleRadians);this.context.textAlign="center";this.context.fillText(text,0,0);this.context.restore();} -BaseEdgeDrawer.prototype.DrawArrow=function(position,direction,length,width) -{var normal=direction.normal();var pointOnLine=position.subtract(direction.multiply(length));var point1=pointOnLine.add(normal.multiply(width));var point2=pointOnLine.add(normal.multiply(-width));this.context.beginPath();this.context.moveTo(position.x,position.y);this.context.lineTo(point1.x,point1.y);this.context.lineTo(point2.x,point2.y);this.context.lineTo(position.x,position.y);this.context.closePath();this.context.fill();} -BaseEdgeDrawer.prototype.GetStartArrowDirection=function(position1,position2,lengthArrow) -{if(this.startArrowDirection&&this.startArrowDirection!=this) -{return this.startArrowDirection.GetStartArrowDirection(position1,position2,lengthArrow);} -var direction=position1.subtract(position2);direction.normalize(1.0);return direction;} -BaseEdgeDrawer.prototype.GetFinishArrowDirection=function(position1,position2,lengthArrow) -{if(this.finishArrowDirection&&this.finishArrowDirection!=this) -{return this.finishArrowDirection.GetFinishArrowDirection(position1,position2,lengthArrow);} -var direction=position2.subtract(position1);direction.normalize(1.0);return direction;} -BaseEdgeDrawer.prototype.GetTextCenterPoint=function(position1,position2,hasPair,arcStyle) -{if(this.textCenterObject&&this.textCenterObject!=this) -{return this.textCenterObject.GetTextCenterPoint(position1,position2,hasPair,arcStyle);} -var textShift=Math.min(12/position1.subtract(position2).length(),0.4);var centerPoint=Point.interpolate(position1,position2,0.5);if(position1.equals(position2)) -{let sinVal=Math.sin(this.model.GetLoopShiftAngel());let cosVal=Math.cos(this.model.GetLoopShiftAngel());centerPoint.x=centerPoint.x-cosVal*this.model.GetLoopSize();centerPoint.y=centerPoint.y-(sinVal+Math.sign(sinVal)*1.0)*this.model.GetLoopSize();} -return centerPoint;} -BaseEdgeDrawer.prototype.GetPointOnArc=function(position1,position2,percent) -{if(this.getPointOnArc&&this.getPointOnArc!=this) -{return this.getPointOnArc.GetPointOnArc(position1,position2,percent);} -return Point.interpolate(position1,position2,percent);} -function ProgressArcDrawer(context,baseDrawer,progress) -{this.context=context;this.baseDrawer=baseDrawer;this.progress=progress;} -ProgressArcDrawer.prototype=Object.create(BaseEdgeDrawer.prototype);ProgressArcDrawer.prototype.Draw=function(baseEdge,arcStyle) -{this.baseDrawer.Draw(baseEdge,arcStyle);this.context.lineWidth=10;var positions=baseEdge.GetEdgePositionsShift();var progressSize=10;if(positions[0].equals(positions[1])) -{var sizeInRadian=progressSize/(2*Math.PI*this.baseDrawer.model.GetLoopSize())*6;this.context.beginPath();this.context.arc(positions[0].x-Math.cos(this.baseDrawer.model.GetLoopShiftAngel())*this.baseDrawer.model.GetLoopSize(),positions[0].y-Math.sin(this.baseDrawer.model.GetLoopShiftAngel())*this.baseDrawer.model.GetLoopSize(),this.baseDrawer.model.GetLoopSize(),this.progress*2*Math.PI,this.progress*2*Math.PI+sizeInRadian);this.context.stroke();} -else -{var startPosition=this.baseDrawer.GetPointOnArc(positions[0],positions[1],this.progress);var vectorOffset=positions[0].subtract(positions[1]).normalizeCopy(progressSize);var finishPosition=startPosition.add(vectorOffset);this.context.beginPath();this.context.moveTo(startPosition.x,startPosition.y);this.context.lineTo(finishPosition.x,finishPosition.y);this.context.stroke();}} -function CurvedArcDrawer(context,model) -{this.context=context;this.model=model;} -CurvedArcDrawer.prototype=Object.create(BaseEdgeDrawer.prototype);CurvedArcDrawer.prototype.DrawArc=function(position1,position2,arcStyle) -{this.context.setLineDash(lineDashTypes[arcStyle.lineDash]);if(position1.equals(position2)) -{this.context.beginPath();this.context.arc(position1.x-Math.cos(this.model.GetLoopShiftAngel())*this.model.GetLoopSize(),position1.y-Math.sin(this.model.GetLoopShiftAngel())*this.model.GetLoopSize(),this.model.GetLoopSize(),0,2*Math.PI);this.context.closePath();this.context.stroke();} -else -{var points=this.model.GetBezierPoints(position1,position2);var firstBezierPoint=points[0];var secondBezierPoint=points[1];this.context.beginPath();this.context.moveTo(position1.x,position1.y);this.context.bezierCurveTo(firstBezierPoint.x,firstBezierPoint.y,secondBezierPoint.x,secondBezierPoint.y,position2.x,position2.y);this.context.stroke();} -this.context.setLineDash([]);} -CurvedArcDrawer.prototype.GetStartArrowDirection=function(position1,position2,lengthArrow) -{var dist=position1.distance(position2);var direction=position1.subtract(this.model.GetCurvePoint(position1,position2,lengthArrow/dist));direction.normalize(1.0);return direction;} -CurvedArcDrawer.prototype.GetFinishArrowDirection=function(position1,position2,lengthArrow) -{var dist=position1.distance(position2);var direction=position2.subtract(this.model.GetCurvePoint(position1,position2,1.0-lengthArrow/dist));direction.normalize(1.0);return direction;} -CurvedArcDrawer.prototype.GetTextCenterPoint=function(position1,position2,hasPair,arcStyle) -{var centerPoint=this.model.GetCurvePoint(position1,position2,0.5) -if(position1.equals(position2)) -{let sinVal=Math.sin(this.model.GetLoopShiftAngel());let cosVal=Math.cos(this.model.GetLoopShiftAngel());centerPoint.x=centerPoint.x-cosVal*this.model.GetLoopSize();centerPoint.y=centerPoint.y-(sinVal+Math.sign(sinVal)*1.0)*this.model.GetLoopSize();} -return centerPoint;} -CurvedArcDrawer.prototype.GetPointOnArc=function(position1,position2,percent) -{return this.model.GetCurvePoint(position1,position2,percent);} -const VertexCircleShape=0,VertexSquareShape=1,VertexTriangleShape=2,VertexPentagonShape=3,VertexHomeShape=4,VertexTextboxShape=5;VertexSnowflakeShape=6;function GetSquarePoints(diameter) -{var res=[];var a=diameter;res.push(new Point(-a/2,-a/2));res.push(new Point(a/2,-a/2));res.push(new Point(a/2,a/2));res.push(new Point(-a/2,a/2));return res;} -function GetTrianglePoints(diameter) -{var res=[];var effectiveDiameter=diameter*1.5;var upOffset=effectiveDiameter/2;var downOffset=effectiveDiameter/4;var lrOffset=effectiveDiameter*3/(Math.sqrt(3)*4);res.push(new Point(0,-upOffset));res.push(new Point(lrOffset,downOffset));res.push(new Point(-lrOffset,downOffset));return res;} -function GetPentagonPoints(diameter) -{var res=[];var baseValue=diameter/2*1.2;res.push(new Point(0,-baseValue));res.push((new Point(0,-baseValue)).rotate(new Point(0,0),72));res.push((new Point(0,-baseValue)).rotate(new Point(0,0),72*2));res.push((new Point(0,-baseValue)).rotate(new Point(0,0),72*3));res.push((new Point(0,-baseValue)).rotate(new Point(0,0),72*4));res.push((new Point(0,-baseValue)).rotate(new Point(0,0),72*5));return res;} -function GetTextboxPoints(diameter,additional_data) -{var res=[];var width=diameter;var height=diameter;if(additional_data) -{var tempContext=document.createElement('canvas').getContext('2d');tempContext.font="bold "+additional_data.style.mainTextFontSize+ -DefaultFont;let metrics=tempContext.measureText(additional_data.text);width=metrics.width+diameter/2;let actualHeight=metrics.actualBoundingBoxAscent*1.6;height=Math.max(height,actualHeight);} -res.push(new Point(-width/2,-height/2));res.push(new Point(width/2,-height/2));res.push(new Point(width/2,height/2));res.push(new Point(-width/2,height/2));return res;} -function GetShowflakePoints(diameter) -{var res=[];var superSmallRadius=diameter*0.8/2;var smallRadius=diameter*0.95/2;var bigRadius=diameter*1.5/2;let angel=8;res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),-angel));res.push(new Point(smallRadius,0));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),angel));res.push(new Point(bigRadius,0).rotate(new Point(0,0),30));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60-angel));res.push(new Point(smallRadius,0).rotate(new Point(0,0),60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+angel));res.push(new Point(bigRadius,0).rotate(new Point(0,0),30+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60-angel));res.push(new Point(smallRadius,0).rotate(new Point(0,0),60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+angel));res.push(new Point(bigRadius,0).rotate(new Point(0,0),30+60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+60-angel));res.push(new Point(smallRadius,0).rotate(new Point(0,0),60+60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+60+angel));res.push(new Point(bigRadius,0).rotate(new Point(0,0),30+60+60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+60+60-angel));res.push(new Point(smallRadius,0).rotate(new Point(0,0),60+60+60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+60+60+angel));res.push(new Point(bigRadius,0).rotate(new Point(0,0),30+60+60+60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+60+60+60-angel));res.push(new Point(smallRadius,0).rotate(new Point(0,0),60+60+60+60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+60+60+60+angel));res.push(new Point(bigRadius,0).rotate(new Point(0,0),30+60+60+60+60+60));return res;} -function GetPointsForShape(shape,diameter,additional_data=null) -{switch(parseInt(shape)) -{case VertexSquareShape:return GetSquarePoints(diameter);break;case VertexTriangleShape:return GetTrianglePoints(diameter);break;case VertexPentagonShape:return GetPentagonPoints(diameter);break;case VertexTextboxShape:return GetTextboxPoints(diameter,additional_data);break;case VertexSnowflakeShape:return GetShowflakePoints(diameter);break;default:return null;break;}} -function GetSizeForShape(shape,diameter) -{switch(parseInt(shape)) -{case VertexSquareShape:return diameter;break;case VertexTriangleShape:return diameter*1.5;break;case VertexPentagonShape:return diameter*1.2;break;case VertexTextboxShape:return diameter;break;case VertexSnowflakeShape:return diameter*1.5;break;default:return diameter;break;}} -const CommonTextCenter=0,CommonTextUp=1;const DefaultFont="px sans-serif",DefaultMainTextFontSize=16,TopTextFontSizeDelta=-4;function BaseVertexStyle() -{this.baseStyles=[];} -BaseVertexStyle.prototype.GetStyle=function(baseStyle,object) -{this.baseStyles.forEach(function(element){var styleObject=globalApplication.GetStyle("vertex",element,object);baseStyle=styleObject.GetStyle(baseStyle,object);});if(this.hasOwnProperty('lineWidth')) -baseStyle.lineWidth=this.lineWidth;if(this.hasOwnProperty('strokeStyle')) -baseStyle.strokeStyle=this.strokeStyle;if(this.hasOwnProperty('fillStyle')) -baseStyle.fillStyle=this.fillStyle;if(this.hasOwnProperty('mainTextColor')) -baseStyle.mainTextColor=this.mainTextColor;if(this.hasOwnProperty('shape')) -baseStyle.shape=this.shape;if(this.hasOwnProperty('upTextColor')) -baseStyle.upTextColor=this.upTextColor;if(this.hasOwnProperty('commonTextPosition')) -baseStyle.commonTextPosition=this.commonTextPosition;if(this.hasOwnProperty('mainTextFontSize')) -baseStyle.mainTextFontSize=this.mainTextFontSize;baseStyle.lineWidth=parseInt(baseStyle.lineWidth);return this.FixNewFields(baseStyle);} -BaseVertexStyle.prototype.FixNewFields=function(style) -{if(!style.hasOwnProperty('shape')) -style.shape=VertexCircleShape;if(!style.hasOwnProperty('commonTextPosition')) -style.commonTextPosition=CommonTextCenter;if(!style.hasOwnProperty('mainTextFontSize')) -style.mainTextFontSize=DefaultMainTextFontSize;return style;} -BaseVertexStyle.prototype.Clear=function() -{delete this.lineWidth;delete this.strokeStyle;delete this.fillStyle;delete this.mainTextColor;delete this.shape;delete this.upTextColor;delete this.commonTextPosition;delete this.lineWidth;delete this.mainTextFontSize;} -BaseVertexStyle.prototype.ShouldLoad=function(field) -{return field!="baseStyles";} -function CommonVertexStyle() -{BaseVertexStyle.apply(this,arguments);this.lineWidth=2;this.strokeStyle='#c7b7c7';this.fillStyle='#68aeba';this.mainTextColor='#f0d543';this.shape=VertexCircleShape;this.upTextColor='#68aeba';this.commonTextPosition=CommonTextCenter;this.baseStyles=[];} -CommonVertexStyle.prototype=Object.create(BaseVertexStyle.prototype);function CommonPrintVertexStyle() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#000000';this.fillStyle='#FFFFFF';this.mainTextColor='#000000';this.baseStyles.push("common");} -CommonPrintVertexStyle.prototype=Object.create(BaseVertexStyle.prototype);function SelectedVertexStyle0() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#f0d543';this.mainTextColor='#f0d543';this.fillStyle='#c7627a';this.baseStyles.push("common");} -SelectedVertexStyle0.prototype=Object.create(BaseVertexStyle.prototype);function SelectedVertexStyle1() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#7a9ba0';this.mainTextColor='#c3d2d5';this.fillStyle='#534641';this.baseStyles.push("selected");} -SelectedVertexStyle1.prototype=Object.create(BaseVertexStyle.prototype);function SelectedVertexStyle2() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#8C4C86';this.mainTextColor='#dbbdd8';this.fillStyle='#253267';this.baseStyles.push("selected");} -SelectedVertexStyle2.prototype=Object.create(BaseVertexStyle.prototype);function SelectedVertexStyle3() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#6188FF';this.mainTextColor='#6188FF';this.fillStyle='#E97CF9';this.baseStyles.push("selected");} -SelectedVertexStyle3.prototype=Object.create(BaseVertexStyle.prototype);function SelectedVertexStyle4() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#C6B484';this.mainTextColor='#C6B484';this.fillStyle='#E0DEE1';this.baseStyles.push("selected");} -SelectedVertexStyle4.prototype=Object.create(BaseVertexStyle.prototype);function SelectedPrintVertexStyle() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#000000';this.mainTextColor='#000000';this.fillStyle='#AAAAAA';this.baseStyles.push("printed");} -SelectedPrintVertexStyle.prototype=Object.create(BaseVertexStyle.prototype);var DefaultSelectedGraphStyles=[new SelectedVertexStyle0(),new SelectedVertexStyle1(),new SelectedVertexStyle2(),new SelectedVertexStyle3(),new SelectedVertexStyle4()];var DefaultPrintSelectedGraphStyles=[new SelectedPrintVertexStyle()];function BaseVertexDrawer(context) -{this.context=context;} -BaseVertexDrawer.prototype.Draw=function(baseGraph,graphStyle) -{this.SetupStyle(graphStyle);this.DrawShape(baseGraph);if(this.currentStyle.lineWidth!=0) -this.context.stroke();this.context.fill();var shapeSize=GetSizeForShape(graphStyle.shape,baseGraph.model.diameter+graphStyle.lineWidth);if(graphStyle.commonTextPosition==CommonTextCenter) -{this.DrawCenterText(baseGraph.position,baseGraph.mainText,graphStyle.mainTextColor,graphStyle.fillStyle,true,true,graphStyle.mainTextFontSize);this.DrawCenterText(baseGraph.position.add(new Point(0,-shapeSize/2.0-graphStyle.mainTextFontSize/2.2)),baseGraph.upText,graphStyle.upTextColor,graphStyle.strokeStyle,false,false,graphStyle.mainTextFontSize+TopTextFontSizeDelta);} -else if(graphStyle.commonTextPosition==CommonTextUp) -{this.DrawCenterText(baseGraph.position.add(new Point(0,-shapeSize/2.0-graphStyle.mainTextFontSize/2.2)),baseGraph.mainText,graphStyle.mainTextColor,graphStyle.fillStyle,true,false,graphStyle.mainTextFontSize);this.DrawCenterText(baseGraph.position.add(new Point(0,shapeSize/2.0+graphStyle.mainTextFontSize/1.7)),baseGraph.upText,graphStyle.upTextColor,graphStyle.strokeStyle,false,false,graphStyle.mainTextFontSize+TopTextFontSizeDelta);}} -BaseVertexDrawer.prototype.SetupStyle=function(style) -{this.currentStyle=style;this.context.lineWidth=style.lineWidth;this.context.strokeStyle=style.strokeStyle;this.context.fillStyle=style.fillStyle;} -BaseVertexDrawer.prototype.DrawShape=function(baseGraph) -{this.context.beginPath();if(this.currentStyle.shape==VertexCircleShape) -{this.context.arc(baseGraph.position.x,baseGraph.position.y,baseGraph.model.diameter/2.0,0,2*Math.PI);} -else -{var points=GetPointsForShape(this.currentStyle.shape,baseGraph.model.diameter,{style:this.currentStyle,text:baseGraph.mainText});this.context.moveTo(baseGraph.position.x+points[points.length-1].x,baseGraph.position.y+points[points.length-1].y);var context=this.context;points.forEach(function(point){context.lineTo(baseGraph.position.x+point.x,baseGraph.position.y+point.y);});} -this.context.closePath();} -BaseVertexDrawer.prototype.DrawText=function(position,text,color,outlineColor,outline,font) -{this.context.fillStyle=color;this.context.font=font;this.context.lineWidth=4;this.context.strokeStyle=outlineColor;if(outline) -{this.context.save();this.context.lineJoin='round';this.context.strokeText(text,position.x,position.y);this.context.restore();} -this.context.fillText(text,position.x,position.y);} -BaseVertexDrawer.prototype.DrawCenterText=function(position,text,color,outlineColor,bold,outline,size) -{this.context.textBaseline="middle";this.context.font=(bold?"bold ":"")+size+DefaultFont;var textWidth=this.context.measureText(text).width;this.DrawText(new Point(position.x-textWidth/2,position.y),text,color,outlineColor,outline,this.context.font);} -{let modulDir="features/algorithms/";doInclude([include("model/Algorithms.js",modulDir),include("model/BaseTraversal.js",modulDir)]) -function loadAsyncAlgorithms(onFinish){let modulDir="features/algorithms/";let pluginsList=["BFS.js","Coloring.js","ConnectedComponent.js","DFS.js","EulerianLoop.js","EulerianPath.js","FindAllPatches.js","FindLongestPath.js","FindShortPatchsFromOne.js","Floid.js","GraphReorder.js","HamiltonianLoop.js","HamiltonianPath.js","IsomorphismCheck.js","MaxClique.js","MaxFlow.js","MinimumSpanningTree.js","ModernGraphStyle.js","RadiusAndDiameter.js","ShortestPath.js","VerticesDegree.js"];doIncludeAsync(pluginsList.map((plugin)=>include("model/plugins/"+plugin+"?v="+globalVersion,modulDir)),onFinish);}} -function getVertexToVertexArray(graph,ignoreDirection) -{res={};for(var i=0;iprocessData+=delimiter+param.name+delimiter+param.value);var res=this.app.processEmscripten(processData);processResult(res);}else{console.log("Use new CGI");var queryString=algorithmName+"=cgiInput&report=xml";otherParams.forEach((param)=>queryString+="&"+param.name+"="+param.value);$.ajax({type:"POST",url:"/"+SiteDir+"cgi-bin/GraphCGI.exe?"+queryString,data:xml,dataType:"text",}).done(function(msg) -{processResult(msg);});} -return true;} -BaseAlgorithmEx.prototype.GetNodesPath=function(array,start,count) -{var res=[];for(var index=start;index"+"";for(var i=0;i";} -return res+"";} -BaseHandler.prototype.GetSelect2VertexMenu=function() -{return""+ -this.GetSelectVertexMenu("Vertex1")+" → "+this.GetSelectVertexMenu("Vertex2")+"";} -BaseHandler.prototype.SelectFirstVertexMenu=function(vertex1Text,vertex) -{} -BaseHandler.prototype.UpdateFirstVertexMenu=function() -{} -BaseHandler.prototype.SelectSecondVertexMenu=function(vertex2Text,vertex) -{} -BaseHandler.prototype.UpdateSecondVertexMenu=function() -{} -BaseHandler.prototype.GetSelectedVertex=function() -{return null;} -BaseHandler.prototype.addContextMenu=function() -{var $contextMenu=$("#contextMenu");var handler=this;$("#Context_Delete").click(function(){if(handler.contextMenuObject!=null){handler.app.PushToStack("DeleteObject");handler.app.DeleteObject(handler.contextMenuObject);handler.app.redrawGraph();userAction("DeleteObject_contextMenu");}});$("#Context_Rename").click(function(){if(handler.contextMenuObject!=null){var callback=function(enumType){handler.RenameVertex(enumType.GetVertexText(0),handler.contextMenuObject);userAction("RenameVertex_contextMenu");};var customEnum=new TextEnumVerticesCustom(handler.app);customEnum.ShowDialog(callback,g_rename,g_renameVertex,handler.contextMenuObject.mainText);}});$("#Context_Connect").click(function(){if(handler.contextMenuObject!=null&&handler.GetSelectedVertex()!=null){var addFunc=function(firstVertex,secondVertex,direct){handler.app.CreateNewArc(firstVertex,secondVertex,direct,document.getElementById('EdgeWeight').value,$("#RadiosReplaceEdge").prop("checked"),document.getElementById('EdgeLable').value);handler.app.redrawGraph();} -handler.ShowCreateEdgeDialog(handler.GetSelectedVertex(),handler.contextMenuObject,addFunc);}});$("#Context_Delete_Edge").click(function(){if(handler.contextMenuObject!=null){handler.app.PushToStack("DeleteObject");handler.app.DeleteObject(handler.contextMenuObject);handler.app.redrawGraph();userAction("DeleteObject_contextMenu");}});$("#Context_Edit_Edge").click(function(){if(handler.contextMenuObject!=null){handler.ShowEditEdgeDialog(handler.contextMenuObject);}});$("#Context_Add_Vertex").click(function(){handler.app.PushToStack("Add");handler.app.CreateNewGraph(handler.contextMenuPoint.x,handler.contextMenuPoint.y);handler.app.redrawGraph();});$("#Context_Back_Color").click(function(){var setupBackgroundStyle=new SetupBackgroundStyle(handler.app);setupBackgroundStyle.show();});$("body").on("contextmenu","canvas",function(e){handler.contextMenuPoint=handler.app.getMousePos(handler.app.canvas,e);handler.contextMenuObject=handler.GetSelectedObject(handler.contextMenuPoint);if(handler.contextMenuObject instanceof BaseVertex){$("#edgeContextMenu").hide();$("#backgroundContextMenu").hide();$("#vertexContextMenu").show();if(handler.GetSelectedVertex()==null){$("#Context_Connect").hide();}else{$("#Context_Connect").show();}}else if(handler.contextMenuObject instanceof BaseEdge){$("#vertexContextMenu").hide();$("#backgroundContextMenu").hide();$("#edgeContextMenu").show();}else{$("#vertexContextMenu").hide();$("#edgeContextMenu").hide();$("#backgroundContextMenu").show();} -$contextMenu.css({display:"block",left:e.offsetX,top:e.offsetY});return false;});$("body").click(function(){$contextMenu.hide();});} -BaseHandler.prototype.removeContextMenu=function() -{$("body").off("contextmenu");$("#Context_Delete").off("click");$("#Context_Rename").off("click");$("#Context_Connect").off("click");$("#Context_Delete_Edge").off("click");$("#Context_Edit_Edge").off("click");$("#Context_Add_Vertex").off("click");$("#Context_Back_Color").off("click");} -BaseHandler.prototype.RenameVertex=function(text,object) -{if(object!=null&&(object instanceof BaseVertex)) -{this.app.PushToStack("RenameVertex");object.mainText=text;this.app.redrawGraph();}} -BaseHandler.prototype.ShowCreateEdgeDialog=function(firstVertex,secondVertex,addEdgeCallBack){if(!this.app.graph.isMulti()) -{var hasEdge=this.app.graph.FindEdgeAny(firstVertex.id,secondVertex.id);var hasReverseEdge=this.app.graph.FindEdgeAny(secondVertex.id,firstVertex.id);if(hasEdge==null&&hasReverseEdge==null) -{$("#RadiosReplaceEdge").prop("checked",true);$("#NewEdgeAction").hide();} -else{$("#NewEdgeAction").show();}} -else -{$("#RadiosAddEdge").prop("checked",true);$("#NewEdgeAction").hide();} -var dialogButtons={};var handler=this;$("#CheckSaveDefaultEdge").prop("checked",false);$("#defaultEdgeDialogBlock").show();dialogButtons[g_orintEdge]=function(){handler.app.PushToStack("Connect");addEdgeCallBack(firstVertex,secondVertex,true);$(this).dialog("close");};dialogButtons[g_notOrintEdge]=function(){handler.app.PushToStack("Connect");addEdgeCallBack(firstVertex,secondVertex,false);$(this).dialog("close");};var edgePresets=this.app.GetEdgePresets();var presetsStr=""+g_DefaultWeightPreset+"";for(var i=0;i"+edgePreset+"";} -document.getElementById("EdgesPresets").innerHTML=presetsStr;document.getElementById('EdgeLable').value="";$("#addEdge").dialog({resizable:false,height:"auto",width:"auto",modal:true,title:g_addEdge,buttons:dialogButtons,dialogClass:'EdgeDialog',open:function(){$(this).off('submit').on('submit',function(){return false;});setTimeout(function(){const weightInput=document.getElementById('EdgeWeight');if(weightInput) -{weightInput.focus();weightInput.select();}},0);}});} -BaseHandler.prototype.ShowEditEdgeDialog=function(edgeObject){var dialogButtons={};var handler=this;dialogButtons[g_save]=function(){handler.app.PushToStack("ChangeEdge");edgeObject.SetWeight(document.getElementById('EdgeWeight').value);edgeObject.SetUpText(document.getElementById('EdgeLable').value);handler.needRedraw=true;handler.app.redrawGraph();userAction("ChangeWeight");$(this).dialog("close");};document.getElementById('EdgeWeight').value=edgeObject.useWeight?edgeObject.weight:g_noWeight;document.getElementById('EdgeWeightSlider').value=edgeObject.useWeight?edgeObject.weight:0;var edgePresets=handler.app.GetEdgePresets();var presetsStr=""+g_DefaultWeightPreset+"";for(var i=0;i"+edgePreset+"";} -document.getElementById("EdgesPresets").innerHTML=presetsStr;document.getElementById('EdgeLable').value=edgeObject.upText;$("#CheckSaveDefaultEdge").prop("checked",false);$("#defaultEdgeDialogBlock").hide();$("#addEdge").dialog({resizable:false,height:"auto",width:"auto",modal:true,title:g_editWeight,buttons:dialogButtons,dialogClass:'EdgeDialog',open:function(){$(handler).off('submit').on('submit',function(){return false;});}});} -doInclude([include("features/base_handler/index.js")]) -function DefaultHandler(app) -{this.removeStack=true;BaseHandler.apply(this,arguments);this.message=g_textsSelectAndMove+" "+g_selectGroupText+""+" "+g_useContextMenuText+"";this.selectedObjects=[];this.dragObject=null;this.selectedObject=null;this.prevPosition=null;this.groupingSelect=false;this.selectedLogRect=false;this.selectedLogCtrl=false;this.saveUndo=false;this.addContextMenu();} -DefaultHandler.prototype=Object.create(BaseHandler.prototype);DefaultHandler.prototype.pressed=false;DefaultHandler.prototype.curveValue=0.1;DefaultHandler.prototype.GetSelectedVertex=function() -{return(this.selectedObject instanceof BaseVertex)?this.selectedObject:null;} -DefaultHandler.prototype.MouseMove=function(pos) -{if(this.dragObject) -{if(!this.saveUndo) -{this.app.PushToStack("Move");this.saveUndo=true;} -this.dragObject.position.x=pos.x;this.dragObject.position.y=pos.y;this.needRedraw=true;} -else if(this.selectedObjects.length>0&&this.pressed&&!this.groupingSelect) -{if(!this.saveUndo) -{this.app.PushToStack("Move");this.saveUndo=true;} -var offset=(new Point(pos.x,pos.y)).subtract(this.prevPosition);for(var i=0;i0||this.selectedObject!=null)&&selectedObject!=null) -{if(this.selectedObjects.length==0) -{this.selectedObjects.push(this.selectedObject);this.selectedObject=null;this.selectedObjects.push(selectedObject);} -else if(!this.selectedObjects.includes(selectedObject)) -{this.selectedObjects.push(selectedObject);} -else if(severalSelect&&this.selectedObjects.includes(selectedObject)) -{var index=this.selectedObjects.indexOf(selectedObject);this.selectedObjects.splice(index,1);} -if(!this.selectedLogCtrl) -{userAction("GroupSelected.SelectCtrl");this.selectedLogCtrl=true;}} -else -{if(selectedObject!=null) -{this.selectedObject=selectedObject;} -if((selectedObject instanceof BaseVertex)&&selectedObject!=null) -{this.dragObject=selectedObject;this.message=g_moveCursorForMoving;}} -this.needRedraw=true;this.pressed=true;this.prevPosition=pos;this.app.canvas.style.cursor="move";} -DefaultHandler.prototype.MouseUp=function(pos) -{this.saveUndo=false;this.message=g_textsSelectAndMove+" "+g_selectGroupText+""+" "+g_useContextMenuText+"";this.dragObject=null;this.pressed=false;this.app.canvas.style.cursor="auto";this.app.SetSelectionRect(null);this.groupingSelect=false;if(this.selectedObject!=null&&(this.selectedObject instanceof BaseVertex)) -{this.message=g_textsSelectAndMove -+"
" -+"" -+"" -+"
";var handler=this;var callback=function(enumType){handler.RenameVertex(enumType.GetVertexText(0),handler.selectedObject);userAction("RenameVertex");};$('#message').unbind();$('#message').on('click','#renameButton',function(){var customEnum=new TextEnumVerticesCustom(handler.app);customEnum.ShowDialog(callback,g_rename,g_renameVertex,handler.selectedObject.mainText);});$('#message').on('click','#changeCommonStyle',function(){var selectedVertices=handler.app.GetSelectedVertices();var setupVertexStyle=new SetupVertexStyle(handler.app);setupVertexStyle.show(0,selectedVertices);});$('#message').on('click','#changeSelectedStyle',function(){var selectedVertices=handler.app.GetSelectedVertices();var setupVertexStyle=new SetupVertexStyle(handler.app);setupVertexStyle.show(1,selectedVertices);});} -else if(this.selectedObject!=null&&(this.selectedObject instanceof BaseEdge)) -{this.message=g_textsSelectAndMove -+"" -+" "+g_curveEdge+" " -+"   " -+"
" -+"" -+"" -+"
";var handler=this;$('#message').unbind();$('#message').on('click','#editEdge',function(){handler.ShowEditEdgeDialog(handler.selectedObject);});$('#message').on('click','#incCurvel',function(){handler.app.PushToStack("ChangeCurvelEdge");handler.selectedObject.model.ChangeCurveValue(DefaultHandler.prototype.curveValue);handler.needRedraw=true;handler.app.redrawGraph();userAction("Edge.Bend");});$('#message').on('click','#decCurvel',function(){handler.app.PushToStack("ChangeCurvelEdge");handler.selectedObject.model.ChangeCurveValue(-DefaultHandler.prototype.curveValue);handler.needRedraw=true;handler.app.redrawGraph();userAction("Edge.Bend");});$('#message').on('click','#changeCommonStyle',function(){var selectedEdges=handler.app.GetSelectedEdges();var setupVertexStyle=new SetupEdgeStyle(handler.app);setupVertexStyle.show(0,selectedEdges);});$('#message').on('click','#changeSelectedStyle',function(){var selectedEdges=handler.app.GetSelectedEdges();var setupVertexStyle=new SetupEdgeStyle(handler.app);setupVertexStyle.show(1,selectedEdges);});} -else if(this.selectedObjects.length>0) -{this.message=g_dragGroupText+" "+g_selectGroupText+"";var hasVertices=false;var hasEdges=false;for(var i=0;i";this.message=this.message -+"    " -+"" -this.message=this.message -+"     " -+"" -+"
";var handler=this;$('#message').unbind();$('#message').on('click','#DublicateSelected',function(){handler.app.PushToStack("DublicateSelection");userAction("GroupSelected.Dublicate");var newSelected=[];var copyVertex={};for(var i=0;i=1) -{var curve=handler.app.GetAvailableCurveValue(neighborEdges,newObject);newObject.model.SetCurveValue(curve);}} -newSelected.push(newObject);}} -handler.selectedObjects=newSelected;handler.needRedraw=true;handler.app.redrawGraph();});$('#message').on('click','#RemoveSelected',function(){handler.app.PushToStack("RemoveSelection");userAction("GroupSelected.Remove");for(var i=0;i"+g_selectGroupText+"";});if(hasEdges){$('#message').on('click','#changeCommonStyleEdge',function(){var selectedEdges=handler.app.GetSelectedEdges();var setupVertexStyle=new SetupEdgeStyle(handler.app);setupVertexStyle.show(0,selectedEdges);});$('#message').on('click','#changeSelectedStyleEdge',function(){var selectedEdges=handler.app.GetSelectedEdges();var setupVertexStyle=new SetupEdgeStyle(handler.app);setupVertexStyle.show(1,selectedEdges);});} -if(hasVertices){$('#message').on('click','#changeCommonStyleVertex',function(){var selectedVertices=handler.app.GetSelectedVertices();var setupVertexStyle=new SetupVertexStyle(handler.app);setupVertexStyle.show(0,selectedVertices);});$('#message').on('click','#changeSelectedStyleVertex',function(){var selectedVertices=handler.app.GetSelectedVertices();var setupVertexStyle=new SetupVertexStyle(handler.app);setupVertexStyle.show(1,selectedVertices);});}} -this.needRedraw=true;} -DefaultHandler.prototype.GetSelectedGroup=function(object) -{return(object==this.dragObject)||(object==this.selectedObject)?1:0||this.selectedObjects.includes(object);} -DefaultHandler.prototype.SelectObjectInRect=function(rect) -{this.selectedObjects=[];var vertices=this.app.graph.vertices;for(var i=0;i" -+" " -+"" -+" "+baseMessage;} -ConnectionGraphHandler.checkUseDefaultEdge=function(elem,app) -{app.setUseDefaultEdge(elem.checked);app.updateMessage();};ConnectionGraphHandler.prototype.GetUseDefaultEdgeCheckBox=function(){if(!this.app.hasDefaultEdge()){return"";} -return"
"+""+" "+"
";} -ConnectionGraphHandler.prototype.InitControls=function(){BaseHandler.prototype.InitControls.call(this) -if(!this.app.hasDefaultEdge()){return;} -let app=this.app;$('#useDefaultEdge').unbind();$('#useDefaultEdge').change(function(){app.setUseDefaultEdge(this.checked);});$("#useDefaultEdge").prop("checked",this.app.getUseDefaultEdge());} -doInclude([include("features/base_handler/index.js")]) -function DeleteGraphHandler(app) -{this.removeStack=true;BaseHandler.apply(this,arguments);this.message=g_selectObjectToDelete;this.addContextMenu();} -DeleteGraphHandler.prototype=Object.create(BaseHandler.prototype);DeleteGraphHandler.prototype.MouseDown=function(pos) -{var selectedObject=this.GetSelectedObject(pos);if(!this.app.IsCorrectObject(selectedObject)) -return;this.app.PushToStack("Delete");this.app.DeleteObject(selectedObject);this.needRedraw=true;} -function DeleteAllHandler(app) -{BaseHandler.apply(this,arguments);} -DeleteAllHandler.prototype=Object.create(BaseHandler.prototype);DeleteAllHandler.prototype.clear=function() -{this.app.PushToStack("DeleteAll");this.app.graph=new Graph();this.app.savedGraphName="";this.needRedraw=true;} -doInclude([include("features/base_handler/index.js")]) -function AlgorithmGraphHandler(app,algorithm) -{BaseHandler.apply(this,arguments);this.algorithm=algorithm;this.SaveUpText();this.UpdateResultAndMessage();} -AlgorithmGraphHandler.prototype=Object.create(BaseHandler.prototype);AlgorithmGraphHandler.prototype.MouseMove=function(pos){} -AlgorithmGraphHandler.prototype.MouseDown=function(pos) -{this.app.setRenderPath([]);if(this.algorithm.instance()) -{this.app.SetDefaultHandler();} -else -{var selectedObject=this.GetSelectedGraph(pos);if(selectedObject&&(selectedObject instanceof BaseVertex)) -{if(this.algorithm.selectVertex(selectedObject)) -{this.needRedraw=true;} -this.UpdateResultAndMessage();} -else if(selectedObject&&(selectedObject instanceof BaseEdge)) -{if(this.algorithm.selectEdge(selectedObject)) -{this.needRedraw=true;} -this.UpdateResultAndMessage();} -else -{if(this.algorithm.deselectAll()) -{this.needRedraw=true;this.UpdateResultAndMessage();}}}} -AlgorithmGraphHandler.prototype.MouseUp=function(pos){} -AlgorithmGraphHandler.prototype.GetSelectedGroup=function(object) -{return this.algorithm.getObjectSelectedGroup(object);} -AlgorithmGraphHandler.prototype.RestoreAll=function() -{this.app.setRenderPath([]);if(this.algorithm.needRestoreUpText()) -{this.RestoreUpText();} -if(this.algorithm.wantRestore()) -{this.algorithm.restore();}} -AlgorithmGraphHandler.prototype.SaveUpText=function() -{this.vertexUpText={};var graph=this.app.graph;for(i=0;i";var directedHeader="";var undirectedHeader="";var defaultWeight=1.0;var weightKeyId="\"d0\"";var weightNode=""+""+defaultWeight+""+"";var xmlBody="";for(var i=0;i";} -var hasDirected=false;for(var i=0;i"+arc.weight+"";} -xmlBody=xmlBody+""+weightData+"":"/>")} -xml=mainHeader+weightNode+(hasDirected?directedHeader:undirectedHeader)+xmlBody+"" -return xml;} -function BaseEnumVertices(app,startNumber) -{this.app=app;this.startNumber=startNumber;} -BaseEnumVertices.prototype.GetVertexText=function(id) -{return this.startNumber+id;} -BaseEnumVertices.prototype.GetVertexTextAsync=function(callback) -{callback(this);} -BaseEnumVertices.prototype.GetText=function() -{return this.startNumber+", "+(this.startNumber+1)+", "+(this.startNumber+2)+"...";} -BaseEnumVertices.prototype.GetValue=function() -{return"Numbers"+this.startNumber;} -function TextEnumTitle(app,title) -{BaseEnumVertices.apply(this,arguments);this.pattern="";this.title=title;} -TextEnumTitle.prototype=Object.create(BaseEnumVertices.prototype);TextEnumTitle.prototype.GetVertexText=function(id) -{return this.title;} -function TextEnumVertices(app) -{BaseEnumVertices.apply(this,arguments);this.pattern="ABCDEFGHIJKLMNOPQRSTUVWXYZ";} -TextEnumVertices.prototype=Object.create(BaseEnumVertices.prototype);TextEnumVertices.prototype.GetVertexText=function(id) -{var res="";res=this.pattern[id%this.pattern.length]+res;while(id>=this.pattern.length) -{id=Math.floor(id/this.pattern.length)-1;res=this.pattern[id%this.pattern.length]+res;} -return res;} -TextEnumVertices.prototype.GetText=function() -{return"A, B, ... Z";} -TextEnumVertices.prototype.GetValue=function() -{return"Latin";} -function TextEnumVerticesCyr(app) -{TextEnumVertices.apply(this,arguments);this.pattern="АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ";} -TextEnumVerticesCyr.prototype=Object.create(TextEnumVertices.prototype);TextEnumVerticesCyr.prototype.GetText=function() -{return"А, Б, ... Я";} -TextEnumVerticesCyr.prototype.GetValue=function() -{return"Cyrillic";} -function TextEnumVerticesGreek(app) -{TextEnumVertices.apply(this,arguments);this.pattern="ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ";} -TextEnumVerticesGreek.prototype=Object.create(TextEnumVertices.prototype);TextEnumVerticesGreek.prototype.GetText=function() -{return"Α, Β, ... Ω";} -TextEnumVerticesGreek.prototype.GetValue=function() -{return"Greek";} -function TextEnumVerticesCustom(app) -{BaseEnumVertices.apply(this,arguments);this.pattern="";} -TextEnumVerticesCustom.prototype=Object.create(BaseEnumVertices.prototype);TextEnumVerticesCustom.prototype.GetText=function() -{return g_customEnumVertex;} -TextEnumVerticesCustom.prototype.GetValue=function() -{return"Custom";} -TextEnumVerticesCustom.prototype.GetVertexTextAsync=function(callback) -{this.ShowDialog(callback,g_addVertex,g_addVertex,"A");} -TextEnumVerticesCustom.prototype.ShowDialog=function(callback,buttonText,titleTitle,title) -{var dialogButtons={};app=this.app;dialogButtons[buttonText]=function(){app.PushToStack("RenameVertex");callback(new TextEnumTitle(app,$("#VertexTitle").val()));$(this).dialog("close");};$("#addVertex").dialog({resizable:false,height:"auto",width:"auto",modal:true,title:titleTitle,buttons:dialogButtons,dialogClass:'EdgeDialog',open:function(){$(this).off('submit').on('submit',function(){return false;});$("#VertexTitle").val(title);$("#VertexTitle").focus();}});} -var g_textsSelectAndMove="Drag objects";var g_moveCursorForMoving="Move cursor";var g_clickToAddVertex="Click to add vertex";var g_selectFirstVertexToConnect="Select first vertex to connect";var g_selectSecondVertexToConnect="Select second vertex to connect";var g_selectStartVertexForShortPath="Select start vertex for shortest path";var g_selectFinishVertexForShortPath="Select finish vertex for shortest path";var g_shortestPathResult="Shortest path is %d";var g_pathNotExists="Path does not exists";var g_selectObjectToDelete="Select object to delete";var g_addEdge="Add edge";var g_orintEdge="Directed";var g_notOrintEdge="Undirected";var g_adjacencyMatrixText="Adjacency Matrix";var g_save="Save";var g_cancel="Cancel";var g_save_graph="Save Graph";var g_shortestDistance="lowest-distance is ";var g_incidenceMatrixText="Incidence Matrix";var g_save_dialog="Save dialog";var g_close="close";var g_sickConnectedComponent="Sick connected component is ";var g_connectedComponent="Connected component is ";var g_what_do_you_think="What do you think about site?";var g_name="Name";var g_feedback="Feedback";var g_send="Send";var g_write_to_us="Write to us";var g_fixMatrix="Fix matrix";var g_readMatrixHelp="Matrix format help";var g_matrixWrongFormat="Matrix is wrong";var g_pairWrongFormat="Edge List is wrong";var g_fix="Fix" -var g_save_image_dialog="Save graph image";var g_fullReport="Full report";var g_shortReport="Short report";var g_hasEulerianLoop="Graph has Eulerian Loop";var g_hasNotEulerianLoop="Graph has not Eulerian Loop";var g_hasEulerianPath="Graph has Eulerian Path";var g_hasNotEulerianPath="Graph has not Eulerian Path";var g_processing="Processing...";var g_customEnumVertex="Custom";var g_addVertex="Add vertex";var g_renameVertex="Rename vertex";var g_rename="Rename";var g_language="en";var g_editWeight="Edit weight";var g_noWeight="No weight";var g_groupRename="Group rename";var g_vote="Vote";var g_recommendAlgorithm="Recommend algorithm";var g_graphOfMinDist="Graph of minimal distances.";var g_checkToSave="Check to save";var g_showDistMatrix="Show Distance matrix";var g_minDistMatrixText="Minimal distances matrix";var g_selectStartVertexForMaxFlow="Select source vertex for max flow";var g_selectFinishVertexForMaxFlow="Select sink vertex for max flow";var g_maxFlowResult="Maximum flow from %2 to %3 is %1";var g_flowNotExists="Flow from %1 to %2 does not exists";var g_sourceVertex="Source";var g_sinkVertex="Sink";var g_hasHamiltonianLoop="Graph has Hamiltonian Loop";var g_hasNotHamiltonianLoop="Graph has not Hamiltonian Loop";var g_hasHamiltonianPath="Graph has Hamiltonian Path";var g_hasNotHamiltonianPath="Graph has not Hamiltonian Path";var g_startTraversal="Select start traversal vector";var g_traversalOrder="Traversal order: ";var g_curveEdge="Curved edge";var g_Undo="Undo";var g_default="default";var g_vertexDraw="Vertex draw style";var g_edgeDraw="Edge draw style";var g_backgroundStyle="Background style";var g_GraphIsMultiMessage="Graph is multigraph";var g_GraphIsGeneralMessage="";var g_DefaultWeightPreset="no weight";var g_dragGroupText="Drag group.";var g_selectGroupText="Select using ctrl";var g_copyGroupeButton="Duplicate";var g_removeGroupeButton="Remove objects";var g_BFSName="Breadth-first search";var g_ColoringName="Graph coloring";var g_findConnectedComponent="Find connected components";var g_DFSName="Depth-first search";var g_EulerinLoopName="Find Eulerian cycle";var g_EulerinPath="Find Eulerian path";var g_FloidName="Floyd–Warshall algorithm";var g_GraphReorder="Arrange the graph";var g_HamiltoianCycleName="Find Hamiltonian cycle";var g_HamiltonianPath="Find Hamiltonian path";var g_MaxFlowName="Find Maximum flow";var g_minimumSpanningTree="Search of minimum spanning tree";var g_modernGraphStyleName="Visualization based on weight";var g_RadiusAndDiameter="Search graph radius and diameter";var g_findShortPathName="Find shortest path using Dijkstra's algorithm";var g_VerticesDegreeName="Calculate vertices degree";var g_SpanningTreeResult="Min Spanning Tree is";var g_SpanningTreeIgnoreDir="We ignored edges direction for calculation";var g_SpanningTreeNotConnected="Graph is not connected";var g_selectFirstGraphIsomorphismCheck="Select first graph for isomorphic check. Click to any node of graph";var g_selectSecondGraphIsomorphismCheck="Select second graph for isomorphic check. Click to any node of graph";var g_selectFirstGraphPatternCheck="Select a template graph by clicking to any node of graph";var g_selectSecondGraphForSearchSubgraph="Choose a graph in which we will look for isomorphic subgraphs. Click to any node of this graph";var g_graphsIsomorph="Graphs are isomorphic";var g_graphsNotIsomorph="Graphs are not isomorphic";var g_numberOfIsomorphSubgraphIs="Number of isomorphic subgraphs are ";var g_graphHasNoIsomorphSubgraph="Graph don't contain isomorphic subgraphs";var g_searchIsomorphSubgraph="Search isomorphic subgraphs";var g_subgraphNo="Isomorphic subgraph # ";var g_graphHasNoAtleast2Graphs="To use the algorithm, you need to create 2 separate graphs";var g_IsomorphismCheck="Check Graphs Isomorphism";var g_graphIsDisconnected="Graph is disconnected";var g_graphIsTrivial="Graph contains only one vertex";var g_graphRadius="Graph radius";var g_graphDiameter="Graph diameter";var g_vertexCentral="Central";var g_vertexPeripheral="Peripheral";var g_maximumDegreeOfGraph="The maximum degree of a graph is";var g_colorNumber="Color number is";var g_done="Done";var g_action="Action";var g_commonEdgeStyle="Common Edge Style";var g_selectedEdgeStyle="Selected Edge Style";var g_commonVertexStyle="Common Vertex Style";var g_selectedVertexStyle="Selected Vertex Style";var g_findAllPathes="Find all paths";var g_numberOfPathesFrom="Number of paths from " -var g_to=" to ";var g_are=" are ";var g_pathN="Path #";var g_selectFinishVertex="Select finish vertex";var g_selectStartVertex="Select start vertex";var g_findAllPathesFromVertex="Find all shortest paths from vertex";var g_distanceFrom="Distance from ";var g_pathTo="Path to ";var g_useContextMenuText="Use context menu for addition actions." -var g_findLongestPath="Find the longest path";var g_LengthOfLongestPathFrom="Length of the longest path from ";var g_additionalActions="Additional actions";var g_reverseAllEdges="Reverse all edges";var g_makeAllUndirected="Make all edges undirected";var g_makeAllDirected="Make all edges directed";var g_reuseSavedEdge="Reuse saved edge";var g_MaxClique="Max Clique";var g_MaxCliqueNotFound="Max Clique is not found";var g_MaxCliqueSizeIs="Max Clique size is ";var g_MaxCliqueContains=". Clique contains these vertecies: ";var g_wrongImageFormatPNGAndJPEG="Wrong image format. We support only JPEG and PNG.";var g_wrongImageSizeP1="Image size is too big. Image size must be less than {0} pixels.";function loadTexts() -{g_textsSelectAndMove=document.getElementById("SelectAndMoveObject").innerHTML;g_moveCursorForMoving=document.getElementById("MoveCursorForMoving").innerHTML;g_clickToAddVertex=document.getElementById("clickToAddVertex").innerHTML;g_selectFirstVertexToConnect=document.getElementById("selectFisrtVertextToConnect").innerHTML;g_selectSecondVertexToConnect=document.getElementById("selectSecondVertextToConnect").innerHTML;g_selectStartVertexForShortPath=document.getElementById("selectStartShortPathVertex").innerHTML;g_selectFinishVertexForShortPath=document.getElementById("selectFinishShortPathVertex").innerHTML;g_shortestPathResult=document.getElementById("shortPathResult").innerHTML;g_pathNotExists=document.getElementById("pathNotExists").innerHTML;g_selectObjectToDelete=document.getElementById("selectObjectToDelete").innerHTML;g_addEdge=document.getElementById("AddEdge").innerHTML;g_orintEdge=document.getElementById("OrintEdge").innerHTML;g_notOrintEdge=document.getElementById("NotOrintdge").innerHTML;g_adjacencyMatrixText=document.getElementById("AdjacencyMatrixText").innerHTML;g_save=document.getElementById("Save").innerHTML;g_cancel=document.getElementById("Cancel").innerHTML;g_shortestDistance=document.getElementById("shortestDist").innerHTML;g_incidenceMatrixText=document.getElementById("IncidenceMatrixText").innerHTML;g_save_dialog=document.getElementById("saveDialogTitle").innerHTML;g_close=document.getElementById("closeButton").innerHTML;g_sickConnectedComponent=document.getElementById("sickConnectedComponentResult").innerHTML;g_connectedComponent=document.getElementById("connectedComponentResult").innerHTML;g_what_do_you_think=document.getElementById("whatDoYouThink").innerHTML;g_name=document.getElementById("name").innerHTML;g_feedback=document.getElementById("feedback").innerHTML;g_send=document.getElementById("send").innerHTML;g_write_to_us=document.getElementById("writeToUs").innerHTML;g_fixMatrix=document.getElementById("fixMatrixButton").innerHTML;g_readMatrixHelp=document.getElementById("matrixHelp").innerHTML;g_matrixWrongFormat=document.getElementById("wronMatrixTitle").innerHTML;g_save_image_dialog=document.getElementById("saveImageDialogTitle").innerHTML;g_fullReport=document.getElementById("fullReport").innerHTML;g_shortReport=document.getElementById("shortReport").innerHTML;g_hasEulerianLoop=document.getElementById("hasEulerianLoop").innerHTML;g_hasNotEulerianLoop=document.getElementById("hasNotEulerianLoop").innerHTML;g_processing=document.getElementById("processing").innerHTML;g_customEnumVertex=document.getElementById("customEnumVertex").innerHTML;g_addVertex=document.getElementById("addVertexText").innerHTML;g_renameVertex=document.getElementById("renameVertex").innerHTML;g_rename=document.getElementById("renameText").innerHTML;g_language=document.getElementById("currentLanguage").innerHTML;g_editWeight=document.getElementById("editWeight").innerHTML;g_noWeight=document.getElementById("noWeight").innerHTML;g_groupRename=document.getElementById("groupeRenameText").innerHTML;g_vote=document.getElementById("voteText").innerHTML;g_recommendAlgorithm=document.getElementById("recommend_algorithm").innerHTML;g_hasEulerianPath=document.getElementById("hasEulerianPath").innerHTML;g_hasNotEulerianPath=document.getElementById("hasNotEulerianPath").innerHTML;g_graphOfMinDist=document.getElementById("graphOfMinDist").innerHTML;g_checkToSave=document.getElementById("checkToSave").innerHTML;g_showDistMatrix=document.getElementById("showDistMatrix").innerHTML;g_minDistMatrixText=document.getElementById("distMatrixText").innerHTML;g_selectStartVertexForMaxFlow=document.getElementById("selectStartVertexForMaxFlow").innerHTML;g_selectFinishVertexForMaxFlow=document.getElementById("selectFinishVertexForMaxFlow").innerHTML;g_maxFlowResult=document.getElementById("maxFlowResult").innerHTML;g_flowNotExists=document.getElementById("flowNotExists").innerHTML;g_sourceVertex=document.getElementById("sourceVertex").innerHTML;g_sinkVertex=document.getElementById("sinkVertex").innerHTML;g_hasHamiltonianLoop=document.getElementById("hasHamiltonianLoop").innerHTML;g_hasNotHamiltonianLoop=document.getElementById("hasNotHamiltonianLoop").innerHTML;g_hasHamiltonianPath=document.getElementById("hasHamiltonianPath").innerHTML;g_hasNotHamiltonianPath=document.getElementById("hasNotHamiltonianPath").innerHTML;g_startTraversal=document.getElementById("startTraversal").innerHTML;g_traversalOrder=document.getElementById("traversalOrder").innerHTML;g_curveEdge=document.getElementById("curveEdge").innerHTML;g_Undo=document.getElementById("undoTranslate").innerHTML;g_save_graph=document.getElementById("saveGraph").innerHTML;g_default=document.getElementById("default").innerHTML;g_vertexDraw=document.getElementById("vertexDrawStyle").innerHTML;g_edgeDraw=document.getElementById("edgeDrawStyle").innerHTML;g_backgroundStyle=document.getElementById("backgroundStyle").innerHTML;g_GraphIsMultiMessage=document.getElementById("graphIsMultiMessage").innerHTML;g_GraphIsGeneralMessage=document.getElementById("graphIsGeneralMessage").innerHTML;g_DefaultWeightPreset=document.getElementById("defaultWeightPreset").innerHTML;var isMac=navigator.platform.toUpperCase().indexOf('MAC')>=0;if(isMac) -g_selectGroupText=document.getElementById("selectGroupMac").innerHTML;else -g_selectGroupText=document.getElementById("selectGroupWin").innerHTML;g_dragGroupText=document.getElementById("dragSelectedGroup").innerHTML;g_copyGroupeButton=document.getElementById("copySelectedGroup").innerHTML;g_removeGroupeButton=document.getElementById("removeSelectedGroup").innerHTML;g_BFSName=document.getElementById("BFSName").innerHTML;g_ColoringName=document.getElementById("ColoringName").innerHTML;g_findConnectedComponent=document.getElementById("findConnectedComponent").innerHTML;g_DFSName=document.getElementById("DFSName").innerHTML;g_EulerinLoopName=document.getElementById("EulerinLoopName").innerHTML;g_EulerinPath=document.getElementById("EulerinPath").innerHTML;g_FloidName=document.getElementById("FloidName").innerHTML;g_GraphReorder=document.getElementById("GraphReorder").innerHTML;g_HamiltoianCycleName=document.getElementById("HamiltoianCycleName").innerHTML;g_HamiltonianPath=document.getElementById("HamiltonianPath").innerHTML;g_MaxFlowName=document.getElementById("MaxFlowName").innerHTML;g_minimumSpanningTree=document.getElementById("minimumSpanningTree").innerHTML;g_modernGraphStyleName=document.getElementById("modernGraphStyleName").innerHTML;g_RadiusAndDiameter=document.getElementById("RadiusAndDiameter").innerHTML;g_findShortPathName=document.getElementById("findShortPathName").innerHTML;g_VerticesDegreeName=document.getElementById("VerticesDegreeName").innerHTML;g_SpanningTreeResult=document.getElementById("MinSpanningTreeResult").innerHTML;g_SpanningTreeIgnoreDir=document.getElementById("MinSpanningIgnoreDir").innerHTML;g_SpanningTreeNotConnected=document.getElementById("MinSpanningNotConnected").innerHTML;g_selectFirstGraphIsomorphismCheck=document.getElementById("SelectFirstGraphIsomorphismCheck").innerHTML;g_selectSecondGraphIsomorphismCheck=document.getElementById("SelectSecondGraphIsomorphismCheck").innerHTML;g_selectFirstGraphPatternCheck=document.getElementById("SelectFirstGraphPatternCheck").innerHTML;g_selectSecondGraphForSearchSubgraph=document.getElementById("SelectSecondGraphForSearchSubgraph").innerHTML;g_graphsIsomorph=document.getElementById("GraphsIsomorph").innerHTML;g_graphsNotIsomorph=document.getElementById("GraphsNotIsomorph").innerHTML;g_numberOfIsomorphSubgraphIs=document.getElementById("NumberOfIsomorphSubgraphIs").innerHTML;g_graphHasNoIsomorphSubgraph=document.getElementById("GraphHasNoIsomorphSubgraph").innerHTML;g_searchIsomorphSubgraph=document.getElementById("SearchIsomorphSubgraph").innerHTML;g_subgraphNo=document.getElementById("SubgraphNo").innerHTML;g_graphHasNoAtleast2Graphs=document.getElementById("GraphHasNoAtleast2Graphs").innerHTML;g_IsomorphismCheck=document.getElementById("IsomorphismCheck").innerHTML;g_graphIsDisconnected=document.getElementById("GraphIsDisconnected").innerHTML;g_graphIsTrivial=document.getElementById("GraphIsTrivial").innerHTML;g_graphRadius=document.getElementById("GraphRadius").innerHTML;g_graphDiameter=document.getElementById("GraphDiameter").innerHTML;g_vertexCentral=document.getElementById("VertexCentral").innerHTML;g_vertexPeripheral=document.getElementById("VertexPeripheral").innerHTML;g_maximumDegreeOfGraph=document.getElementById("MaximumDegreeOfGraph").innerHTML;g_colorNumber=document.getElementById("ColorNumber").innerHTML;g_done=document.getElementById("Done").innerHTML;g_action=document.getElementById("ActionText").innerHTML;g_commonEdgeStyle=document.getElementById("CommonEdgeStyleText").innerHTML;g_selectedEdgeStyle=document.getElementById("SelectedEdgeStyleText").innerHTML;g_commonVertexStyle=document.getElementById("CommonVertexStyleText").innerHTML;g_selectedVertexStyle=document.getElementById("SelectedVertexStyleText").innerHTML;g_findAllPathes=document.getElementById("FindAllPathes").innerHTML;g_numberOfPathesFrom=document.getElementById("NumberOfPathesFrom").innerHTML;g_to=document.getElementById("To").innerHTML;g_are=document.getElementById("Are").innerHTML;g_pathN=document.getElementById("PathN").innerHTML;g_selectFinishVertex=document.getElementById("SelectFinishVertex").innerHTML;g_selectStartVertex=document.getElementById("SelectStartVertex").innerHTML;g_findAllPathesFromVertex=document.getElementById("findAllPathsFromVertex").innerHTML;g_distanceFrom=document.getElementById("distanceFrom").innerHTML;g_pathTo=document.getElementById("pathTo").innerHTML;g_useContextMenuText=document.getElementById("UseContextMenuText").innerHTML;g_findLongestPath=document.getElementById("findLongestPath").innerHTML;g_LengthOfLongestPathFrom=document.getElementById("LengthOfLongestPathFrom").innerHTML;g_additionalActions=document.getElementById("additionlActions").innerHTML;g_reverseAllEdges=document.getElementById("reverseAllEdges").innerHTML;g_makeAllUndirected=document.getElementById("makeAllUndirected").innerHTML;g_makeAllDirected=document.getElementById("makeAllDirected").innerHTML;g_pairWrongFormat=document.getElementById("pairWrongFormat").innerHTML;g_fix=document.getElementById("fixButton").innerHTML;g_reuseSavedEdge=document.getElementById("reuseSavedEdge").innerHTML;g_MaxClique=document.getElementById("maxClique").innerHTML;g_MaxCliqueNotFound=document.getElementById("maxCliqueNotFound").innerHTML;g_MaxCliqueSizeIs=document.getElementById("maxCliqueSizeIs").innerHTML;g_MaxCliqueContains=document.getElementById("maxCliqueContains").innerHTML;g_wrongImageFormatPNGAndJPEG=document.getElementById("wrongImageFormatPNGAndJPEG").innerHTML;g_wrongImageSizeP1=document.getElementById("wrongImageSizeP1").innerHTML;} -function UndoStack(maxUndoStackSize){this.undoStack=[];this.maxUndoStackSize=maxUndoStackSize;} -UndoStack.prototype.PushToStack=function(actionName,dataToSave) -{var object={};object.actionName=actionName;object.data=dataToSave;this.undoStack.push(object);while(this.undoStack.length>this.maxUndoStackSize) -{this.undoStack.shift();}} -UndoStack.prototype.Undo=function() -{if(this.IsUndoStackEmpty()) -return null;var state=this.undoStack.pop();return state.data;} -UndoStack.prototype.ClearUndoStack=function() -{this.undoStack=[];} -UndoStack.prototype.IsUndoStackEmpty=function() -{return(this.undoStack.length<=0);} -var DiskSaveLoad=function(){};DiskSaveLoad.LoadGraphFromDisk=function(graphName,callback) -{$.ajax({type:"GET",url:"/"+SiteDir+"cgi-bin/loadGraph.php?name="+graphName}).done(callback);} -DiskSaveLoad.SaveSVGGraphOnDisk=function(imageName,svgText,callback) -{$.ajax({type:"POST",url:"/"+SiteDir+"cgi-bin/saveSvg.php?name="+imageName,data:{svgdata:svgText},dataType:"text",success:callback});return imageName;} -DiskSaveLoad.SaveGraphOnDisk=function(savedGraphName,graphAsString,callback) -{$.ajax({type:"POST",url:"/"+SiteDir+"cgi-bin/saveGraph.php?name="+savedGraphName,data:graphAsString,dataType:"text"}).done(callback);} -DiskSaveLoad.SaveGraphImageOnDisk=function(imageName,rectParams,imageBase64Data,callback) -{$.ajax({type:"POST",url:"/"+SiteDir+"cgi-bin/saveImage.php?name="+imageName+rectParams,data:{base64data:imageBase64Data},dataType:"text",success:callback});} -var globalApplication=null;function Application(document,window,listener) -{this.document=document;this.listener=listener;this.canvas=this.document.getElementById('canvas');this.handler=new DefaultHandler(this);this.savedGraphName="";this.currentEnumVerticesType=new BaseEnumVertices(this,1);this.findPathReport=1;this.isTimerRender=false;globalApplication=this;this.renderPath=[];this.renderTimer=0;this.renderPathLength=0;this.renderPathCounter=0;this.renderPathLoops=0;this.enumVerticesTextList=[new BaseEnumVertices(this,1),new BaseEnumVertices(this,0),new TextEnumVertices(this),new TextEnumVerticesCyr(this),new TextEnumVerticesGreek(this),new TextEnumVerticesCustom(this)];this.SetDefaultTransformations();this.algorithmsValues={};this.undoStack=new UndoStack(this.maxUndoStackSize);this.edgeCommonStyle=new CommonEdgeStyle();this.isEdgeCommonStyleCustom=false;this.edgeSelectedStyles=FullArrayCopy(DefaultSelectedEdgeStyles);this.isEdgeSelectedStylesCustom=false;this.edgePrintCommonStyle=new CommonPrintEdgeStyle();this.edgePrintSelectedStyles=FullArrayCopy(DefaultPrintSelectedEdgeStyles);this.vertexCommonStyle=new CommonVertexStyle();this.isVertexCommonStyleCustom=false;this.vertexSelectedVertexStyles=FullArrayCopy(DefaultSelectedGraphStyles);this.isVertexSelectedVertexStylesCustom=false;this.vertexPrintCommonStyle=new CommonPrintVertexStyle();this.vertexPrintSelectedVertexStyles=FullArrayCopy(DefaultPrintSelectedGraphStyles);this.backgroundCommonStyle=new CommonBackgroundStyle();this.backgroundPrintStyle=new PrintBackgroundStyle();this.isBackgroundCommonStyleCustom=false;this.renderPathWithEdges=false;this.edgePresets=[1,3,5,7,11,42];this.maxEdgePresets=6;this.selectionRect=null;this.defaultVertexSize=null;this.defaultEdgeWidth=null;this.processEmscriptenFunction=null;this.defaultEdge=null;this.useDefaultEdge=false;};Application.prototype.graph=new Graph();Application.prototype.dragObject=-1;Application.prototype.handler=null;Application.prototype.status={};Application.prototype.graphNameLength=16;Application.prototype.maxUndoStackSize=8;Application.prototype.getMousePos=function(canvas,e) -{var rect=canvas.getBoundingClientRect();return{x:(e.clientX-rect.left)/this.canvasScale-this.canvasPosition.x,y:(e.clientY-rect.top)/this.canvasScale-this.canvasPosition.y};} -Application.prototype.redrawGraph=function() -{if(!this.isTimerRender) -{this._redrawGraphInWindow();this.GraphTypeChanged();}} -Application.prototype.redrawGraphTimer=function() -{if(this.isTimerRender) -{var context=this._redrawGraphInWindow();if(this.renderPath.length>1) -{context.save();context.scale(this.canvasScale,this.canvasScale);context.translate(this.canvasPosition.x,this.canvasPosition.y);var movePixelStep=16;var currentLength=0;var i=0 -for(i=0;ithis.renderPathCounter) -{currentLength-=edge.GetPixelLength();break;}} -if(i>=this.renderPath.length-1) -{i=0;if(this.renderPathWithEdges) -i=1;this.renderPathCounter=0;currentLength=0;this.renderPathLoops+=1;} -var edge=null;var currentVertexId=this.renderPath[i];if(this.renderPathWithEdges) -{edge=this.graph.FindEdgeById(this.renderPath[i]);currentVertexId=this.renderPath[i-1];} -else if(this.renderMinPath) -{edge=this.graph.FindEdgeMin(this.renderPath[i],this.renderPath[i+1]);} -else -{edge=this.graph.FindEdge(this.renderPath[i],this.renderPath[i+1]);} -var progress=(this.renderPathCounter-currentLength)/edge.GetPixelLength();this.RedrawEdgeProgress(context,edge,edge.vertex1.id==currentVertexId?progress:1.0-progress);this.renderPathCounter+=movePixelStep;context.restore();}} -if(this.renderPathLoops>=5) -{this.stopRenderTimer();}} -Application.prototype._redrawGraphInWindow=function() -{var context=this.canvas.getContext('2d');context.save();context.scale(this.canvasScale,this.canvasScale);context.translate(this.canvasPosition.x,this.canvasPosition.y);this._RedrawGraph(context,this.canvasPosition,this.backgroundCommonStyle,true);context.restore();return context;} -Application.prototype._OffscreenRedrawGraph=function() -{var bbox=this.graph.getGraphBBox();var canvas=document.createElement('canvas');canvas.width=bbox.size().x;canvas.height=bbox.size().y;var context=canvas.getContext('2d');context.save();context.translate(bbox.minPoint.inverse().x,bbox.minPoint.inverse().y);this._RedrawGraph(context,bbox.minPoint.inverse(),this.backgroundCommonStyle,false);context.restore();return canvas;} -Application.prototype._PrintRedrawGraph=function() -{var bbox=this.graph.getGraphBBox();var canvas=document.createElement('canvas');canvas.width=bbox.size().x;canvas.height=bbox.size().y;var context=canvas.getContext('2d');context.save();context.translate(bbox.minPoint.inverse().x,bbox.minPoint.inverse().y);this._RedrawGraph(context,bbox.minPoint.inverse(),this.backgroundPrintStyle,false,this.vertexPrintCommonStyle,this.vertexPrintSelectedVertexStyles,this.edgePrintCommonStyle,this.edgePrintSelectedStyles);context.restore();return canvas;} -Application.prototype._printToSVG=function() -{var bbox=this.graph.getGraphBBox();var context=new C2S(bbox.size().x,bbox.size().y);context.save();context.translate(bbox.minPoint.inverse().x,bbox.minPoint.inverse().y);this._RedrawGraph(context,bbox.minPoint.inverse(),this.backgroundCommonStyle,false);context.restore();return context.getSerializedSvg();} -Application.prototype.updateRenderPathLength=function() -{this.renderPathLength=0;this.renderPathCounter=0;if(this.renderPath.length>1) -{for(var i=0;i0) -{this.startRenderTimer();} -else -{this.stopRenderTimer();}} -Application.prototype.setRenderPathWithEdges=function(renderPath) -{this.renderPath=renderPath;this.renderMinPath=false;this.renderPathWithEdges=true;if(this.renderPath.length>0) -{this.startRenderTimer();} -else -{this.stopRenderTimer();}} -Application.prototype.GetBaseArcDrawer=function(context,edge) -{var arcDrawer=new BaseEdgeDrawer(context);if(edge.model.type==EdgeModels.curve) -{var curvedArcDrawer=new CurvedArcDrawer(context,edge.model);arcDrawer=new BaseEdgeDrawer(context,{drawArc:curvedArcDrawer,startArrowDirection:curvedArcDrawer,finishArrowDirection:curvedArcDrawer,textCenterObject:curvedArcDrawer,getPointOnArc:curvedArcDrawer});} -return arcDrawer;} -Application.prototype.UpdateEdgeCurrentStyle=function(edge,ForceCommonStyle,ForceSelectedStyle) -{var commonStyle=(ForceCommonStyle===undefined)?this.edgeCommonStyle:ForceCommonStyle;var selectedStyle=(ForceSelectedStyle===undefined)?this.edgeSelectedStyles:ForceSelectedStyle;var selectedGroup=this.handler.GetSelectedGroup(edge);var selected=false;if(selectedGroup>0) -{selectedGroup=(selectedGroup-1)%selectedStyle.length;selected=true;} -var currentStyle=null;if(edge.hasOwnStyleFor((selected?1:0)+selectedGroup)) -currentStyle=edge.getStyleFor((selected?1:0)+selectedGroup);else -currentStyle=selected?selectedStyle[selectedGroup]:commonStyle;edge.currentStyle=currentStyle;} -Application.prototype.RedrawEdge=function(context,edge) -{var curvedArcDrawer=new CurvedArcDrawer(context,edge.model) -var arcDrawer=this.GetBaseArcDrawer(context,edge);this._RedrawEdge(edge,arcDrawer);} -Application.prototype._RedrawEdge=function(edge,arcDrawer,commonStyle,selectedStyles) -{this._RedrawEdgeWithStyle(edge,edge.currentStyle,arcDrawer,commonStyle,selectedStyles);} -Application.prototype._RedrawEdgeWithStyle=function(edge,style,arcDrawer,commonStyle,selectedStyles) -{arcDrawer.Draw(edge,style.GetStyle({},edge));} -Application.prototype.RedrawEdgeProgress=function(context,edge,progress) -{var progressDraw=new ProgressArcDrawer(context,this.GetBaseArcDrawer(context,edge),progress);var arcDrawer=new BaseEdgeDrawer(context,{drawObject:progressDraw});this._RedrawEdge(edge,arcDrawer,this.edgeCommonStyle,this.edgeSelectedStyles);} -Application.prototype.UpdateEdgesCurrentStyle=function(ForceCommonStyle,ForceSelectedStyle) -{for(i=0;i0) -{selectedGroup=(selectedGroup-1)%selectedStyle.length;selected=true;} -var currentStyle=null;if(this.graph.vertices[i].hasOwnStyleFor((selected?1:0)+selectedGroup)&&!force) -currentStyle=this.graph.vertices[i].getStyleFor((selected?1:0)+selectedGroup);else -currentStyle=selected?selectedStyle[selectedGroup]:commonStyle;this.graph.vertices[i].currentStyle=currentStyle;}} -Application.prototype.RedrawSelectionRect=function(context) -{context.lineWidth=1.0/this.canvasScale;context.strokeStyle=this.edgeSelectedStyles[0].strokeStyle;context.setLineDash([6,3]);context.beginPath();context.rect(this.selectionRect.left(),this.selectionRect.top(),this.selectionRect.size().x,this.selectionRect.size().y);context.closePath();context.stroke();context.setLineDash([]);} -Application.prototype.updateMessage=function() -{this.listener.updateMessage(this.handler.GetMessage());this.handler.InitControls();} -Application.prototype.CanvasOnMouseMove=function(e) -{var pos=this.getMousePos(this.canvas,e);this.handler.MouseMove(pos);if(this.handler.IsNeedRedraw()) -{this.handler.RestRedraw();this.redrawGraph();} -this.updateMessage();} -Application.prototype.CanvasOnMouseDown=function(e) -{if(e.which!==1)return;var pos=this.getMousePos(this.canvas,e);this.handler.MouseDown(pos);if(this.handler.IsNeedRedraw()) -{this.handler.RestRedraw();this.redrawGraph();} -this.updateMessage();} -Application.prototype.CanvasOnMouseUp=function(e) -{if(e.which!==1)return;var pos=this.getMousePos(this.canvas,e);this.handler.MouseUp(pos);if(this.handler.IsNeedRedraw()) -{this.handler.RestRedraw();this.redrawGraph();} -this.updateMessage();} -Application.prototype.multCanvasScale=function(factor,zoom_to=null) -{if(zoom_to) -{var pos1=this.getMousePos(this.canvas,zoom_to);this.canvasScale*=factor;var pos2=this.getMousePos(this.canvas,zoom_to);this.canvasPosition=this.canvasPosition.add(new Point(pos2.x-pos1.x,pos2.y-pos1.y));} -else -{var oldRealWidth=this.GetRealWidth();var oldRealHeight=this.GetRealHeight();this.canvasScale*=factor;this.canvasPosition=this.canvasPosition.add(new Point((this.GetRealWidth()-oldRealWidth)/2.0,(this.GetRealHeight()-oldRealHeight)/2.0));} -this.redrawGraph();} -Application.prototype.setCanvasScale=function(factor) -{var oldRealWidth=this.GetRealWidth();var oldRealHeight=this.GetRealHeight();this.canvasScale=factor;this.canvasPosition=this.canvasPosition.add(new Point((this.GetRealWidth()-oldRealWidth)/2.0,(this.GetRealHeight()-oldRealHeight)/2.0));this.redrawGraph();} -Application.prototype.onCanvasMove=function(point) -{this.canvasPosition=this.canvasPosition.add(point.multiply(1/this.canvasScale));this.redrawGraph();} -Application.prototype.AddNewVertex=function(vertex) -{return this.graph.AddNewVertex(vertex);} -Application.prototype.AddNewEdge=function(edge,replaceIfExists) -{return this.graph.AddNewEdge(edge,replaceIfExists);} -Application.prototype.CreateNewGraph=function(x,y) -{var app=this;this.currentEnumVerticesType.GetVertexTextAsync(function(enumType) -{app.graph.AddNewVertex(new BaseVertex(x,y,enumType));app.redrawGraph();});} -Application.prototype.CreateNewGraphEx=function(x,y,vertexEnume) -{return this.graph.AddNewVertex(new BaseVertex(x,y,vertexEnume));} -Application.prototype.CreateNewArc=function(graph1,graph2,isDirect,weight,replaceIfExist,upText) -{var edge=this.AddNewEdge(new BaseEdge(graph1,graph2,isDirect,weight,upText),replaceIfExist);this.graph.FixEdgeCurve(edge);var edgeObject=this.graph.edges[edge];if(edgeObject.useWeight) -this.UpdateEdgePresets(edgeObject.weight);return edge;} -Application.prototype.DeleteEdge=function(edgeObject) -{var vertex1=edgeObject.vertex1;var vertex2=edgeObject.vertex2;var hasPair=this.graph.hasPair(edgeObject);this.graph.DeleteEdge(edgeObject);if(hasPair) -{var pairEdges=this.FindAllEdges(vertex2.id,vertex1.id);if(pairEdges.length==1&&pairEdges[0].model.default) -pairEdges[0].model.type=EdgeModels.line;}} -Application.prototype.DeleteVertex=function(graphObject) -{this.graph.DeleteVertex(graphObject);} -Application.prototype.DeleteObject=function(object) -{if(object instanceof BaseVertex) -{this.DeleteVertex(object);} -else if(object instanceof BaseEdge) -{this.DeleteEdge(object);}} -Application.prototype.IsCorrectObject=function(object) -{return(object instanceof BaseVertex)||(object instanceof BaseEdge);} -Application.prototype.FindVertex=function(id) -{return this.graph.FindVertex(id);} -Application.prototype.FindEdge=function(id1,id2) -{return this.graph.FindEdge(id1,id2);} -Application.prototype.FindEdgeAny=function(id1,id2) -{return this.graph.FindEdgeAny(id1,id2);} -Application.prototype.FindAllEdges=function(id1,id2) -{return this.graph.FindAllEdges(id1,id2);} -Application.prototype.SetHandler=function(newHandler) -{if(this.handler) -{this.handler.RestoreAll();} -this.handler=newHandler;this.ToDefaultStateAndRedraw();} -Application.prototype.ToDefaultStateAndRedraw=function() -{this.setRenderPath([]);this.updateMessage();this.redrawGraph();} -Application.prototype.getParameterByName=function(name) -{name=name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var regex=new RegExp("[\\?&]"+name+"=([^&#]*)"),results=regex.exec(location.search);return results===null?"":decodeURIComponent(results[1].replace(/\+/g," "));} -Application.prototype.onPostLoadEvent=function() -{this.SetEnumVerticesType(document.cookie.replace(/(?:(?:^|.*;\s*)enumType\s*\=\s*([^;]*).*$)|^.*$/,"$1"));var wasLoad=false;var matrix=document.getElementById("inputMatrix").innerHTML;var separator=document.getElementById("separator").innerHTML=="space"?" ":",";console.log(matrix);console.log("separator: \""+separator+"\"");matrix=(matrix.length<=0)?this.getParameterByName("matrix"):matrix;if(matrix.length>0) -{if(!this.SetAdjacencyMatrixSmart(matrix,separator)) -{userAction("AdjacencyMatrix.Failed");this.listener.ShowAdjacencyMatrixErrorDialog(matrix);} -else -{userAction("AdjacencyMatrix.Success");} -this.updateMessage();this.redrawGraph();wasLoad=true;} -var matrix=document.getElementById("inputIncidenceMatrix").innerHTML;matrix=(matrix.length<=0)?this.getParameterByName("incidenceMatrix"):matrix;if(matrix.length>0) -{if(!this.SetIncidenceMatrixSmart(matrix)) -{userAction("IncidenceMatrix.Failed");this.listener.ShowIncidenceMatrixErrorDialog(matrix);} -else -{userAction("IncidenceMatrix.Success");} -this.updateMessage();this.redrawGraph();wasLoad=true;} -var pairs=document.getElementById("inputPair").innerHTML;if(pairs.length>0) -{pairs=pairs.replaceAll('>','>');pairs=pairs.replaceAll('<','<');if(!this.SetPairSmart(pairs)) -{userAction("Pair.Failed");this.listener.ShowPairErrorDialog(pairs);} -else -{userAction("Pair.Success");} -this.updateMessage();this.redrawGraph();wasLoad=true;} -if(!wasLoad) -{var graphName=this.getParameterByName("graph");if(graphName.length<=0) -{graphName=document.cookie.replace(/(?:(?:^|.*;\s*)graphName\s*\=\s*([^;]*).*$)|^.*$/,"$1");} -if(graphName.length>0) -{userAction("LoadGraphFromDisk");this.LoadGraphFromDisk(graphName);}} -if(this.undoStack.IsUndoStackEmpty()) -document.getElementById('GraphUndo').style.display='none';this.updateMessage();this.redrawGraph();} -Application.prototype.onLoad=function() -{this.canvas=this.document.getElementById('canvas');this.SetDefaultHandler() -this.updateMessage();this.redrawGraph();} -Application.prototype.NeedRedraw=function() -{this.updateMessage();this.redrawGraph();} -Application.prototype.SetStatus=function(name,value) -{this.status[name]=value;} -Application.prototype.GetStatus=function() -{return this.status[name];} -Application.prototype.GetAdjacencyMatrix=function() -{return this.graph.GetAdjacencyMatrixStr();} -Application.prototype.TestAdjacencyMatrix=function(matrix,rowsObj,colsObj,separator) -{if(separator===undefined) -{separator=",";} -return this.graph.TestAdjacencyMatrix(matrix,rowsObj,colsObj,separator);} -Application.prototype.SetAdjacencyMatrix=function(matrix,separator) -{if(separator===undefined) -{separator=",";} -var res=true;var r={};var c={};if(!this.TestAdjacencyMatrix(matrix,r,c,separator)) -{$.get("/"+SiteDir+"cgi-bin/addFailedMatrix.php?text=adjacency&matrix="+encodeURIComponent(matrix),function(data){;});res=false;} -this.graph.SetAdjacencyMatrix(matrix,new Point(this.GetRealWidth(),this.GetRealHeight()),this.currentEnumVerticesType,separator);this.AutoAdjustViewport();this.redrawGraph();return res;} -Application.prototype.SetPair=function(pair) -{var res=true;var r={};var c={};if(!this.TestPair(pair)) -{$.get("/"+SiteDir+"cgi-bin/addFailedMatrix.php?text=pair&matrix="+encodeURIComponent(pair),function(data){;});res=false;} -this.graph.SetPair(pair,new Point(this.GetRealWidth(),this.GetRealHeight()),this.currentEnumVerticesType);this.AutoAdjustViewport();this.redrawGraph();return res;} -Application.prototype.GetIncidenceMatrix=function() -{return this.graph.GetIncidenceMatrix();} -Application.prototype.TestIncidenceMatrix=function(matrix,rowsObj,colsObj) -{return this.graph.TestIncidenceMatrix(matrix,rowsObj,colsObj);} -Application.prototype.TestPair=function(pair) -{return this.graph.TestPair(pair);} -Application.prototype.SetIncidenceMatrix=function(matrix) -{var res=true;var r={};var c={};if(!this.TestIncidenceMatrix(matrix,r,c)) -{$.get("/"+SiteDir+"cgi-bin/addFailedMatrix.php?text=incidence&matrix="+encodeURIComponent(matrix),function(data){;});res=false;} -this.graph.SetIncidenceMatrix(matrix,new Point(this.GetRealWidth(),this.GetRealHeight()),this.currentEnumVerticesType);this.AutoAdjustViewport();this.redrawGraph();return res;} -Application.prototype.Test=function() -{this.graph.VerticesReposition(new Point(this.GetRealWidth(),this.GetRealHeight()),this.graph.vertices);this.redrawGraph();} -Application.prototype.SetAdjacencyMatrixSmart=function(matrix,separator) -{if(separator===undefined) -{separator=",";} -var res=false;if(this.TestAdjacencyMatrix(matrix,{},{},separator)) -{res=this.SetAdjacencyMatrix(matrix,separator);} -else if(this.TestIncidenceMatrix(matrix,{},{})) -{res=this.SetIncidenceMatrix(matrix);} -else -{res=this.SetAdjacencyMatrix(matrix);} -return res;} -Application.prototype.SetIncidenceMatrixSmart=function(matrix) -{var res=false;if(this.TestIncidenceMatrix(matrix,{},{})) -{res=this.SetIncidenceMatrix(matrix);} -else if(this.TestAdjacencyMatrix(matrix,{},{})) -{res=this.SetAdjacencyMatrix(matrix);} -else -{res=this.SetIncidenceMatrix(matrix);} -return res;} -Application.prototype.SetPairSmart=function(pair) -{var res=false;if(this.TestPair(pair)) -{res=this.SetPair(pair);} -else -{res=false;} -return res;} -Application.prototype.SaveGraphOnDisk=function() -{var graphAsString=this.graph.SaveToXML(this.SaveUserSettings());if(this.savedGraphName.length<=0) -{this.savedGraphName=this.GetNewGraphName();} -var app=this;DiskSaveLoad.SaveGraphOnDisk(this.savedGraphName,graphAsString,function(msg) -{document.cookie="graphName="+app.savedGraphName;});} -Application.prototype.SaveGraphImageOnDisk=function(showDialogCallback) -{var imageName=this.GetNewName();this.stopRenderTimer();this.redrawGraph();var bbox=this.graph.getGraphBBox();var rectParams="";if(this.IsGraphFitOnViewport()) -{var canvasWidth=this.GetRealWidth();var canvasHeight=this.GetRealHeight();var canvasPositionInverse=this.canvasPosition.inverse();var pos=bbox.minPoint.subtract(canvasPositionInverse);rectParams="&x="+Math.round(pos.x*this.canvasScale)+"&y="+Math.round(pos.y*this.canvasScale) -+"&width="+Math.round(bbox.size().x*this.canvasScale)+"&height="+Math.round(bbox.size().y*this.canvasScale);} -var imageBase64Data=this.canvas.toDataURL();DiskSaveLoad.SaveGraphImageOnDisk(imageName,rectParams,imageBase64Data,showDialogCallback);return imageName;} -Application.prototype.SaveFullGraphImageOnDisk=function(showDialogCallback,forPrint) -{var imageName=this.GetNewName();this.stopRenderTimer();var canvas=forPrint?this._PrintRedrawGraph():this._OffscreenRedrawGraph();var bbox=this.graph.getGraphBBox();var rectParams="";rectParams="&x=0"+"&y=0"+"&width="+bbox.size().x+"&height="+bbox.size().y;var imageBase64Data=canvas.toDataURL();DiskSaveLoad.SaveGraphImageOnDisk(imageName,rectParams,imageBase64Data,showDialogCallback);return imageName;} -Application.prototype.SaveSVGGraphOnDisk=function(showDialogCallback) -{var imageName=this.GetNewName();this.stopRenderTimer();var svgText=this._printToSVG();DiskSaveLoad.SaveSVGGraphOnDisk(imageName,svgText,showDialogCallback);return imageName;} -Application.prototype.LoadGraphFromString=function(str) -{var graph=new Graph();var userSettings={};graph.LoadFromXML(str,userSettings);if(userSettings.hasOwnProperty("data")&&userSettings["data"].length>0) -this.LoadUserSettings(userSettings["data"]);this.SetDefaultTransformations();this.graph=graph;if(this.graph.isNeedReposition()) -{this.graph.VerticesReposition(new Point(this.GetRealWidth(),this.GetRealHeight()),this.graph.vertices);} -this.AutoAdjustViewport();this.updateMessage();this.redrawGraph();} -Application.prototype.LoadGraphFromDisk=function(graphName) -{var app=this;DiskSaveLoad.LoadGraphFromDisk(graphName,function(msg) -{app.LoadGraphFromString(msg);});} -Application.prototype.GetNewGraphName=function() -{var name=this.GetNewName();if(this.isVertexCommonStyleCustom||this.isVertexSelectedVertexStylesCustom||this.isBackgroundCommonStyleCustom||this.isEdgeCommonStyleCustom||this.isEdgeSelectedStylesCustom) -{name=name+"ZZcst";} -return name;} -Application.prototype.GetNewName=function() -{var name="";var possible="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(var i=0;i0) -{if(bboxSize.x>this.GetRealWidth()||bboxSize.y>this.GetRealHeight()) -{this.canvasScale=Math.min(this.GetRealWidth()/bboxSize.x,this.GetRealHeight()/bboxSize.y);} -if(graphBBox.minPoint.x<0.0||graphBBox.minPoint.y<0.0||graphBBox.maxPoint.x>this.GetRealWidth()||graphBBox.maxPoint.y>this.GetRealHeight()) -{this.canvasPosition=graphBBox.minPoint.inverse();}}} -Application.prototype.OnAutoAdjustViewport=function() -{this.SetDefaultTransformations();this.AutoAdjustViewport();this.redrawGraph();} -Application.prototype.getAlgorithmNames=function() -{var res=[];for(var i=0;i=Math.floor(graphBBox.maxPoint.x)&&Math.floor(canvasPositionInverse.y+canvasHeight)>=Math.floor(graphBBox.maxPoint.y));} -Application.prototype.PushToStack=function(actionName) -{this.undoStack.PushToStack(actionName,this.graph.SaveToXML(this.SaveUserSettings()));document.getElementById('GraphUndo').style.display='inline-block';} -Application.prototype.Undo=function() -{let data=this.undoStack.Undo();if(data==null) -return;this.graph=new Graph();var userSettings={};this.graph.LoadFromXML(data,userSettings);if(userSettings.hasOwnProperty("data")&&userSettings["data"].length>0) -this.LoadUserSettings(userSettings["data"]);this.redrawGraph();if(this.undoStack.IsUndoStackEmpty()) -document.getElementById('GraphUndo').style.display='none';} -Application.prototype.SaveUserSettings=function() -{var res="{";var needEnd=false;var checkValue=[];checkValue.push({field:"edgeCommonStyle",value:this.edgeCommonStyle,check:this.isEdgeCommonStyleCustom});checkValue.push({field:"edgeSelectedStyles",value:this.edgeSelectedStyles,check:this.isEdgeSelectedStylesCustom});checkValue.push({field:"vertexCommonStyle",value:this.vertexCommonStyle,check:this.isVertexCommonStyleCustom});checkValue.push({field:"vertexSelectedVertexStyles",value:this.vertexSelectedVertexStyles,check:this.isVertexSelectedVertexStylesCustom});checkValue.push({field:"backgroundCommonStyle",value:this.backgroundCommonStyle,check:this.isBackgroundCommonStyleCustom});checkValue.push({field:"defaultVertexSize",value:this.defaultVertexSize,check:this.defaultVertexSize!=null});checkValue.push({field:"defaultEdgeWidth",value:this.defaultEdgeWidth,check:this.defaultEdgeWidth!=null});checkValue.forEach(function(entry){if(!entry.check) -return;if(needEnd) -res=res+",";let valueJson="";if(typeof entry.value.saveToJson==="function"){valueJson=entry.value.saveToJson();}else{valueJson=JSON.stringify(entry.value);} -res=res+"\""+entry.field+"\""+":"+valueJson;needEnd=true;});res=res+"}";return this.EncodeToHTML(res);} -Application.prototype.LoadUserSettings=function(json) -{var checkValue=[];checkValue.push({field:"edgeCommonStyle",value:this.edgeCommonStyle,check:"isEdgeCommonStyleCustom",deep:false});checkValue.push({field:"edgeSelectedStyles",value:this.edgeSelectedStyles,check:"isEdgeSelectedStylesCustom",deep:true});checkValue.push({field:"vertexCommonStyle",value:this.vertexCommonStyle,check:"isVertexCommonStyleCustom",deep:false});checkValue.push({field:"vertexSelectedVertexStyles",value:this.vertexSelectedVertexStyles,check:"isVertexSelectedVertexStylesCustom",deep:true});checkValue.push({field:"defaultVertexSize",value:"defaultVertexSize",check:null,deep:false});checkValue.push({field:"defaultEdgeWidth",value:"defaultEdgeWidth",check:null,deep:false});checkValue.push({field:"backgroundCommonStyle",value:this.backgroundCommonStyle,check:this.isBackgroundCommonStyleCustom,deep:false});var decoderStr=this.DecodeFromHTML(json);var parsedSave=JSON.parse(decoderStr);var app=this;checkValue.forEach(function(entry){if(parsedSave.hasOwnProperty(entry.field)) -{if(typeof parsedSave[entry.field]==='number') -{app[entry.value]=parseInt(parsedSave[entry.field]);} -else -{if(typeof entry.value.loadFromJson==="function"){entry.value.loadFromJson(parsedSave[entry.field],function(){setTimeout(function(){app.redrawGraph()},1000);});return;} -if(!entry.deep) -entry.value.Clear();for(var k in parsedSave[entry.field]) -{if(!entry.deep) -{if(entry.value.ShouldLoad(k)) -{entry.value[k]=parsedSave[entry.field][k];}} -else -{if(k%1!=0) -continue;entry.value[k].Clear();for(var deepK in parsedSave[entry.field][k]) -{if(k=this.maxEdgePresets) -break;}} -Application.prototype.GetEdgePresets=function() -{return this.edgePresets;} -Application.prototype.SetSelectionRect=function(rect) -{this.selectionRect=rect;} -Application.prototype.GetSelectionRect=function(rect) -{return this.selectionRect;} -Application.prototype.GetStyle=function(type,styleName,object,index) -{var correctIndex=index;if(correctIndex==undefined) -correctIndex=0;if(type=="vertex") -{if(styleName=="common") -{return object!==undefined?object.getStyleFor(0):this.vertexCommonStyle;} -else if(styleName=="selected") -{return object!==undefined&&object.hasOwnStyleFor(correctIndex+1)?object.getStyleFor(correctIndex+1):this.vertexSelectedVertexStyles[correctIndex];} -else if(styleName=="printed") -{return this.vertexPrintCommonStyle;} -else if(styleName=="printedSelected") -{return this.vertexPrintSelectedVertexStyles[correctIndex];} -return null;} -else if(type=="edge") -{if(styleName=="common") -{return object!==undefined?object.getStyleFor(0):this.edgeCommonStyle;} -else if(styleName=="selected") -{return object!==undefined&&object.hasOwnStyleFor(correctIndex+1)?object.getStyleFor(correctIndex+1):this.edgeSelectedStyles[correctIndex];} -else if(styleName=="printed") -{return this.edgePrintCommonStyle;} -else if(styleName=="printedSelected") -{return this.edgePrintSelectedStyles[correctIndex];} -return null;} -return null;} -Application.prototype._RedrawGraph=function(context,backgroundPosition,backgroundStyle,bDrawSelectedRect,forceVertexCommon,forceVertexSelected,forceEdgeCommon,forceEdgeSelected) -{var backgroundDrawer=new BaseBackgroundDrawer(context);backgroundDrawer.Draw(backgroundStyle,Math.max(this.canvas.width,this.GetRealWidth()),Math.max(this.canvas.height,this.GetRealHeight()),backgroundPosition,this.canvasScale);this.UpdateEdgesCurrentStyle(forceEdgeCommon,forceEdgeSelected);this.UpdateNodesCurrentStyle(forceVertexCommon,forceVertexSelected);this.RedrawEdges(context);this.RedrawNodes(context);if(bDrawSelectedRect&&this.selectionRect!=null) -this.RedrawSelectionRect(context);} -Application.prototype.GetSelectedVertices=function() -{var res=[];for(i=0;i0) -{res.push(this.graph.vertices[i]);}} -return res;} -Application.prototype.GetSelectedEdges=function() -{var res=[];for(i=0;i0) -{res.push(this.graph.edges[i]);}} -return res;} -Application.prototype.SetDefaultVertexSize=function(diameter) -{var oldDefaultDiameter=this.GetDefaultVertexSize();this.defaultVertexSize=diameter;for(i=0;i0) -{self.application.multCanvasScale(1.3,e);} -else -{self.application.multCanvasScale(1.0/1.3,e);}}} -Editor.prototype.initKeyActions=function(){let self=this;function getCharCode(event){if(event.which==null){return event.keyCode;} -if(event.which!=0&&event.charCode!=0){return event.which;} -return null;} -function getChar(event){return String.fromCharCode(getCharCode(event));} -function selectHandler(buttonName,handler) -{userAction(buttonName+"_shortcut");self.restButtons(buttonName);self.application.SetHandler(handler);} -document.onkeypress=function(e) -{if(event.defaultPrevented||($('#addVertex').hasClass('ui-dialog-content')&&$('#addVertex').dialog('isOpen'))||($('#adjacencyMatrix').hasClass('ui-dialog-content')&&$('#adjacencyMatrix').dialog('isOpen'))||($('#addEdge').hasClass('ui-dialog-content')&&$('#addEdge').dialog('isOpen'))||($('#incidenceMatrix').hasClass('ui-dialog-content')&&$('#incidenceMatrix').dialog('isOpen'))||($('#saveDialog').hasClass('ui-dialog-content')&&$('#saveDialog').dialog('isOpen'))||($('#saveImageDialog').hasClass('ui-dialog-content')&&$('#saveImageDialog').dialog('isOpen'))||($('#GroupRenameDialog').hasClass('ui-dialog-content')&&$('#GroupRenameDialog').dialog('isOpen'))||$('#developerTools').css("display")!="none"||($('#NeedAlgorithm').hasClass('ui-dialog-content')&&$('#NeedAlgorithm').dialog('isOpen'))) -{console.log("prevent");return;} -var key=getChar(event);var code=getCharCode(event);console.log(key+" code="+code);var evtobj=window.event?event:e;var isCtrl=evtobj?evtobj.ctrlKey:false;var moveValue=10;if(code==61||code==43) -{self.application.multCanvasScale(1.5);} -else if(code==45) -{self.application.multCanvasScale(1/1.5);} -else if(key=='w'||key=='ц') -{self.application.onCanvasMove(new Point(0,moveValue));} -else if(key=='s'||key=='ы') -{self.application.onCanvasMove(new Point(0,-moveValue));} -else if(key=='a'||key=='ф') -{self.application.onCanvasMove(new Point(moveValue,0));} -else if(key=='d'||key=='в') -{self.application.onCanvasMove(new Point(-moveValue,0));} -else if(key=='v'||key=='м') -{selectHandler('AddGraph',new AddGraphHandler(self.application));} -else if(key=='e'||key=='у') -{selectHandler('ConnectGraphs',new ConnectionGraphHandler(self.application));} -else if(key=='r'||key=='к') -{selectHandler('DeleteObject',new DeleteGraphHandler(self.application));} -else if(key=='m'||key=='ь') -{selectHandler('Default',new DefaultHandler(self.application));} -else if(code==26&&isCtrl) -{userAction("Key_GraphUndo");self.application.Undo();}} -$(document).keydown(function(event){if(event.which=="17"||event.which=="91") -g_ctrlPressed=true;});$(document).keyup(function(){g_ctrlPressed=false;});} -Editor.prototype.initButtonActions=function() -{let self=this;document.getElementById('ShowAdjacencyMatrix').onclick=function() -{userAction(this.id);var showAdjacencyMatrix=new ShowAdjacencyMatrix(self.application);showAdjacencyMatrix.show();} -document.getElementById('ShowIncidenceMatrix').onclick=function() -{userAction(this.id);var showIncidenceMatrix=new ShowIncidenceMatrix(self.application);showIncidenceMatrix.show();} -document.getElementById('ShowDistanceMatrix').onclick=function() -{userAction(this.id);var showDistanceMatrix=new ShowDistanceMatrix(self.application);showDistanceMatrix.show();} -document.getElementById('GroupRename').onclick=function() -{userAction(this.id);var groupRenameVertices=new GroupRenameVertices(self.application);groupRenameVertices.show();} -document.getElementById('groupRenameButton').onclick=function() -{userAction(this.id);var groupRenameVertices=new GroupRenameVertices(self.application);groupRenameVertices.show();} -document.getElementById('Default').onclick=function() -{userAction(this.id);self.restButtons('Default');self.application.SetHandler(new DefaultHandler(self.application));document.getElementById('Default').className="btn btn-primary btn-sm";} -document.getElementById('AddGraph').onclick=function() -{userAction(this.id);self.restButtons('AddGraph');self.application.SetHandler(document.getElementById('AddGraph').className!=""?new AddGraphHandler(self.application):new DefaultHandler(self.application));} -document.getElementById('ConnectGraphs').onclick=function() -{userAction(this.id);self.restButtons('ConnectGraphs');self.application.SetHandler(document.getElementById('ConnectGraphs').className!=""?new ConnectionGraphHandler(self.application):new DefaultHandler(self.application));} -document.getElementById('DeleteObject').onclick=function() -{userAction(this.id);self.restButtons('DeleteObject');self.application.SetHandler(document.getElementById('DeleteObject').className!=""?new DeleteGraphHandler(self.application):new DefaultHandler(self.application));} -document.getElementById('DeleteAll').onclick=function() -{userAction(this.id);var removeAll=new DeleteAllHandler(self.application);removeAll.clear();self.application.ToDefaultStateAndRedraw();} -document.getElementById('SaveGraph').onclick=function() -{userAction(this.id);var savedDialogGraphHandler=new SavedDialogGraphHandler(self.application);savedDialogGraphHandler.show();} -document.getElementById('NewGraph').onclick=function() -{userAction(this.id);var removeAll=new DeleteAllHandler(self.application);removeAll.clear();self.application.ToDefaultStateAndRedraw();self.application.SetDefaultTransformations();} -document.getElementById('SaveGraphImage').onclick=function() -{userAction(this.id);var savedDialogGraphImageHandler=new SavedDialogGraphImageHandler(self.application);savedDialogGraphImageHandler.showWorkspace();} -document.getElementById('SaveFullGraphImage').onclick=function() -{userAction(this.id);var savedDialogGraphImageHandler=new SavedDialogGraphImageHandler(self.application);savedDialogGraphImageHandler.showFullgraph();} -document.getElementById('SavePrintGraphImage').onclick=function() -{userAction(this.id);var savedDialogGraphImageHandler=new SavedDialogGraphImageHandler(self.application);savedDialogGraphImageHandler.showPrint();} -document.getElementById('SaveSvgGraphImage').onclick=function() -{userAction(this.id);var savedDialogGraphImageHandler=new SavedDialogGraphImageHandler(self.application);savedDialogGraphImageHandler.showSvg();} -document.getElementById('Zoom100').onclick=function() -{userAction(this.id);self.application.setCanvasScale(1.0);} -document.getElementById('Zoom50').onclick=function() -{userAction(this.id);self.application.setCanvasScale(50/100);} -document.getElementById('Zoom25').onclick=function() -{userAction(this.id);self.application.setCanvasScale(25/100);} -document.getElementById('ZoomFit').onclick=function() -{userAction(this.id);self.application.OnAutoAdjustViewport();} -document.getElementById('ZoomIn').onclick=function() -{userAction(this.id);self.application.multCanvasScale(1.5);} -document.getElementById('ZoomOut').onclick=function() -{userAction(this.id);self.application.multCanvasScale(1.0/1.5);} -document.getElementById('MoveWorspace').onclick=function() -{userAction(this.id);self.restButtons('Default');self.application.SetHandler(new DefaultHandler(self.application));document.getElementById('Default').className="btn btn-primary btn-sm";} -document.getElementById('SetupVertexStyle').onclick=function() -{userAction(this.id);var setupVertexStyle=new SetupVertexStyle(self.application);setupVertexStyle.show(0);} -document.getElementById('SetupVertexStyleSelected').onclick=function() -{userAction(this.id);var setupVertexStyle=new SetupVertexStyle(self.application);setupVertexStyle.show(1);} -document.getElementById('SetupEdgeStyle').onclick=function() -{userAction(this.id);var setupEdgeStyle=new SetupEdgeStyle(self.application);setupEdgeStyle.show(0);} -document.getElementById('SetupEdgeStyleSelected').onclick=function() -{userAction(this.id);var setupEdgeStyle=new SetupEdgeStyle(self.application);setupEdgeStyle.show(1);} -document.getElementById('SetupBackgroundStyle').onclick=function() -{userAction(this.id);var setupBackgroundStyle=new SetupBackgroundStyle(self.application);setupBackgroundStyle.show();} -document.getElementById('GraphUndo').onclick=function() -{userAction(this.id);self.application.Undo();} -document.getElementById('runUserScript').onclick=function() -{} -document.getElementById('submitUserScript').onclick=function() -{var script=document.getElementById('userScript');var data="message="+script.value+"&";$.ajax({type:"POST",url:"/feedback",data:data});$("#sentAlgorithm").dialog({resizable:false,height:"auto",width:400,modal:true,dialogClass:'EdgeDialog'});} -document.getElementById('devToolsZoom').onclick=function() -{var devTools=document.getElementById('developerTools');if(devTools.hasOwnProperty("isMin")&&!devTools["isMin"]) -{devTools["isMin"]=true;devTools.style.width="30%";} -else -{devTools["isMin"]=false;devTools.style.width="100%";}} -document.getElementById('ExportGraph').onclick=function() -{userAction(this.id);var graphAsString=self.application.graph.SaveToXML("");var savedGraphName=self.application.GetNewGraphName();var element=document.createElement('a');element.setAttribute('href','data:text/plain;charset=utf-8,'+encodeURIComponent(graphAsString));element.setAttribute('download',"graph_"+savedGraphName+".graphml");element.style.display='none';document.body.appendChild(element);element.click();document.body.removeChild(element);} -document.getElementById('ImportGraph').onclick=function() -{userAction(this.id);if(ImportGraphFiles){ImportGraphFiles.click();}} -document.getElementById('openAlgorithmList').onclick=function() -{setTimeout(function() -{var button=document.getElementById('openAlgorithmList');var buttonRect=button.getBoundingClientRect();var algorithmList=document.getElementById('algorithmList');var delta=buttonRect.right-algorithmList.offsetWidth;if(delta<0) -{var value=(delta-4)+"px";algorithmList.style.right=value;} -else -{algorithmList.style.right="0";}},1);} -document.getElementById('Fullscreen').onclick=function() -{var idList=["h1Header","h1Text","navigation","footerContent","bottom_adv"];self.fullscreen=!self.fullscreen -userAction(self.fullscreen?"fullscreen_on":"fullscreen_off");for(var i=0;i','>');pair=pair.replaceAll('<','<');dialogButtons[g_readMatrixHelp]=function(){window.location.assign(g_language=="ru"?"./wiki/Справка/СписокРебер":"./wiki/Help/EdgeList");};dialogButtons[g_fix]=function(){window.location.assign("./create_graph_by_edge_list?pair="+pair);};dialogButtons[g_close]=function(){$(this).dialog("close");};$("#pairErrorInc").dialog({resizable:false,title:g_pairWrongFormat,width:400,modal:true,dialogClass:'EdgeDialog',buttons:dialogButtons,});} -Editor.prototype.ShowAdjacencyMatrixErrorDialog=function(matrix) -{var dialogButtons={};matrixRes=matrix.replace(/\n/g,'%0A');dialogButtons[g_readMatrixHelp]=function(){window.location.assign(g_language=="ru"?"./wiki/Справка/МатрицаСмежности#matrixFormat":"./wiki/Help/AdjacencyMatrix#matrixFormat");};dialogButtons[g_fixMatrix]=function(){window.location.assign("./create_graph_by_matrix?matrix="+matrixRes);};dialogButtons[g_close]=function(){$(this).dialog("close");};$("#matrixError").dialog({resizable:false,title:g_matrixWrongFormat,width:400,modal:true,dialogClass:'EdgeDialog',buttons:dialogButtons,});} -Editor.prototype.SetDefaultHandler=function() -{this.restButtons('Default');this.application.SetHandler(new DefaultHandler(this.application));} -Editor.prototype.OnGraphTypeChanged=function(isMulti) -{$("#CanvasMessage").text(isMulti?g_GraphIsMultiMessage:g_GraphIsGeneralMessage);} -Editor.prototype.updateMessage=function(message) -{$("#message").html(message);} -let DisableEmscripten=false;let PostLoadedCalled=false;let editor=new Editor(document,window);function resizeCanvas() -{var adv=document.getElementById('bottom_info');var canvas=document.getElementById('canvas');canvas.width=document.getElementById('canvasSection').offsetWidth;var mainContainer=document.getElementById('mainContainer');var offset=(mainContainer.offsetTop+mainContainer.offsetHeight)-(canvas.offsetTop+canvas.offsetHeight)+ -($("#footerContent").css("display")==='block'?0:24);canvas.height=$(window).height()-document.getElementById('canvas').offsetTop- -(adv&&$("#bottom_info").css("display")==='block'?document.getElementById('bottom_info').offsetHeight:0)- -($("#footer").css("display")==='block'?document.getElementById('footer').offsetHeight:0)-offset;editor.redraw();} -function touchHandler(event) -{var touches=event.changedTouches,first=touches[0],type="";switch(event.type) -{case"touchstart":type="mousedown";break;case"touchmove":type="mousemove";break;case"touchend":type="mouseup";break;default:return;} -var simulatedEvent=document.createEvent("MouseEvent");simulatedEvent.initMouseEvent(type,true,true,window,1,first.screenX,first.screenY,first.clientX,first.clientY,false,false,false,false,0,null);first.target.dispatchEvent(simulatedEvent);event.preventDefault();} -function handelImportGraph(files){var graphFileToLoad=files[0];var fileReader=new FileReader();fileReader.onload=function(fileLoadedEvent){var textFromFileLoaded=fileLoadedEvent.target.result;console.log(textFromFileLoaded);editor.application.LoadGraphFromString(textFromFileLoaded);ImportGraphFiles.value="";};fileReader.readAsText(graphFileToLoad,"UTF-8");} -function postLoadPage() -{if(!PostLoadedCalled) -{loadTexts();editor.init();PostLoadedCalled=true;}} -$(document).ready(function() -{window.onresize=function(event) -{resizeCanvas();} -document.getElementById('canvas').addEventListener("touchstart",touchHandler,true);document.getElementById('canvas').addEventListener("touchmove",touchHandler,true);document.getElementById('canvas').addEventListener("touchend",touchHandler,true);document.getElementById('canvas').addEventListener("touchcancel",touchHandler,true);var isMobile=navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i);if(!isMobile&&!DisableEmscripten){let fullPathToGraphffoline="features/graphoffline/Graphoffline.Emscripten.js"+"?v="+globalVersion;doIncludeAsync([include(fullPathToGraphffoline),],()=>{Module['onRuntimeInitialized']=onRuntimeInitialized;var process=Module.cwrap('ProcessAlgorithm','string',['string']);function onRuntimeInitialized(){editor.application.setEmscripten(process);}})}});moduleLoader.endCacheLoading(); \ No newline at end of file +moduleLoader.endCacheLoading(); \ No newline at end of file diff --git a/script/pages/create_graph_by_matrix/api/index.js.cache b/script/pages/create_graph_by_matrix/api/index.js.cache index a6debd0..9ca886c 100644 --- a/script/pages/create_graph_by_matrix/api/index.js.cache +++ b/script/pages/create_graph_by_matrix/api/index.js.cache @@ -1,92 +1,4 @@ -moduleLoader.beginCacheLoading(["/script/shared/utils.js?v=78","/script/pages/create_graph_by_matrix/model/createByMatrixMain.js?v=78","/script/pages/create_graph_by_matrix/model/main.js?v=78","/script/entities/graph/api/index.js?v=78","/script/shared/point.js?v=78","/script/entities/edge/api/index.js?v=78","/script/entities/edge/model/BaseEdge.js?v=78","/script/entities/edge/model/EdgeModel.js?v=78","/script/entities/vertex/api/index.js?v=78","/script/entities/vertex/model/BaseVertex.js?v=78","/script/entities/vertex/model/VertexModel.js?v=78","/script/entities/graph/model/Graph.js?v=78","/script/features/draw_graph/api/index.js?v=78","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=78","/script/features/draw_graph/model/EdgeStyle.js?v=78","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=78","/script/features/draw_graph/model/VertexShape.js?v=78","/script/features/draw_graph/model/VertexStyle.js?v=78","/script/features/draw_graph/model/BaseVertexDrawer.js?v=78","/script/features/algorithms/api/index.js?v=78","/script/features/algorithms/model/Algorithms.js?v=78","/script/features/algorithms/model/BaseTraversal.js?v=78","/script/features/base_handler/index.js?v=78","/script/features/default_handler/index.js?v=78","/script/features/add_vertices_handler/index.js?v=78","/script/features/connect_vertices_handler/index.js?v=78","/script/features/delete_objects_handler/index.js?v=78","/script/features/algorithm_handler/index.js?v=78","/script/features/serialization/api/index.js?v=78","/script/features/serialization/model/GraphMLCreator.js?v=78","/script/features/enum_vertices/EnumVertices.js?v=78","/script/pages/editor/model/texts.js?v=78","/script/pages/editor/model/UndoStack.js?v=78","/script/pages/editor/model/DiskSaveLoad.js?v=78","/script/pages/editor/model/Application.js?v=78","/script/pages/editor/ui/ya_metrika.js?v=78","/script/pages/editor/ui/editor.js?v=78","/script/pages/editor/ui/main.js?v=78",]);{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js"),include("model/createByMatrixMain.js",modulDir),include("model/main.js",modulDir)]);} -function gEncodeToHTML(str) -{if(typeof str!=='string') -return str;return str.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');} -function gDecodeFromHTML(str) -{if(typeof str!=='string') -return str;return str.replace(/'/g,"'").replace(/"/g,'"').replace(/>/g,'>').replace(/</g,'<').replace(/&/g,'&');} -function FullObjectCopy(obj) -{var newObj=Object.create(Object.getPrototypeOf(obj));return Object.assign(newObj,obj);} -function FullArrayCopy(arr) -{var res=[];arr.forEach(function(element){var copyElement=FullObjectCopy(element);res.push(copyElement);});return res;} -function formatString(string,params){return string.replace(/{(\d+)}/g,(match,index)=>{return typeof params[index]!=='undefined'?params[index]:match;});} -Array.prototype.swap=function(x,y){var b=this[x];this[x]=this[y];this[y]=b;return this;} -window.onload=function() -{if(document.getElementById('CreateByAdjacencyMatrix')) -{document.getElementById('CreateByAdjacencyMatrix').onclick=function() -{window.location="./?matrix="+$("#AdjacencyMatrixFieldPage").val();}}} -var g_MatrixSize=3;var g_ctrlPressed=false;function PackMatrix() -{var matrix="";for(i=0;i0?element.value:"0")+", ";} -matrix=matrix+"\n";} -return matrix;} -function getCharCode(event) -{if(event.which==null) -{return event.keyCode;} -if(event.which!=0) -{return event.which;} -return null;} -function getChar(event) -{var k=getCharCode(event) -return String.fromCharCode(k);} -function CopyMatrixToTextInput(event) -{document.getElementById("AdjacencyMatrixFieldPage").value=PackMatrix();if(event) -{var key=getChar(event);var code=getCharCode(event);console.log(key+" code="+code);if(g_ctrlPressed) -{var moveFocus=function(offsetX,offsetY) -{var focused_element=document.activeElement;if(focused_element&&focused_element.name.includes("field")) -{var name=focused_element.name;var coords=name.replace('field','').split("_");if(coords.length==2) -{var focusName="field"+(parseInt(coords[0])+offsetY)+"_"+(parseInt(coords[1])+offsetX) -var element=document.getElementsByName(focusName)[0];if(element) -{element.focus();}}}} -switch(code) -{case 38:{moveFocus(0,-1);break;} -case 40:{moveFocus(0,1);break;} -case 37:{moveFocus(-1,0);break;} -case 39:{moveFocus(1,0);break;}}}}} -function _ShowTextInput() -{$("#AdjacencyMatrixFieldPage").show();$("#MatrixForm").hide();$("#TextDescription").show();$("#MatrixDescription").hide();$("#idSeparatorList").show();} -function _ShowMatrixInput() -{$("#MatrixForm").show();$("#AdjacencyMatrixFieldPage").hide();$("#TextDescription").hide();$("#MatrixDescription").show();$("#idSeparatorList").hide();} -function ShowTextInput() -{_ShowTextInput();document.getElementById("showMatrix").className="btn btn-default";document.getElementById("showText").className="btn btn-default active";} -function ShowMatrixInput() -{_ShowMatrixInput();document.getElementById("showMatrix").className="btn btn-default active";document.getElementById("showText").className="btn btn-default";} -function CopyMatrixToMatrixInput() -{var graph=new Graph();var colsObj={};var rowsObj={};if(graph.TestAdjacencyMatrix($("#AdjacencyMatrixFieldPage").val(),rowsObj,colsObj)) -{var rows=rowsObj.rows;var cols=colsObj.cols;for(var i=g_MatrixSize;i0.0) -{context.globalAlpha=style.commonOpacity;context.fillStyle=style.commonColor;context.fillRect(-rect.minPoint.x,-rect.minPoint.y,rect.size().x+1,rect.size().y+1);this.DrawImage(style,width,height,position,scale);} -context.globalAlpha=oldOpacity;} -BaseBackgroundDrawer.prototype.DrawImage=function(style,width,height,position,scale) -{if(style.image==null){return;} -var context=this.context;context.clearRect(0,0,style.image.width,style.image.height);context.drawImage(style.image,0,0)} -const lineDashTypes=[[],[4,4],[12,12],[16,4,4,4],];const WeightTextCenter=0,WeightTextUp=1;const DefaultFontEdge="px sans-serif",DefaultMainTextFontSizeEdge=16,TopTextFontSizeDeltaEdge=-4;function BaseEdgeStyle() -{this.baseStyles=[];} -BaseEdgeStyle.prototype.GetStyle=function(baseStyle,object) -{this.baseStyles.forEach(function(element){var styleObject=globalApplication.GetStyle("edge",element,object);baseStyle=styleObject.GetStyle(baseStyle,object);});if(this.hasOwnProperty('weightText')) -baseStyle.weightText=this.weightText;if(this.hasOwnProperty('strokeStyle')) -baseStyle.strokeStyle=this.strokeStyle;if(this.hasOwnProperty('fillStyle')) -baseStyle.fillStyle=this.fillStyle;if(this.hasOwnProperty('textPadding')) -baseStyle.textPadding=this.textPadding;if(this.hasOwnProperty('textStrokeWidth')) -baseStyle.textStrokeWidth=this.textStrokeWidth;if(this.hasOwnProperty('lineDash')) -baseStyle.lineDash=this.lineDash;if(this.hasOwnProperty('additionalTextColor')) -baseStyle.additionalTextColor=this.additionalTextColor;if(this.hasOwnProperty('weightPosition')) -baseStyle.weightPosition=this.weightPosition;if(this.hasOwnProperty('mainTextFontSize')) -baseStyle.mainTextFontSize=this.mainTextFontSize;return this.FixNewFields(baseStyle);} -BaseEdgeStyle.prototype.FixNewFields=function(style) -{if(!style.hasOwnProperty('lineDash')) -style.lineDash=0;if(!style.hasOwnProperty('weightPosition')) -style.weightPosition=WeightTextCenter;if(!style.hasOwnProperty('mainTextFontSize')) -style.mainTextFontSize=DefaultMainTextFontSizeEdge;return style;} -BaseEdgeStyle.prototype.Clear=function() -{delete this.weightText;delete this.strokeStyle;delete this.fillStyle;delete this.textPadding;delete this.textStrokeWidth;delete this.lineDash;delete this.additionalTextColor;delete this.weightPosition;delete this.mainTextFontSize;} -BaseEdgeStyle.prototype.ShouldLoad=function(field) -{return field!="baseStyles";} -function CommonEdgeStyle() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#c7b7c7';this.weightText='#f0d543';this.fillStyle='#68aeba';this.textPadding=4;this.textStrokeWidth=2;this.lineDash=0;this.additionalTextColor='#c7b7c7';this.weightPosition=WeightTextCenter;} -CommonEdgeStyle.prototype=Object.create(BaseEdgeStyle.prototype);function CommonPrintEdgeStyle() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#000000';this.weightText='#000000';this.fillStyle='#FFFFFF';this.textPadding=4;this.textStrokeWidth=2;this.baseStyles.push("common");} -CommonPrintEdgeStyle.prototype=Object.create(BaseEdgeStyle.prototype);function SelectedEdgeStyle0() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#f0d543';this.weightText='#f0d543';this.fillStyle='#c7627a';this.baseStyles.push("common");} -SelectedEdgeStyle0.prototype=Object.create(BaseEdgeStyle.prototype);function SelectedEdgeStyle1() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#8FBF83';this.weightText='#8FBF83';this.fillStyle='#F9F9D5';this.baseStyles.push("selected");} -SelectedEdgeStyle1.prototype=Object.create(BaseEdgeStyle.prototype);function SelectedEdgeStyle2() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#8C4C86';this.weightText='#8C4C86';this.fillStyle='#253267';this.baseStyles.push("selected");} -SelectedEdgeStyle2.prototype=Object.create(BaseEdgeStyle.prototype);function SelectedEdgeStyle3() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#6188FF';this.weightText='#6188FF';this.fillStyle='#E97CF9';this.baseStyles.push("selected");} -SelectedEdgeStyle3.prototype=Object.create(BaseEdgeStyle.prototype);function SelectedEdgeStyle4() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#C6B484';this.weightText='#C6B484';this.fillStyle='#E0DEE1';this.baseStyles.push("selected");} -SelectedEdgeStyle4.prototype=Object.create(BaseEdgeStyle.prototype);function SelectedEdgePrintStyle() -{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#AAAAAA';this.weightText='#000000';this.fillStyle='#AAAAAA';this.baseStyles.push("printed");} -SelectedEdgePrintStyle.prototype=Object.create(BaseEdgeStyle.prototype);var DefaultSelectedEdgeStyles=[new SelectedEdgeStyle0(),new SelectedEdgeStyle1(),new SelectedEdgeStyle2(),new SelectedEdgeStyle3(),new SelectedEdgeStyle4()];var DefaultPrintSelectedEdgeStyles=[new SelectedEdgePrintStyle()];function BaseEdgeDrawer(context,drawObjects) -{if(drawObjects===undefined) -{drawObjects=null;} -this.context=context;this.drawObject=null;this.drawArc=null;this.startArrowDirection=null;this.finishArrowDirection=null;this.textCenterObject=null;this.getPointOnArc=null;if(drawObjects) -{if(drawObjects.hasOwnProperty("drawObject")) -this.drawObject=drawObjects.drawObject;if(drawObjects.hasOwnProperty("drawArc")) -this.drawArc=drawObjects.drawArc;if(drawObjects.hasOwnProperty("startArrowDirection")) -this.startArrowDirection=drawObjects.startArrowDirection;if(drawObjects.hasOwnProperty("finishArrowDirection")) -this.finishArrowDirection=drawObjects.finishArrowDirection;if(drawObjects.hasOwnProperty("textCenterObject")) -this.textCenterObject=drawObjects.textCenterObject;if(drawObjects.hasOwnProperty("getPointOnArc")) -this.getPointOnArc=drawObjects.getPointOnArc;}} -BaseEdgeDrawer.prototype.Draw=function(baseEdge,arcStyle) -{if(this.drawObject&&this.drawObject!=this) -{this.drawObject.Draw(baseEdge,arcStyle);return;} -this.SetupStyle(baseEdge,arcStyle);var lengthArrow=Math.max(baseEdge.model.width*4,8);var widthArrow=Math.max(baseEdge.model.width*2,4);var position1=baseEdge.vertex1.position;var position2=baseEdge.vertex2.position;var direction=position1.subtract(position2);direction.normalize(1.0);var positions=baseEdge.GetEdgePositionsShift();var hasStartStyle=!position1.equals(position2)&&baseEdge.GetStartEdgeStyle()!="";var hasFinishStyle=!position1.equals(position2)&&baseEdge.GetFinishEdgeStyle()!="";var arcPos1=positions[0];var arcPos2=positions[1];if(hasStartStyle) -{var dirArrow=this.GetStartArrowDirection(positions[0],positions[1],lengthArrow);arcPos1=arcPos1.add(dirArrow.multiply(lengthArrow/2));} -if(hasFinishStyle) -{var dirArrow=this.GetFinishArrowDirection(positions[0],positions[1],lengthArrow);arcPos2=arcPos2.add(dirArrow.multiply(-lengthArrow/2));} -this.DrawArc(arcPos1,arcPos2,arcStyle);this.context.fillStyle=this.context.strokeStyle;this.context.lineWidth=0;if(hasStartStyle) -{this.DrawArrow(positions[0],this.GetStartArrowDirection(positions[0],positions[1],lengthArrow),lengthArrow,widthArrow);} -if(hasFinishStyle) -{this.DrawArrow(positions[1],this.GetFinishArrowDirection(positions[0],positions[1],lengthArrow),lengthArrow,widthArrow);} -this.SetupStyle(baseEdge,arcStyle);if(arcStyle.weightPosition==WeightTextCenter) -{if(baseEdge.GetText().length>0) -{this.DrawWeight(positions[0],positions[1],baseEdge.GetText(),arcStyle,false);} -if(baseEdge.GetUpText().length>0) -{this.DrawUpText(positions[0],positions[1],baseEdge.GetUpText(),arcStyle,false,arcStyle.additionalTextColor,baseEdge.model.width/2+arcStyle.mainTextFontSize+4,arcStyle.mainTextFontSize);}} -else if(arcStyle.weightPosition==WeightTextUp) -{if(baseEdge.GetText().length>0) -{this.DrawUpText(positions[0],positions[1],baseEdge.GetText(),arcStyle,false,arcStyle.weightText,baseEdge.model.width/2+arcStyle.mainTextFontSize/2,arcStyle.mainTextFontSize);} -if(baseEdge.GetUpText().length>0) -{this.DrawUpText(positions[0],positions[1],baseEdge.GetUpText(),arcStyle,false,arcStyle.additionalTextColor,-baseEdge.model.width/2-(arcStyle.mainTextFontSize/2+4),arcStyle.mainTextFontSize);}}} -BaseEdgeDrawer.prototype.SetupStyle=function(baseEdge,arcStyle) -{this.context.lineWidth=baseEdge.model.width;this.context.strokeStyle=arcStyle.strokeStyle;this.context.fillStyle=arcStyle.fillStyle;this.model=baseEdge.model;this.style=arcStyle;} -BaseEdgeDrawer.prototype.DrawArc=function(position1,position2,arcStyle) -{if(this.drawArc&&this.drawArc!=this) -{this.drawArc.DrawArc(position1,position2,arcStyle);return;} -this.context.setLineDash(lineDashTypes[arcStyle.lineDash]);if(position1.equals(position2)) -{this.context.beginPath();this.context.arc(position1.x-Math.cos(this.model.GetLoopShiftAngel())*this.model.GetLoopSize(),position1.y-Math.sin(this.model.GetLoopShiftAngel())*this.model.GetLoopSize(),this.model.GetLoopSize(),0,2*Math.PI);this.context.stroke();} -else -{this.context.beginPath();this.context.moveTo(position1.x,position1.y);this.context.lineTo(position2.x,position2.y);this.context.stroke();} -this.context.setLineDash([]);} -BaseEdgeDrawer.prototype.DrawWeight=function(position1,position2,text,arcStyle,hasPair) -{var centerPoint=this.GetTextCenterPoint(position1,position2,hasPair,arcStyle);this.context.font="bold "+arcStyle.mainTextFontSize+"px sans-serif";this.context.textBaseline="middle";this.context.lineWidth=arcStyle.textStrokeWidth;this.context.fillStyle=arcStyle.fillStyle;var widthText=this.context.measureText(text).width;this.context.beginPath();this.context.rect(centerPoint.x-widthText/2-arcStyle.textPadding/2,centerPoint.y-arcStyle.mainTextFontSize/1.7-arcStyle.textPadding/2,widthText+arcStyle.textPadding,arcStyle.mainTextFontSize+arcStyle.textPadding);this.context.closePath();this.context.fill();this.context.stroke();this.context.fillStyle=arcStyle.weightText;this.context.fillText(text,centerPoint.x-widthText/2,centerPoint.y);} -BaseEdgeDrawer.prototype.DrawUpText=function(position1,position2,text,arcStyle,hasPair,color,offset,fontSize) -{var centerPoint=this.GetTextCenterPoint(position1,position2,hasPair,arcStyle);this.context.font=fontSize==null?"bold "+(DefaultMainTextFontSizeEdge+TopTextFontSizeDeltaEdge)+"px sans-serif":"bold "+(fontSize+TopTextFontSizeDeltaEdge)+"px sans-serif";this.context.textBaseline="middle";var widthText=this.context.measureText(text).width;this.context.fillStyle=color;var vectorEdge=new Point(position2.x-position1.x,position2.y-position1.y);var angleRadians=Math.atan2(vectorEdge.y,vectorEdge.x);if(angleRadians>Math.PI/2||angleRadians<-Math.PI/2) -{vectorEdge=new Point(position1.x-position2.x,position1.y-position2.y);angleRadians=Math.atan2(vectorEdge.y,vectorEdge.x);} -var normalize=vectorEdge.normal().normalizeCopy(offset);this.context.save();this.context.translate(centerPoint.x-normalize.x,centerPoint.y-normalize.y);this.context.rotate(angleRadians);this.context.textAlign="center";this.context.fillText(text,0,0);this.context.restore();} -BaseEdgeDrawer.prototype.DrawArrow=function(position,direction,length,width) -{var normal=direction.normal();var pointOnLine=position.subtract(direction.multiply(length));var point1=pointOnLine.add(normal.multiply(width));var point2=pointOnLine.add(normal.multiply(-width));this.context.beginPath();this.context.moveTo(position.x,position.y);this.context.lineTo(point1.x,point1.y);this.context.lineTo(point2.x,point2.y);this.context.lineTo(position.x,position.y);this.context.closePath();this.context.fill();} -BaseEdgeDrawer.prototype.GetStartArrowDirection=function(position1,position2,lengthArrow) -{if(this.startArrowDirection&&this.startArrowDirection!=this) -{return this.startArrowDirection.GetStartArrowDirection(position1,position2,lengthArrow);} -var direction=position1.subtract(position2);direction.normalize(1.0);return direction;} -BaseEdgeDrawer.prototype.GetFinishArrowDirection=function(position1,position2,lengthArrow) -{if(this.finishArrowDirection&&this.finishArrowDirection!=this) -{return this.finishArrowDirection.GetFinishArrowDirection(position1,position2,lengthArrow);} -var direction=position2.subtract(position1);direction.normalize(1.0);return direction;} -BaseEdgeDrawer.prototype.GetTextCenterPoint=function(position1,position2,hasPair,arcStyle) -{if(this.textCenterObject&&this.textCenterObject!=this) -{return this.textCenterObject.GetTextCenterPoint(position1,position2,hasPair,arcStyle);} -var textShift=Math.min(12/position1.subtract(position2).length(),0.4);var centerPoint=Point.interpolate(position1,position2,0.5);if(position1.equals(position2)) -{let sinVal=Math.sin(this.model.GetLoopShiftAngel());let cosVal=Math.cos(this.model.GetLoopShiftAngel());centerPoint.x=centerPoint.x-cosVal*this.model.GetLoopSize();centerPoint.y=centerPoint.y-(sinVal+Math.sign(sinVal)*1.0)*this.model.GetLoopSize();} -return centerPoint;} -BaseEdgeDrawer.prototype.GetPointOnArc=function(position1,position2,percent) -{if(this.getPointOnArc&&this.getPointOnArc!=this) -{return this.getPointOnArc.GetPointOnArc(position1,position2,percent);} -return Point.interpolate(position1,position2,percent);} -function ProgressArcDrawer(context,baseDrawer,progress) -{this.context=context;this.baseDrawer=baseDrawer;this.progress=progress;} -ProgressArcDrawer.prototype=Object.create(BaseEdgeDrawer.prototype);ProgressArcDrawer.prototype.Draw=function(baseEdge,arcStyle) -{this.baseDrawer.Draw(baseEdge,arcStyle);this.context.lineWidth=10;var positions=baseEdge.GetEdgePositionsShift();var progressSize=10;if(positions[0].equals(positions[1])) -{var sizeInRadian=progressSize/(2*Math.PI*this.baseDrawer.model.GetLoopSize())*6;this.context.beginPath();this.context.arc(positions[0].x-Math.cos(this.baseDrawer.model.GetLoopShiftAngel())*this.baseDrawer.model.GetLoopSize(),positions[0].y-Math.sin(this.baseDrawer.model.GetLoopShiftAngel())*this.baseDrawer.model.GetLoopSize(),this.baseDrawer.model.GetLoopSize(),this.progress*2*Math.PI,this.progress*2*Math.PI+sizeInRadian);this.context.stroke();} -else -{var startPosition=this.baseDrawer.GetPointOnArc(positions[0],positions[1],this.progress);var vectorOffset=positions[0].subtract(positions[1]).normalizeCopy(progressSize);var finishPosition=startPosition.add(vectorOffset);this.context.beginPath();this.context.moveTo(startPosition.x,startPosition.y);this.context.lineTo(finishPosition.x,finishPosition.y);this.context.stroke();}} -function CurvedArcDrawer(context,model) -{this.context=context;this.model=model;} -CurvedArcDrawer.prototype=Object.create(BaseEdgeDrawer.prototype);CurvedArcDrawer.prototype.DrawArc=function(position1,position2,arcStyle) -{this.context.setLineDash(lineDashTypes[arcStyle.lineDash]);if(position1.equals(position2)) -{this.context.beginPath();this.context.arc(position1.x-Math.cos(this.model.GetLoopShiftAngel())*this.model.GetLoopSize(),position1.y-Math.sin(this.model.GetLoopShiftAngel())*this.model.GetLoopSize(),this.model.GetLoopSize(),0,2*Math.PI);this.context.closePath();this.context.stroke();} -else -{var points=this.model.GetBezierPoints(position1,position2);var firstBezierPoint=points[0];var secondBezierPoint=points[1];this.context.beginPath();this.context.moveTo(position1.x,position1.y);this.context.bezierCurveTo(firstBezierPoint.x,firstBezierPoint.y,secondBezierPoint.x,secondBezierPoint.y,position2.x,position2.y);this.context.stroke();} -this.context.setLineDash([]);} -CurvedArcDrawer.prototype.GetStartArrowDirection=function(position1,position2,lengthArrow) -{var dist=position1.distance(position2);var direction=position1.subtract(this.model.GetCurvePoint(position1,position2,lengthArrow/dist));direction.normalize(1.0);return direction;} -CurvedArcDrawer.prototype.GetFinishArrowDirection=function(position1,position2,lengthArrow) -{var dist=position1.distance(position2);var direction=position2.subtract(this.model.GetCurvePoint(position1,position2,1.0-lengthArrow/dist));direction.normalize(1.0);return direction;} -CurvedArcDrawer.prototype.GetTextCenterPoint=function(position1,position2,hasPair,arcStyle) -{var centerPoint=this.model.GetCurvePoint(position1,position2,0.5) -if(position1.equals(position2)) -{let sinVal=Math.sin(this.model.GetLoopShiftAngel());let cosVal=Math.cos(this.model.GetLoopShiftAngel());centerPoint.x=centerPoint.x-cosVal*this.model.GetLoopSize();centerPoint.y=centerPoint.y-(sinVal+Math.sign(sinVal)*1.0)*this.model.GetLoopSize();} -return centerPoint;} -CurvedArcDrawer.prototype.GetPointOnArc=function(position1,position2,percent) -{return this.model.GetCurvePoint(position1,position2,percent);} -const VertexCircleShape=0,VertexSquareShape=1,VertexTriangleShape=2,VertexPentagonShape=3,VertexHomeShape=4,VertexTextboxShape=5;VertexSnowflakeShape=6;function GetSquarePoints(diameter) -{var res=[];var a=diameter;res.push(new Point(-a/2,-a/2));res.push(new Point(a/2,-a/2));res.push(new Point(a/2,a/2));res.push(new Point(-a/2,a/2));return res;} -function GetTrianglePoints(diameter) -{var res=[];var effectiveDiameter=diameter*1.5;var upOffset=effectiveDiameter/2;var downOffset=effectiveDiameter/4;var lrOffset=effectiveDiameter*3/(Math.sqrt(3)*4);res.push(new Point(0,-upOffset));res.push(new Point(lrOffset,downOffset));res.push(new Point(-lrOffset,downOffset));return res;} -function GetPentagonPoints(diameter) -{var res=[];var baseValue=diameter/2*1.2;res.push(new Point(0,-baseValue));res.push((new Point(0,-baseValue)).rotate(new Point(0,0),72));res.push((new Point(0,-baseValue)).rotate(new Point(0,0),72*2));res.push((new Point(0,-baseValue)).rotate(new Point(0,0),72*3));res.push((new Point(0,-baseValue)).rotate(new Point(0,0),72*4));res.push((new Point(0,-baseValue)).rotate(new Point(0,0),72*5));return res;} -function GetTextboxPoints(diameter,additional_data) -{var res=[];var width=diameter;var height=diameter;if(additional_data) -{var tempContext=document.createElement('canvas').getContext('2d');tempContext.font="bold "+additional_data.style.mainTextFontSize+ -DefaultFont;let metrics=tempContext.measureText(additional_data.text);width=metrics.width+diameter/2;let actualHeight=metrics.actualBoundingBoxAscent*1.6;height=Math.max(height,actualHeight);} -res.push(new Point(-width/2,-height/2));res.push(new Point(width/2,-height/2));res.push(new Point(width/2,height/2));res.push(new Point(-width/2,height/2));return res;} -function GetShowflakePoints(diameter) -{var res=[];var superSmallRadius=diameter*0.8/2;var smallRadius=diameter*0.95/2;var bigRadius=diameter*1.5/2;let angel=8;res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),-angel));res.push(new Point(smallRadius,0));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),angel));res.push(new Point(bigRadius,0).rotate(new Point(0,0),30));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60-angel));res.push(new Point(smallRadius,0).rotate(new Point(0,0),60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+angel));res.push(new Point(bigRadius,0).rotate(new Point(0,0),30+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60-angel));res.push(new Point(smallRadius,0).rotate(new Point(0,0),60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+angel));res.push(new Point(bigRadius,0).rotate(new Point(0,0),30+60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+60-angel));res.push(new Point(smallRadius,0).rotate(new Point(0,0),60+60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+60+angel));res.push(new Point(bigRadius,0).rotate(new Point(0,0),30+60+60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+60+60-angel));res.push(new Point(smallRadius,0).rotate(new Point(0,0),60+60+60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+60+60+angel));res.push(new Point(bigRadius,0).rotate(new Point(0,0),30+60+60+60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+60+60+60-angel));res.push(new Point(smallRadius,0).rotate(new Point(0,0),60+60+60+60+60));res.push(new Point(superSmallRadius,0).rotate(new Point(0,0),60+60+60+60+60+angel));res.push(new Point(bigRadius,0).rotate(new Point(0,0),30+60+60+60+60+60));return res;} -function GetPointsForShape(shape,diameter,additional_data=null) -{switch(parseInt(shape)) -{case VertexSquareShape:return GetSquarePoints(diameter);break;case VertexTriangleShape:return GetTrianglePoints(diameter);break;case VertexPentagonShape:return GetPentagonPoints(diameter);break;case VertexTextboxShape:return GetTextboxPoints(diameter,additional_data);break;case VertexSnowflakeShape:return GetShowflakePoints(diameter);break;default:return null;break;}} -function GetSizeForShape(shape,diameter) -{switch(parseInt(shape)) -{case VertexSquareShape:return diameter;break;case VertexTriangleShape:return diameter*1.5;break;case VertexPentagonShape:return diameter*1.2;break;case VertexTextboxShape:return diameter;break;case VertexSnowflakeShape:return diameter*1.5;break;default:return diameter;break;}} -const CommonTextCenter=0,CommonTextUp=1;const DefaultFont="px sans-serif",DefaultMainTextFontSize=16,TopTextFontSizeDelta=-4;function BaseVertexStyle() -{this.baseStyles=[];} -BaseVertexStyle.prototype.GetStyle=function(baseStyle,object) -{this.baseStyles.forEach(function(element){var styleObject=globalApplication.GetStyle("vertex",element,object);baseStyle=styleObject.GetStyle(baseStyle,object);});if(this.hasOwnProperty('lineWidth')) -baseStyle.lineWidth=this.lineWidth;if(this.hasOwnProperty('strokeStyle')) -baseStyle.strokeStyle=this.strokeStyle;if(this.hasOwnProperty('fillStyle')) -baseStyle.fillStyle=this.fillStyle;if(this.hasOwnProperty('mainTextColor')) -baseStyle.mainTextColor=this.mainTextColor;if(this.hasOwnProperty('shape')) -baseStyle.shape=this.shape;if(this.hasOwnProperty('upTextColor')) -baseStyle.upTextColor=this.upTextColor;if(this.hasOwnProperty('commonTextPosition')) -baseStyle.commonTextPosition=this.commonTextPosition;if(this.hasOwnProperty('mainTextFontSize')) -baseStyle.mainTextFontSize=this.mainTextFontSize;baseStyle.lineWidth=parseInt(baseStyle.lineWidth);return this.FixNewFields(baseStyle);} -BaseVertexStyle.prototype.FixNewFields=function(style) -{if(!style.hasOwnProperty('shape')) -style.shape=VertexCircleShape;if(!style.hasOwnProperty('commonTextPosition')) -style.commonTextPosition=CommonTextCenter;if(!style.hasOwnProperty('mainTextFontSize')) -style.mainTextFontSize=DefaultMainTextFontSize;return style;} -BaseVertexStyle.prototype.Clear=function() -{delete this.lineWidth;delete this.strokeStyle;delete this.fillStyle;delete this.mainTextColor;delete this.shape;delete this.upTextColor;delete this.commonTextPosition;delete this.lineWidth;delete this.mainTextFontSize;} -BaseVertexStyle.prototype.ShouldLoad=function(field) -{return field!="baseStyles";} -function CommonVertexStyle() -{BaseVertexStyle.apply(this,arguments);this.lineWidth=2;this.strokeStyle='#c7b7c7';this.fillStyle='#68aeba';this.mainTextColor='#f0d543';this.shape=VertexCircleShape;this.upTextColor='#68aeba';this.commonTextPosition=CommonTextCenter;this.baseStyles=[];} -CommonVertexStyle.prototype=Object.create(BaseVertexStyle.prototype);function CommonPrintVertexStyle() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#000000';this.fillStyle='#FFFFFF';this.mainTextColor='#000000';this.baseStyles.push("common");} -CommonPrintVertexStyle.prototype=Object.create(BaseVertexStyle.prototype);function SelectedVertexStyle0() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#f0d543';this.mainTextColor='#f0d543';this.fillStyle='#c7627a';this.baseStyles.push("common");} -SelectedVertexStyle0.prototype=Object.create(BaseVertexStyle.prototype);function SelectedVertexStyle1() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#7a9ba0';this.mainTextColor='#c3d2d5';this.fillStyle='#534641';this.baseStyles.push("selected");} -SelectedVertexStyle1.prototype=Object.create(BaseVertexStyle.prototype);function SelectedVertexStyle2() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#8C4C86';this.mainTextColor='#dbbdd8';this.fillStyle='#253267';this.baseStyles.push("selected");} -SelectedVertexStyle2.prototype=Object.create(BaseVertexStyle.prototype);function SelectedVertexStyle3() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#6188FF';this.mainTextColor='#6188FF';this.fillStyle='#E97CF9';this.baseStyles.push("selected");} -SelectedVertexStyle3.prototype=Object.create(BaseVertexStyle.prototype);function SelectedVertexStyle4() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#C6B484';this.mainTextColor='#C6B484';this.fillStyle='#E0DEE1';this.baseStyles.push("selected");} -SelectedVertexStyle4.prototype=Object.create(BaseVertexStyle.prototype);function SelectedPrintVertexStyle() -{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#000000';this.mainTextColor='#000000';this.fillStyle='#AAAAAA';this.baseStyles.push("printed");} -SelectedPrintVertexStyle.prototype=Object.create(BaseVertexStyle.prototype);var DefaultSelectedGraphStyles=[new SelectedVertexStyle0(),new SelectedVertexStyle1(),new SelectedVertexStyle2(),new SelectedVertexStyle3(),new SelectedVertexStyle4()];var DefaultPrintSelectedGraphStyles=[new SelectedPrintVertexStyle()];function BaseVertexDrawer(context) -{this.context=context;} -BaseVertexDrawer.prototype.Draw=function(baseGraph,graphStyle) -{this.SetupStyle(graphStyle);this.DrawShape(baseGraph);if(this.currentStyle.lineWidth!=0) -this.context.stroke();this.context.fill();var shapeSize=GetSizeForShape(graphStyle.shape,baseGraph.model.diameter+graphStyle.lineWidth);if(graphStyle.commonTextPosition==CommonTextCenter) -{this.DrawCenterText(baseGraph.position,baseGraph.mainText,graphStyle.mainTextColor,graphStyle.fillStyle,true,true,graphStyle.mainTextFontSize);this.DrawCenterText(baseGraph.position.add(new Point(0,-shapeSize/2.0-graphStyle.mainTextFontSize/2.2)),baseGraph.upText,graphStyle.upTextColor,graphStyle.strokeStyle,false,false,graphStyle.mainTextFontSize+TopTextFontSizeDelta);} -else if(graphStyle.commonTextPosition==CommonTextUp) -{this.DrawCenterText(baseGraph.position.add(new Point(0,-shapeSize/2.0-graphStyle.mainTextFontSize/2.2)),baseGraph.mainText,graphStyle.mainTextColor,graphStyle.fillStyle,true,false,graphStyle.mainTextFontSize);this.DrawCenterText(baseGraph.position.add(new Point(0,shapeSize/2.0+graphStyle.mainTextFontSize/1.7)),baseGraph.upText,graphStyle.upTextColor,graphStyle.strokeStyle,false,false,graphStyle.mainTextFontSize+TopTextFontSizeDelta);}} -BaseVertexDrawer.prototype.SetupStyle=function(style) -{this.currentStyle=style;this.context.lineWidth=style.lineWidth;this.context.strokeStyle=style.strokeStyle;this.context.fillStyle=style.fillStyle;} -BaseVertexDrawer.prototype.DrawShape=function(baseGraph) -{this.context.beginPath();if(this.currentStyle.shape==VertexCircleShape) -{this.context.arc(baseGraph.position.x,baseGraph.position.y,baseGraph.model.diameter/2.0,0,2*Math.PI);} -else -{var points=GetPointsForShape(this.currentStyle.shape,baseGraph.model.diameter,{style:this.currentStyle,text:baseGraph.mainText});this.context.moveTo(baseGraph.position.x+points[points.length-1].x,baseGraph.position.y+points[points.length-1].y);var context=this.context;points.forEach(function(point){context.lineTo(baseGraph.position.x+point.x,baseGraph.position.y+point.y);});} -this.context.closePath();} -BaseVertexDrawer.prototype.DrawText=function(position,text,color,outlineColor,outline,font) -{this.context.fillStyle=color;this.context.font=font;this.context.lineWidth=4;this.context.strokeStyle=outlineColor;if(outline) -{this.context.save();this.context.lineJoin='round';this.context.strokeText(text,position.x,position.y);this.context.restore();} -this.context.fillText(text,position.x,position.y);} -BaseVertexDrawer.prototype.DrawCenterText=function(position,text,color,outlineColor,bold,outline,size) -{this.context.textBaseline="middle";this.context.font=(bold?"bold ":"")+size+DefaultFont;var textWidth=this.context.measureText(text).width;this.DrawText(new Point(position.x-textWidth/2,position.y),text,color,outlineColor,outline,this.context.font);} -{let modulDir="features/algorithms/";doInclude([include("model/Algorithms.js",modulDir),include("model/BaseTraversal.js",modulDir)]) -function loadAsyncAlgorithms(onFinish){let modulDir="features/algorithms/";let pluginsList=["BFS.js","Coloring.js","ConnectedComponent.js","DFS.js","EulerianLoop.js","EulerianPath.js","FindAllPatches.js","FindLongestPath.js","FindShortPatchsFromOne.js","Floid.js","GraphReorder.js","HamiltonianLoop.js","HamiltonianPath.js","IsomorphismCheck.js","MaxClique.js","MaxFlow.js","MinimumSpanningTree.js","ModernGraphStyle.js","RadiusAndDiameter.js","ShortestPath.js","VerticesDegree.js"];doIncludeAsync(pluginsList.map((plugin)=>include("model/plugins/"+plugin+"?v="+globalVersion,modulDir)),onFinish);}} -function getVertexToVertexArray(graph,ignoreDirection) -{res={};for(var i=0;iprocessData+=delimiter+param.name+delimiter+param.value);var res=this.app.processEmscripten(processData);processResult(res);}else{console.log("Use new CGI");var queryString=algorithmName+"=cgiInput&report=xml";otherParams.forEach((param)=>queryString+="&"+param.name+"="+param.value);$.ajax({type:"POST",url:"/"+SiteDir+"cgi-bin/GraphCGI.exe?"+queryString,data:xml,dataType:"text",}).done(function(msg) -{processResult(msg);});} -return true;} -BaseAlgorithmEx.prototype.GetNodesPath=function(array,start,count) -{var res=[];for(var index=start;index0?element.value:"0")+", ";} +matrix=matrix+"\n";} +return matrix;} +function getCharCode(event) +{if(event.which==null) +{return event.keyCode;} +if(event.which!=0) +{return event.which;} return null;} -BaseHandler.prototype.GetSelectedObject=function(pos) -{var graphObject=this.GetSelectedGraph(pos);if(graphObject) -{return graphObject;} -var arcObject=this.GetSelectedArc(pos);if(arcObject) -{return arcObject;} -return null;} -BaseHandler.prototype.GetUpText=function(object) -{return"";} -BaseHandler.prototype.GetMessage=function() -{return this.message;} -BaseHandler.prototype.MouseMove=function(pos){} -BaseHandler.prototype.MouseDown=function(pos){} -BaseHandler.prototype.MouseUp=function(pos){} -BaseHandler.prototype.GetSelectedGroup=function(object) -{return 0;} -BaseHandler.prototype.InitControls=function() -{var vertex1Text=document.getElementById("Vertex1");if(vertex1Text) -{var handler=this;vertex1Text.onchange=function(){for(var i=0;i"+"";for(var i=0;i";} -return res+"";} -BaseHandler.prototype.GetSelect2VertexMenu=function() -{return""+ -this.GetSelectVertexMenu("Vertex1")+" → "+this.GetSelectVertexMenu("Vertex2")+"";} -BaseHandler.prototype.SelectFirstVertexMenu=function(vertex1Text,vertex) -{} -BaseHandler.prototype.UpdateFirstVertexMenu=function() -{} -BaseHandler.prototype.SelectSecondVertexMenu=function(vertex2Text,vertex) -{} -BaseHandler.prototype.UpdateSecondVertexMenu=function() -{} -BaseHandler.prototype.GetSelectedVertex=function() -{return null;} -BaseHandler.prototype.addContextMenu=function() -{var $contextMenu=$("#contextMenu");var handler=this;$("#Context_Delete").click(function(){if(handler.contextMenuObject!=null){handler.app.PushToStack("DeleteObject");handler.app.DeleteObject(handler.contextMenuObject);handler.app.redrawGraph();userAction("DeleteObject_contextMenu");}});$("#Context_Rename").click(function(){if(handler.contextMenuObject!=null){var callback=function(enumType){handler.RenameVertex(enumType.GetVertexText(0),handler.contextMenuObject);userAction("RenameVertex_contextMenu");};var customEnum=new TextEnumVerticesCustom(handler.app);customEnum.ShowDialog(callback,g_rename,g_renameVertex,handler.contextMenuObject.mainText);}});$("#Context_Connect").click(function(){if(handler.contextMenuObject!=null&&handler.GetSelectedVertex()!=null){var addFunc=function(firstVertex,secondVertex,direct){handler.app.CreateNewArc(firstVertex,secondVertex,direct,document.getElementById('EdgeWeight').value,$("#RadiosReplaceEdge").prop("checked"),document.getElementById('EdgeLable').value);handler.app.redrawGraph();} -handler.ShowCreateEdgeDialog(handler.GetSelectedVertex(),handler.contextMenuObject,addFunc);}});$("#Context_Delete_Edge").click(function(){if(handler.contextMenuObject!=null){handler.app.PushToStack("DeleteObject");handler.app.DeleteObject(handler.contextMenuObject);handler.app.redrawGraph();userAction("DeleteObject_contextMenu");}});$("#Context_Edit_Edge").click(function(){if(handler.contextMenuObject!=null){handler.ShowEditEdgeDialog(handler.contextMenuObject);}});$("#Context_Add_Vertex").click(function(){handler.app.PushToStack("Add");handler.app.CreateNewGraph(handler.contextMenuPoint.x,handler.contextMenuPoint.y);handler.app.redrawGraph();});$("#Context_Back_Color").click(function(){var setupBackgroundStyle=new SetupBackgroundStyle(handler.app);setupBackgroundStyle.show();});$("body").on("contextmenu","canvas",function(e){handler.contextMenuPoint=handler.app.getMousePos(handler.app.canvas,e);handler.contextMenuObject=handler.GetSelectedObject(handler.contextMenuPoint);if(handler.contextMenuObject instanceof BaseVertex){$("#edgeContextMenu").hide();$("#backgroundContextMenu").hide();$("#vertexContextMenu").show();if(handler.GetSelectedVertex()==null){$("#Context_Connect").hide();}else{$("#Context_Connect").show();}}else if(handler.contextMenuObject instanceof BaseEdge){$("#vertexContextMenu").hide();$("#backgroundContextMenu").hide();$("#edgeContextMenu").show();}else{$("#vertexContextMenu").hide();$("#edgeContextMenu").hide();$("#backgroundContextMenu").show();} -$contextMenu.css({display:"block",left:e.offsetX,top:e.offsetY});return false;});$("body").click(function(){$contextMenu.hide();});} -BaseHandler.prototype.removeContextMenu=function() -{$("body").off("contextmenu");$("#Context_Delete").off("click");$("#Context_Rename").off("click");$("#Context_Connect").off("click");$("#Context_Delete_Edge").off("click");$("#Context_Edit_Edge").off("click");$("#Context_Add_Vertex").off("click");$("#Context_Back_Color").off("click");} -BaseHandler.prototype.RenameVertex=function(text,object) -{if(object!=null&&(object instanceof BaseVertex)) -{this.app.PushToStack("RenameVertex");object.mainText=text;this.app.redrawGraph();}} -BaseHandler.prototype.ShowCreateEdgeDialog=function(firstVertex,secondVertex,addEdgeCallBack){if(!this.app.graph.isMulti()) -{var hasEdge=this.app.graph.FindEdgeAny(firstVertex.id,secondVertex.id);var hasReverseEdge=this.app.graph.FindEdgeAny(secondVertex.id,firstVertex.id);if(hasEdge==null&&hasReverseEdge==null) -{$("#RadiosReplaceEdge").prop("checked",true);$("#NewEdgeAction").hide();} -else{$("#NewEdgeAction").show();}} +function getChar(event) +{var k=getCharCode(event) +return String.fromCharCode(k);} +function CopyMatrixToTextInput(event) +{document.getElementById("AdjacencyMatrixFieldPage").value=PackMatrix();if(event) +{var key=getChar(event);var code=getCharCode(event);console.log(key+" code="+code);if(g_ctrlPressed) +{var moveFocus=function(offsetX,offsetY) +{var focused_element=document.activeElement;if(focused_element&&focused_element.name.includes("field")) +{var name=focused_element.name;var coords=name.replace('field','').split("_");if(coords.length==2) +{var focusName="field"+(parseInt(coords[0])+offsetY)+"_"+(parseInt(coords[1])+offsetX) +var element=document.getElementsByName(focusName)[0];if(element) +{element.focus();}}}} +switch(code) +{case 38:{moveFocus(0,-1);break;} +case 40:{moveFocus(0,1);break;} +case 37:{moveFocus(-1,0);break;} +case 39:{moveFocus(1,0);break;}}}}} +function _ShowTextInput() +{$("#AdjacencyMatrixFieldPage").show();$("#MatrixForm").hide();$("#TextDescription").show();$("#MatrixDescription").hide();$("#idSeparatorList").show();} +function _ShowMatrixInput() +{$("#MatrixForm").show();$("#AdjacencyMatrixFieldPage").hide();$("#TextDescription").hide();$("#MatrixDescription").show();$("#idSeparatorList").hide();} +function ShowTextInput() +{_ShowTextInput();document.getElementById("showMatrix").className="btn btn-default";document.getElementById("showText").className="btn btn-default active";} +function ShowMatrixInput() +{_ShowMatrixInput();document.getElementById("showMatrix").className="btn btn-default active";document.getElementById("showText").className="btn btn-default";} +function CopyMatrixToMatrixInput() +{var graph=new Graph();var colsObj={};var rowsObj={};if(graph.TestAdjacencyMatrix($("#AdjacencyMatrixFieldPage").val(),rowsObj,colsObj)) +{var rows=rowsObj.rows;var cols=colsObj.cols;for(var i=g_MatrixSize;i"+g_DefaultWeightPreset+"";for(var i=0;i"+edgePreset+"";} -document.getElementById("EdgesPresets").innerHTML=presetsStr;document.getElementById('EdgeLable').value="";$("#addEdge").dialog({resizable:false,height:"auto",width:"auto",modal:true,title:g_addEdge,buttons:dialogButtons,dialogClass:'EdgeDialog',open:function(){$(this).off('submit').on('submit',function(){return false;});setTimeout(function(){const weightInput=document.getElementById('EdgeWeight');if(weightInput) -{weightInput.focus();weightInput.select();}},0);}});} -BaseHandler.prototype.ShowEditEdgeDialog=function(edgeObject){var dialogButtons={};var handler=this;dialogButtons[g_save]=function(){handler.app.PushToStack("ChangeEdge");edgeObject.SetWeight(document.getElementById('EdgeWeight').value);edgeObject.SetUpText(document.getElementById('EdgeLable').value);handler.needRedraw=true;handler.app.redrawGraph();userAction("ChangeWeight");$(this).dialog("close");};document.getElementById('EdgeWeight').value=edgeObject.useWeight?edgeObject.weight:g_noWeight;document.getElementById('EdgeWeightSlider').value=edgeObject.useWeight?edgeObject.weight:0;var edgePresets=handler.app.GetEdgePresets();var presetsStr=""+g_DefaultWeightPreset+"";for(var i=0;i"+edgePreset+"";} -document.getElementById("EdgesPresets").innerHTML=presetsStr;document.getElementById('EdgeLable').value=edgeObject.upText;$("#CheckSaveDefaultEdge").prop("checked",false);$("#defaultEdgeDialogBlock").hide();$("#addEdge").dialog({resizable:false,height:"auto",width:"auto",modal:true,title:g_editWeight,buttons:dialogButtons,dialogClass:'EdgeDialog',open:function(){$(handler).off('submit').on('submit',function(){return false;});}});} -doInclude([include("features/base_handler/index.js")]) -function DefaultHandler(app) -{this.removeStack=true;BaseHandler.apply(this,arguments);this.message=g_textsSelectAndMove+" "+g_selectGroupText+""+" "+g_useContextMenuText+"";this.selectedObjects=[];this.dragObject=null;this.selectedObject=null;this.prevPosition=null;this.groupingSelect=false;this.selectedLogRect=false;this.selectedLogCtrl=false;this.saveUndo=false;this.addContextMenu();} -DefaultHandler.prototype=Object.create(BaseHandler.prototype);DefaultHandler.prototype.pressed=false;DefaultHandler.prototype.curveValue=0.1;DefaultHandler.prototype.GetSelectedVertex=function() -{return(this.selectedObject instanceof BaseVertex)?this.selectedObject:null;} -DefaultHandler.prototype.MouseMove=function(pos) -{if(this.dragObject) -{if(!this.saveUndo) -{this.app.PushToStack("Move");this.saveUndo=true;} -this.dragObject.position.x=pos.x;this.dragObject.position.y=pos.y;this.needRedraw=true;} -else if(this.selectedObjects.length>0&&this.pressed&&!this.groupingSelect) -{if(!this.saveUndo) -{this.app.PushToStack("Move");this.saveUndo=true;} -var offset=(new Point(pos.x,pos.y)).subtract(this.prevPosition);for(var i=0;i0||this.selectedObject!=null)&&selectedObject!=null) -{if(this.selectedObjects.length==0) -{this.selectedObjects.push(this.selectedObject);this.selectedObject=null;this.selectedObjects.push(selectedObject);} -else if(!this.selectedObjects.includes(selectedObject)) -{this.selectedObjects.push(selectedObject);} -else if(severalSelect&&this.selectedObjects.includes(selectedObject)) -{var index=this.selectedObjects.indexOf(selectedObject);this.selectedObjects.splice(index,1);} -if(!this.selectedLogCtrl) -{userAction("GroupSelected.SelectCtrl");this.selectedLogCtrl=true;}} -else -{if(selectedObject!=null) -{this.selectedObject=selectedObject;} -if((selectedObject instanceof BaseVertex)&&selectedObject!=null) -{this.dragObject=selectedObject;this.message=g_moveCursorForMoving;}} -this.needRedraw=true;this.pressed=true;this.prevPosition=pos;this.app.canvas.style.cursor="move";} -DefaultHandler.prototype.MouseUp=function(pos) -{this.saveUndo=false;this.message=g_textsSelectAndMove+" "+g_selectGroupText+""+" "+g_useContextMenuText+"";this.dragObject=null;this.pressed=false;this.app.canvas.style.cursor="auto";this.app.SetSelectionRect(null);this.groupingSelect=false;if(this.selectedObject!=null&&(this.selectedObject instanceof BaseVertex)) -{this.message=g_textsSelectAndMove -+"
" -+"" -+"" -+"
";var handler=this;var callback=function(enumType){handler.RenameVertex(enumType.GetVertexText(0),handler.selectedObject);userAction("RenameVertex");};$('#message').unbind();$('#message').on('click','#renameButton',function(){var customEnum=new TextEnumVerticesCustom(handler.app);customEnum.ShowDialog(callback,g_rename,g_renameVertex,handler.selectedObject.mainText);});$('#message').on('click','#changeCommonStyle',function(){var selectedVertices=handler.app.GetSelectedVertices();var setupVertexStyle=new SetupVertexStyle(handler.app);setupVertexStyle.show(0,selectedVertices);});$('#message').on('click','#changeSelectedStyle',function(){var selectedVertices=handler.app.GetSelectedVertices();var setupVertexStyle=new SetupVertexStyle(handler.app);setupVertexStyle.show(1,selectedVertices);});} -else if(this.selectedObject!=null&&(this.selectedObject instanceof BaseEdge)) -{this.message=g_textsSelectAndMove -+"" -+" "+g_curveEdge+" " -+"   " -+"
" -+"" -+"" -+"
";var handler=this;$('#message').unbind();$('#message').on('click','#editEdge',function(){handler.ShowEditEdgeDialog(handler.selectedObject);});$('#message').on('click','#incCurvel',function(){handler.app.PushToStack("ChangeCurvelEdge");handler.selectedObject.model.ChangeCurveValue(DefaultHandler.prototype.curveValue);handler.needRedraw=true;handler.app.redrawGraph();userAction("Edge.Bend");});$('#message').on('click','#decCurvel',function(){handler.app.PushToStack("ChangeCurvelEdge");handler.selectedObject.model.ChangeCurveValue(-DefaultHandler.prototype.curveValue);handler.needRedraw=true;handler.app.redrawGraph();userAction("Edge.Bend");});$('#message').on('click','#changeCommonStyle',function(){var selectedEdges=handler.app.GetSelectedEdges();var setupVertexStyle=new SetupEdgeStyle(handler.app);setupVertexStyle.show(0,selectedEdges);});$('#message').on('click','#changeSelectedStyle',function(){var selectedEdges=handler.app.GetSelectedEdges();var setupVertexStyle=new SetupEdgeStyle(handler.app);setupVertexStyle.show(1,selectedEdges);});} -else if(this.selectedObjects.length>0) -{this.message=g_dragGroupText+" "+g_selectGroupText+"";var hasVertices=false;var hasEdges=false;for(var i=0;i";this.message=this.message -+"    " -+"" -this.message=this.message -+"     " -+"" -+"
";var handler=this;$('#message').unbind();$('#message').on('click','#DublicateSelected',function(){handler.app.PushToStack("DublicateSelection");userAction("GroupSelected.Dublicate");var newSelected=[];var copyVertex={};for(var i=0;i=1) -{var curve=handler.app.GetAvailableCurveValue(neighborEdges,newObject);newObject.model.SetCurveValue(curve);}} -newSelected.push(newObject);}} -handler.selectedObjects=newSelected;handler.needRedraw=true;handler.app.redrawGraph();});$('#message').on('click','#RemoveSelected',function(){handler.app.PushToStack("RemoveSelection");userAction("GroupSelected.Remove");for(var i=0;i"+g_selectGroupText+"";});if(hasEdges){$('#message').on('click','#changeCommonStyleEdge',function(){var selectedEdges=handler.app.GetSelectedEdges();var setupVertexStyle=new SetupEdgeStyle(handler.app);setupVertexStyle.show(0,selectedEdges);});$('#message').on('click','#changeSelectedStyleEdge',function(){var selectedEdges=handler.app.GetSelectedEdges();var setupVertexStyle=new SetupEdgeStyle(handler.app);setupVertexStyle.show(1,selectedEdges);});} -if(hasVertices){$('#message').on('click','#changeCommonStyleVertex',function(){var selectedVertices=handler.app.GetSelectedVertices();var setupVertexStyle=new SetupVertexStyle(handler.app);setupVertexStyle.show(0,selectedVertices);});$('#message').on('click','#changeSelectedStyleVertex',function(){var selectedVertices=handler.app.GetSelectedVertices();var setupVertexStyle=new SetupVertexStyle(handler.app);setupVertexStyle.show(1,selectedVertices);});}} -this.needRedraw=true;} -DefaultHandler.prototype.GetSelectedGroup=function(object) -{return(object==this.dragObject)||(object==this.selectedObject)?1:0||this.selectedObjects.includes(object);} -DefaultHandler.prototype.SelectObjectInRect=function(rect) -{this.selectedObjects=[];var vertices=this.app.graph.vertices;for(var i=0;i" -+" " -+"" -+" "+baseMessage;} -ConnectionGraphHandler.checkUseDefaultEdge=function(elem,app) -{app.setUseDefaultEdge(elem.checked);app.updateMessage();};ConnectionGraphHandler.prototype.GetUseDefaultEdgeCheckBox=function(){if(!this.app.hasDefaultEdge()){return"";} -return"
"+""+" "+"
";} -ConnectionGraphHandler.prototype.InitControls=function(){BaseHandler.prototype.InitControls.call(this) -if(!this.app.hasDefaultEdge()){return;} -let app=this.app;$('#useDefaultEdge').unbind();$('#useDefaultEdge').change(function(){app.setUseDefaultEdge(this.checked);});$("#useDefaultEdge").prop("checked",this.app.getUseDefaultEdge());} -doInclude([include("features/base_handler/index.js")]) -function DeleteGraphHandler(app) -{this.removeStack=true;BaseHandler.apply(this,arguments);this.message=g_selectObjectToDelete;this.addContextMenu();} -DeleteGraphHandler.prototype=Object.create(BaseHandler.prototype);DeleteGraphHandler.prototype.MouseDown=function(pos) -{var selectedObject=this.GetSelectedObject(pos);if(!this.app.IsCorrectObject(selectedObject)) -return;this.app.PushToStack("Delete");this.app.DeleteObject(selectedObject);this.needRedraw=true;} -function DeleteAllHandler(app) -{BaseHandler.apply(this,arguments);} -DeleteAllHandler.prototype=Object.create(BaseHandler.prototype);DeleteAllHandler.prototype.clear=function() -{this.app.PushToStack("DeleteAll");this.app.graph=new Graph();this.app.savedGraphName="";this.needRedraw=true;} -doInclude([include("features/base_handler/index.js")]) -function AlgorithmGraphHandler(app,algorithm) -{BaseHandler.apply(this,arguments);this.algorithm=algorithm;this.SaveUpText();this.UpdateResultAndMessage();} -AlgorithmGraphHandler.prototype=Object.create(BaseHandler.prototype);AlgorithmGraphHandler.prototype.MouseMove=function(pos){} -AlgorithmGraphHandler.prototype.MouseDown=function(pos) -{this.app.setRenderPath([]);if(this.algorithm.instance()) -{this.app.SetDefaultHandler();} -else -{var selectedObject=this.GetSelectedGraph(pos);if(selectedObject&&(selectedObject instanceof BaseVertex)) -{if(this.algorithm.selectVertex(selectedObject)) -{this.needRedraw=true;} -this.UpdateResultAndMessage();} -else if(selectedObject&&(selectedObject instanceof BaseEdge)) -{if(this.algorithm.selectEdge(selectedObject)) -{this.needRedraw=true;} -this.UpdateResultAndMessage();} -else -{if(this.algorithm.deselectAll()) -{this.needRedraw=true;this.UpdateResultAndMessage();}}}} -AlgorithmGraphHandler.prototype.MouseUp=function(pos){} -AlgorithmGraphHandler.prototype.GetSelectedGroup=function(object) -{return this.algorithm.getObjectSelectedGroup(object);} -AlgorithmGraphHandler.prototype.RestoreAll=function() -{this.app.setRenderPath([]);if(this.algorithm.needRestoreUpText()) -{this.RestoreUpText();} -if(this.algorithm.wantRestore()) -{this.algorithm.restore();}} -AlgorithmGraphHandler.prototype.SaveUpText=function() -{this.vertexUpText={};var graph=this.app.graph;for(i=0;i";var directedHeader="";var undirectedHeader="";var defaultWeight=1.0;var weightKeyId="\"d0\"";var weightNode=""+""+defaultWeight+""+"";var xmlBody="";for(var i=0;i";} -var hasDirected=false;for(var i=0;i"+arc.weight+"";} -xmlBody=xmlBody+""+weightData+"":"/>")} -xml=mainHeader+weightNode+(hasDirected?directedHeader:undirectedHeader)+xmlBody+"" -return xml;} -function BaseEnumVertices(app,startNumber) -{this.app=app;this.startNumber=startNumber;} -BaseEnumVertices.prototype.GetVertexText=function(id) -{return this.startNumber+id;} -BaseEnumVertices.prototype.GetVertexTextAsync=function(callback) -{callback(this);} -BaseEnumVertices.prototype.GetText=function() -{return this.startNumber+", "+(this.startNumber+1)+", "+(this.startNumber+2)+"...";} -BaseEnumVertices.prototype.GetValue=function() -{return"Numbers"+this.startNumber;} -function TextEnumTitle(app,title) -{BaseEnumVertices.apply(this,arguments);this.pattern="";this.title=title;} -TextEnumTitle.prototype=Object.create(BaseEnumVertices.prototype);TextEnumTitle.prototype.GetVertexText=function(id) -{return this.title;} -function TextEnumVertices(app) -{BaseEnumVertices.apply(this,arguments);this.pattern="ABCDEFGHIJKLMNOPQRSTUVWXYZ";} -TextEnumVertices.prototype=Object.create(BaseEnumVertices.prototype);TextEnumVertices.prototype.GetVertexText=function(id) -{var res="";res=this.pattern[id%this.pattern.length]+res;while(id>=this.pattern.length) -{id=Math.floor(id/this.pattern.length)-1;res=this.pattern[id%this.pattern.length]+res;} -return res;} -TextEnumVertices.prototype.GetText=function() -{return"A, B, ... Z";} -TextEnumVertices.prototype.GetValue=function() -{return"Latin";} -function TextEnumVerticesCyr(app) -{TextEnumVertices.apply(this,arguments);this.pattern="АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ";} -TextEnumVerticesCyr.prototype=Object.create(TextEnumVertices.prototype);TextEnumVerticesCyr.prototype.GetText=function() -{return"А, Б, ... Я";} -TextEnumVerticesCyr.prototype.GetValue=function() -{return"Cyrillic";} -function TextEnumVerticesGreek(app) -{TextEnumVertices.apply(this,arguments);this.pattern="ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ";} -TextEnumVerticesGreek.prototype=Object.create(TextEnumVertices.prototype);TextEnumVerticesGreek.prototype.GetText=function() -{return"Α, Β, ... Ω";} -TextEnumVerticesGreek.prototype.GetValue=function() -{return"Greek";} -function TextEnumVerticesCustom(app) -{BaseEnumVertices.apply(this,arguments);this.pattern="";} -TextEnumVerticesCustom.prototype=Object.create(BaseEnumVertices.prototype);TextEnumVerticesCustom.prototype.GetText=function() -{return g_customEnumVertex;} -TextEnumVerticesCustom.prototype.GetValue=function() -{return"Custom";} -TextEnumVerticesCustom.prototype.GetVertexTextAsync=function(callback) -{this.ShowDialog(callback,g_addVertex,g_addVertex,"A");} -TextEnumVerticesCustom.prototype.ShowDialog=function(callback,buttonText,titleTitle,title) -{var dialogButtons={};app=this.app;dialogButtons[buttonText]=function(){app.PushToStack("RenameVertex");callback(new TextEnumTitle(app,$("#VertexTitle").val()));$(this).dialog("close");};$("#addVertex").dialog({resizable:false,height:"auto",width:"auto",modal:true,title:titleTitle,buttons:dialogButtons,dialogClass:'EdgeDialog',open:function(){$(this).off('submit').on('submit',function(){return false;});$("#VertexTitle").val(title);$("#VertexTitle").focus();}});} -var g_textsSelectAndMove="Drag objects";var g_moveCursorForMoving="Move cursor";var g_clickToAddVertex="Click to add vertex";var g_selectFirstVertexToConnect="Select first vertex to connect";var g_selectSecondVertexToConnect="Select second vertex to connect";var g_selectStartVertexForShortPath="Select start vertex for shortest path";var g_selectFinishVertexForShortPath="Select finish vertex for shortest path";var g_shortestPathResult="Shortest path is %d";var g_pathNotExists="Path does not exists";var g_selectObjectToDelete="Select object to delete";var g_addEdge="Add edge";var g_orintEdge="Directed";var g_notOrintEdge="Undirected";var g_adjacencyMatrixText="Adjacency Matrix";var g_save="Save";var g_cancel="Cancel";var g_save_graph="Save Graph";var g_shortestDistance="lowest-distance is ";var g_incidenceMatrixText="Incidence Matrix";var g_save_dialog="Save dialog";var g_close="close";var g_sickConnectedComponent="Sick connected component is ";var g_connectedComponent="Connected component is ";var g_what_do_you_think="What do you think about site?";var g_name="Name";var g_feedback="Feedback";var g_send="Send";var g_write_to_us="Write to us";var g_fixMatrix="Fix matrix";var g_readMatrixHelp="Matrix format help";var g_matrixWrongFormat="Matrix is wrong";var g_pairWrongFormat="Edge List is wrong";var g_fix="Fix" -var g_save_image_dialog="Save graph image";var g_fullReport="Full report";var g_shortReport="Short report";var g_hasEulerianLoop="Graph has Eulerian Loop";var g_hasNotEulerianLoop="Graph has not Eulerian Loop";var g_hasEulerianPath="Graph has Eulerian Path";var g_hasNotEulerianPath="Graph has not Eulerian Path";var g_processing="Processing...";var g_customEnumVertex="Custom";var g_addVertex="Add vertex";var g_renameVertex="Rename vertex";var g_rename="Rename";var g_language="en";var g_editWeight="Edit weight";var g_noWeight="No weight";var g_groupRename="Group rename";var g_vote="Vote";var g_recommendAlgorithm="Recommend algorithm";var g_graphOfMinDist="Graph of minimal distances.";var g_checkToSave="Check to save";var g_showDistMatrix="Show Distance matrix";var g_minDistMatrixText="Minimal distances matrix";var g_selectStartVertexForMaxFlow="Select source vertex for max flow";var g_selectFinishVertexForMaxFlow="Select sink vertex for max flow";var g_maxFlowResult="Maximum flow from %2 to %3 is %1";var g_flowNotExists="Flow from %1 to %2 does not exists";var g_sourceVertex="Source";var g_sinkVertex="Sink";var g_hasHamiltonianLoop="Graph has Hamiltonian Loop";var g_hasNotHamiltonianLoop="Graph has not Hamiltonian Loop";var g_hasHamiltonianPath="Graph has Hamiltonian Path";var g_hasNotHamiltonianPath="Graph has not Hamiltonian Path";var g_startTraversal="Select start traversal vector";var g_traversalOrder="Traversal order: ";var g_curveEdge="Curved edge";var g_Undo="Undo";var g_default="default";var g_vertexDraw="Vertex draw style";var g_edgeDraw="Edge draw style";var g_backgroundStyle="Background style";var g_GraphIsMultiMessage="Graph is multigraph";var g_GraphIsGeneralMessage="";var g_DefaultWeightPreset="no weight";var g_dragGroupText="Drag group.";var g_selectGroupText="Select using ctrl";var g_copyGroupeButton="Duplicate";var g_removeGroupeButton="Remove objects";var g_BFSName="Breadth-first search";var g_ColoringName="Graph coloring";var g_findConnectedComponent="Find connected components";var g_DFSName="Depth-first search";var g_EulerinLoopName="Find Eulerian cycle";var g_EulerinPath="Find Eulerian path";var g_FloidName="Floyd–Warshall algorithm";var g_GraphReorder="Arrange the graph";var g_HamiltoianCycleName="Find Hamiltonian cycle";var g_HamiltonianPath="Find Hamiltonian path";var g_MaxFlowName="Find Maximum flow";var g_minimumSpanningTree="Search of minimum spanning tree";var g_modernGraphStyleName="Visualization based on weight";var g_RadiusAndDiameter="Search graph radius and diameter";var g_findShortPathName="Find shortest path using Dijkstra's algorithm";var g_VerticesDegreeName="Calculate vertices degree";var g_SpanningTreeResult="Min Spanning Tree is";var g_SpanningTreeIgnoreDir="We ignored edges direction for calculation";var g_SpanningTreeNotConnected="Graph is not connected";var g_selectFirstGraphIsomorphismCheck="Select first graph for isomorphic check. Click to any node of graph";var g_selectSecondGraphIsomorphismCheck="Select second graph for isomorphic check. Click to any node of graph";var g_selectFirstGraphPatternCheck="Select a template graph by clicking to any node of graph";var g_selectSecondGraphForSearchSubgraph="Choose a graph in which we will look for isomorphic subgraphs. Click to any node of this graph";var g_graphsIsomorph="Graphs are isomorphic";var g_graphsNotIsomorph="Graphs are not isomorphic";var g_numberOfIsomorphSubgraphIs="Number of isomorphic subgraphs are ";var g_graphHasNoIsomorphSubgraph="Graph don't contain isomorphic subgraphs";var g_searchIsomorphSubgraph="Search isomorphic subgraphs";var g_subgraphNo="Isomorphic subgraph # ";var g_graphHasNoAtleast2Graphs="To use the algorithm, you need to create 2 separate graphs";var g_IsomorphismCheck="Check Graphs Isomorphism";var g_graphIsDisconnected="Graph is disconnected";var g_graphIsTrivial="Graph contains only one vertex";var g_graphRadius="Graph radius";var g_graphDiameter="Graph diameter";var g_vertexCentral="Central";var g_vertexPeripheral="Peripheral";var g_maximumDegreeOfGraph="The maximum degree of a graph is";var g_colorNumber="Color number is";var g_done="Done";var g_action="Action";var g_commonEdgeStyle="Common Edge Style";var g_selectedEdgeStyle="Selected Edge Style";var g_commonVertexStyle="Common Vertex Style";var g_selectedVertexStyle="Selected Vertex Style";var g_findAllPathes="Find all paths";var g_numberOfPathesFrom="Number of paths from " -var g_to=" to ";var g_are=" are ";var g_pathN="Path #";var g_selectFinishVertex="Select finish vertex";var g_selectStartVertex="Select start vertex";var g_findAllPathesFromVertex="Find all shortest paths from vertex";var g_distanceFrom="Distance from ";var g_pathTo="Path to ";var g_useContextMenuText="Use context menu for addition actions." -var g_findLongestPath="Find the longest path";var g_LengthOfLongestPathFrom="Length of the longest path from ";var g_additionalActions="Additional actions";var g_reverseAllEdges="Reverse all edges";var g_makeAllUndirected="Make all edges undirected";var g_makeAllDirected="Make all edges directed";var g_reuseSavedEdge="Reuse saved edge";var g_MaxClique="Max Clique";var g_MaxCliqueNotFound="Max Clique is not found";var g_MaxCliqueSizeIs="Max Clique size is ";var g_MaxCliqueContains=". Clique contains these vertecies: ";var g_wrongImageFormatPNGAndJPEG="Wrong image format. We support only JPEG and PNG.";var g_wrongImageSizeP1="Image size is too big. Image size must be less than {0} pixels.";function loadTexts() -{g_textsSelectAndMove=document.getElementById("SelectAndMoveObject").innerHTML;g_moveCursorForMoving=document.getElementById("MoveCursorForMoving").innerHTML;g_clickToAddVertex=document.getElementById("clickToAddVertex").innerHTML;g_selectFirstVertexToConnect=document.getElementById("selectFisrtVertextToConnect").innerHTML;g_selectSecondVertexToConnect=document.getElementById("selectSecondVertextToConnect").innerHTML;g_selectStartVertexForShortPath=document.getElementById("selectStartShortPathVertex").innerHTML;g_selectFinishVertexForShortPath=document.getElementById("selectFinishShortPathVertex").innerHTML;g_shortestPathResult=document.getElementById("shortPathResult").innerHTML;g_pathNotExists=document.getElementById("pathNotExists").innerHTML;g_selectObjectToDelete=document.getElementById("selectObjectToDelete").innerHTML;g_addEdge=document.getElementById("AddEdge").innerHTML;g_orintEdge=document.getElementById("OrintEdge").innerHTML;g_notOrintEdge=document.getElementById("NotOrintdge").innerHTML;g_adjacencyMatrixText=document.getElementById("AdjacencyMatrixText").innerHTML;g_save=document.getElementById("Save").innerHTML;g_cancel=document.getElementById("Cancel").innerHTML;g_shortestDistance=document.getElementById("shortestDist").innerHTML;g_incidenceMatrixText=document.getElementById("IncidenceMatrixText").innerHTML;g_save_dialog=document.getElementById("saveDialogTitle").innerHTML;g_close=document.getElementById("closeButton").innerHTML;g_sickConnectedComponent=document.getElementById("sickConnectedComponentResult").innerHTML;g_connectedComponent=document.getElementById("connectedComponentResult").innerHTML;g_what_do_you_think=document.getElementById("whatDoYouThink").innerHTML;g_name=document.getElementById("name").innerHTML;g_feedback=document.getElementById("feedback").innerHTML;g_send=document.getElementById("send").innerHTML;g_write_to_us=document.getElementById("writeToUs").innerHTML;g_fixMatrix=document.getElementById("fixMatrixButton").innerHTML;g_readMatrixHelp=document.getElementById("matrixHelp").innerHTML;g_matrixWrongFormat=document.getElementById("wronMatrixTitle").innerHTML;g_save_image_dialog=document.getElementById("saveImageDialogTitle").innerHTML;g_fullReport=document.getElementById("fullReport").innerHTML;g_shortReport=document.getElementById("shortReport").innerHTML;g_hasEulerianLoop=document.getElementById("hasEulerianLoop").innerHTML;g_hasNotEulerianLoop=document.getElementById("hasNotEulerianLoop").innerHTML;g_processing=document.getElementById("processing").innerHTML;g_customEnumVertex=document.getElementById("customEnumVertex").innerHTML;g_addVertex=document.getElementById("addVertexText").innerHTML;g_renameVertex=document.getElementById("renameVertex").innerHTML;g_rename=document.getElementById("renameText").innerHTML;g_language=document.getElementById("currentLanguage").innerHTML;g_editWeight=document.getElementById("editWeight").innerHTML;g_noWeight=document.getElementById("noWeight").innerHTML;g_groupRename=document.getElementById("groupeRenameText").innerHTML;g_vote=document.getElementById("voteText").innerHTML;g_recommendAlgorithm=document.getElementById("recommend_algorithm").innerHTML;g_hasEulerianPath=document.getElementById("hasEulerianPath").innerHTML;g_hasNotEulerianPath=document.getElementById("hasNotEulerianPath").innerHTML;g_graphOfMinDist=document.getElementById("graphOfMinDist").innerHTML;g_checkToSave=document.getElementById("checkToSave").innerHTML;g_showDistMatrix=document.getElementById("showDistMatrix").innerHTML;g_minDistMatrixText=document.getElementById("distMatrixText").innerHTML;g_selectStartVertexForMaxFlow=document.getElementById("selectStartVertexForMaxFlow").innerHTML;g_selectFinishVertexForMaxFlow=document.getElementById("selectFinishVertexForMaxFlow").innerHTML;g_maxFlowResult=document.getElementById("maxFlowResult").innerHTML;g_flowNotExists=document.getElementById("flowNotExists").innerHTML;g_sourceVertex=document.getElementById("sourceVertex").innerHTML;g_sinkVertex=document.getElementById("sinkVertex").innerHTML;g_hasHamiltonianLoop=document.getElementById("hasHamiltonianLoop").innerHTML;g_hasNotHamiltonianLoop=document.getElementById("hasNotHamiltonianLoop").innerHTML;g_hasHamiltonianPath=document.getElementById("hasHamiltonianPath").innerHTML;g_hasNotHamiltonianPath=document.getElementById("hasNotHamiltonianPath").innerHTML;g_startTraversal=document.getElementById("startTraversal").innerHTML;g_traversalOrder=document.getElementById("traversalOrder").innerHTML;g_curveEdge=document.getElementById("curveEdge").innerHTML;g_Undo=document.getElementById("undoTranslate").innerHTML;g_save_graph=document.getElementById("saveGraph").innerHTML;g_default=document.getElementById("default").innerHTML;g_vertexDraw=document.getElementById("vertexDrawStyle").innerHTML;g_edgeDraw=document.getElementById("edgeDrawStyle").innerHTML;g_backgroundStyle=document.getElementById("backgroundStyle").innerHTML;g_GraphIsMultiMessage=document.getElementById("graphIsMultiMessage").innerHTML;g_GraphIsGeneralMessage=document.getElementById("graphIsGeneralMessage").innerHTML;g_DefaultWeightPreset=document.getElementById("defaultWeightPreset").innerHTML;var isMac=navigator.platform.toUpperCase().indexOf('MAC')>=0;if(isMac) -g_selectGroupText=document.getElementById("selectGroupMac").innerHTML;else -g_selectGroupText=document.getElementById("selectGroupWin").innerHTML;g_dragGroupText=document.getElementById("dragSelectedGroup").innerHTML;g_copyGroupeButton=document.getElementById("copySelectedGroup").innerHTML;g_removeGroupeButton=document.getElementById("removeSelectedGroup").innerHTML;g_BFSName=document.getElementById("BFSName").innerHTML;g_ColoringName=document.getElementById("ColoringName").innerHTML;g_findConnectedComponent=document.getElementById("findConnectedComponent").innerHTML;g_DFSName=document.getElementById("DFSName").innerHTML;g_EulerinLoopName=document.getElementById("EulerinLoopName").innerHTML;g_EulerinPath=document.getElementById("EulerinPath").innerHTML;g_FloidName=document.getElementById("FloidName").innerHTML;g_GraphReorder=document.getElementById("GraphReorder").innerHTML;g_HamiltoianCycleName=document.getElementById("HamiltoianCycleName").innerHTML;g_HamiltonianPath=document.getElementById("HamiltonianPath").innerHTML;g_MaxFlowName=document.getElementById("MaxFlowName").innerHTML;g_minimumSpanningTree=document.getElementById("minimumSpanningTree").innerHTML;g_modernGraphStyleName=document.getElementById("modernGraphStyleName").innerHTML;g_RadiusAndDiameter=document.getElementById("RadiusAndDiameter").innerHTML;g_findShortPathName=document.getElementById("findShortPathName").innerHTML;g_VerticesDegreeName=document.getElementById("VerticesDegreeName").innerHTML;g_SpanningTreeResult=document.getElementById("MinSpanningTreeResult").innerHTML;g_SpanningTreeIgnoreDir=document.getElementById("MinSpanningIgnoreDir").innerHTML;g_SpanningTreeNotConnected=document.getElementById("MinSpanningNotConnected").innerHTML;g_selectFirstGraphIsomorphismCheck=document.getElementById("SelectFirstGraphIsomorphismCheck").innerHTML;g_selectSecondGraphIsomorphismCheck=document.getElementById("SelectSecondGraphIsomorphismCheck").innerHTML;g_selectFirstGraphPatternCheck=document.getElementById("SelectFirstGraphPatternCheck").innerHTML;g_selectSecondGraphForSearchSubgraph=document.getElementById("SelectSecondGraphForSearchSubgraph").innerHTML;g_graphsIsomorph=document.getElementById("GraphsIsomorph").innerHTML;g_graphsNotIsomorph=document.getElementById("GraphsNotIsomorph").innerHTML;g_numberOfIsomorphSubgraphIs=document.getElementById("NumberOfIsomorphSubgraphIs").innerHTML;g_graphHasNoIsomorphSubgraph=document.getElementById("GraphHasNoIsomorphSubgraph").innerHTML;g_searchIsomorphSubgraph=document.getElementById("SearchIsomorphSubgraph").innerHTML;g_subgraphNo=document.getElementById("SubgraphNo").innerHTML;g_graphHasNoAtleast2Graphs=document.getElementById("GraphHasNoAtleast2Graphs").innerHTML;g_IsomorphismCheck=document.getElementById("IsomorphismCheck").innerHTML;g_graphIsDisconnected=document.getElementById("GraphIsDisconnected").innerHTML;g_graphIsTrivial=document.getElementById("GraphIsTrivial").innerHTML;g_graphRadius=document.getElementById("GraphRadius").innerHTML;g_graphDiameter=document.getElementById("GraphDiameter").innerHTML;g_vertexCentral=document.getElementById("VertexCentral").innerHTML;g_vertexPeripheral=document.getElementById("VertexPeripheral").innerHTML;g_maximumDegreeOfGraph=document.getElementById("MaximumDegreeOfGraph").innerHTML;g_colorNumber=document.getElementById("ColorNumber").innerHTML;g_done=document.getElementById("Done").innerHTML;g_action=document.getElementById("ActionText").innerHTML;g_commonEdgeStyle=document.getElementById("CommonEdgeStyleText").innerHTML;g_selectedEdgeStyle=document.getElementById("SelectedEdgeStyleText").innerHTML;g_commonVertexStyle=document.getElementById("CommonVertexStyleText").innerHTML;g_selectedVertexStyle=document.getElementById("SelectedVertexStyleText").innerHTML;g_findAllPathes=document.getElementById("FindAllPathes").innerHTML;g_numberOfPathesFrom=document.getElementById("NumberOfPathesFrom").innerHTML;g_to=document.getElementById("To").innerHTML;g_are=document.getElementById("Are").innerHTML;g_pathN=document.getElementById("PathN").innerHTML;g_selectFinishVertex=document.getElementById("SelectFinishVertex").innerHTML;g_selectStartVertex=document.getElementById("SelectStartVertex").innerHTML;g_findAllPathesFromVertex=document.getElementById("findAllPathsFromVertex").innerHTML;g_distanceFrom=document.getElementById("distanceFrom").innerHTML;g_pathTo=document.getElementById("pathTo").innerHTML;g_useContextMenuText=document.getElementById("UseContextMenuText").innerHTML;g_findLongestPath=document.getElementById("findLongestPath").innerHTML;g_LengthOfLongestPathFrom=document.getElementById("LengthOfLongestPathFrom").innerHTML;g_additionalActions=document.getElementById("additionlActions").innerHTML;g_reverseAllEdges=document.getElementById("reverseAllEdges").innerHTML;g_makeAllUndirected=document.getElementById("makeAllUndirected").innerHTML;g_makeAllDirected=document.getElementById("makeAllDirected").innerHTML;g_pairWrongFormat=document.getElementById("pairWrongFormat").innerHTML;g_fix=document.getElementById("fixButton").innerHTML;g_reuseSavedEdge=document.getElementById("reuseSavedEdge").innerHTML;g_MaxClique=document.getElementById("maxClique").innerHTML;g_MaxCliqueNotFound=document.getElementById("maxCliqueNotFound").innerHTML;g_MaxCliqueSizeIs=document.getElementById("maxCliqueSizeIs").innerHTML;g_MaxCliqueContains=document.getElementById("maxCliqueContains").innerHTML;g_wrongImageFormatPNGAndJPEG=document.getElementById("wrongImageFormatPNGAndJPEG").innerHTML;g_wrongImageSizeP1=document.getElementById("wrongImageSizeP1").innerHTML;} -function UndoStack(maxUndoStackSize){this.undoStack=[];this.maxUndoStackSize=maxUndoStackSize;} -UndoStack.prototype.PushToStack=function(actionName,dataToSave) -{var object={};object.actionName=actionName;object.data=dataToSave;this.undoStack.push(object);while(this.undoStack.length>this.maxUndoStackSize) -{this.undoStack.shift();}} -UndoStack.prototype.Undo=function() -{if(this.IsUndoStackEmpty()) -return null;var state=this.undoStack.pop();return state.data;} -UndoStack.prototype.ClearUndoStack=function() -{this.undoStack=[];} -UndoStack.prototype.IsUndoStackEmpty=function() -{return(this.undoStack.length<=0);} -var DiskSaveLoad=function(){};DiskSaveLoad.LoadGraphFromDisk=function(graphName,callback) -{$.ajax({type:"GET",url:"/"+SiteDir+"cgi-bin/loadGraph.php?name="+graphName}).done(callback);} -DiskSaveLoad.SaveSVGGraphOnDisk=function(imageName,svgText,callback) -{$.ajax({type:"POST",url:"/"+SiteDir+"cgi-bin/saveSvg.php?name="+imageName,data:{svgdata:svgText},dataType:"text",success:callback});return imageName;} -DiskSaveLoad.SaveGraphOnDisk=function(savedGraphName,graphAsString,callback) -{$.ajax({type:"POST",url:"/"+SiteDir+"cgi-bin/saveGraph.php?name="+savedGraphName,data:graphAsString,dataType:"text"}).done(callback);} -DiskSaveLoad.SaveGraphImageOnDisk=function(imageName,rectParams,imageBase64Data,callback) -{$.ajax({type:"POST",url:"/"+SiteDir+"cgi-bin/saveImage.php?name="+imageName+rectParams,data:{base64data:imageBase64Data},dataType:"text",success:callback});} -var globalApplication=null;function Application(document,window,listener) -{this.document=document;this.listener=listener;this.canvas=this.document.getElementById('canvas');this.handler=new DefaultHandler(this);this.savedGraphName="";this.currentEnumVerticesType=new BaseEnumVertices(this,1);this.findPathReport=1;this.isTimerRender=false;globalApplication=this;this.renderPath=[];this.renderTimer=0;this.renderPathLength=0;this.renderPathCounter=0;this.renderPathLoops=0;this.enumVerticesTextList=[new BaseEnumVertices(this,1),new BaseEnumVertices(this,0),new TextEnumVertices(this),new TextEnumVerticesCyr(this),new TextEnumVerticesGreek(this),new TextEnumVerticesCustom(this)];this.SetDefaultTransformations();this.algorithmsValues={};this.undoStack=new UndoStack(this.maxUndoStackSize);this.edgeCommonStyle=new CommonEdgeStyle();this.isEdgeCommonStyleCustom=false;this.edgeSelectedStyles=FullArrayCopy(DefaultSelectedEdgeStyles);this.isEdgeSelectedStylesCustom=false;this.edgePrintCommonStyle=new CommonPrintEdgeStyle();this.edgePrintSelectedStyles=FullArrayCopy(DefaultPrintSelectedEdgeStyles);this.vertexCommonStyle=new CommonVertexStyle();this.isVertexCommonStyleCustom=false;this.vertexSelectedVertexStyles=FullArrayCopy(DefaultSelectedGraphStyles);this.isVertexSelectedVertexStylesCustom=false;this.vertexPrintCommonStyle=new CommonPrintVertexStyle();this.vertexPrintSelectedVertexStyles=FullArrayCopy(DefaultPrintSelectedGraphStyles);this.backgroundCommonStyle=new CommonBackgroundStyle();this.backgroundPrintStyle=new PrintBackgroundStyle();this.isBackgroundCommonStyleCustom=false;this.renderPathWithEdges=false;this.edgePresets=[1,3,5,7,11,42];this.maxEdgePresets=6;this.selectionRect=null;this.defaultVertexSize=null;this.defaultEdgeWidth=null;this.processEmscriptenFunction=null;this.defaultEdge=null;this.useDefaultEdge=false;};Application.prototype.graph=new Graph();Application.prototype.dragObject=-1;Application.prototype.handler=null;Application.prototype.status={};Application.prototype.graphNameLength=16;Application.prototype.maxUndoStackSize=8;Application.prototype.getMousePos=function(canvas,e) -{var rect=canvas.getBoundingClientRect();return{x:(e.clientX-rect.left)/this.canvasScale-this.canvasPosition.x,y:(e.clientY-rect.top)/this.canvasScale-this.canvasPosition.y};} -Application.prototype.redrawGraph=function() -{if(!this.isTimerRender) -{this._redrawGraphInWindow();this.GraphTypeChanged();}} -Application.prototype.redrawGraphTimer=function() -{if(this.isTimerRender) -{var context=this._redrawGraphInWindow();if(this.renderPath.length>1) -{context.save();context.scale(this.canvasScale,this.canvasScale);context.translate(this.canvasPosition.x,this.canvasPosition.y);var movePixelStep=16;var currentLength=0;var i=0 -for(i=0;ithis.renderPathCounter) -{currentLength-=edge.GetPixelLength();break;}} -if(i>=this.renderPath.length-1) -{i=0;if(this.renderPathWithEdges) -i=1;this.renderPathCounter=0;currentLength=0;this.renderPathLoops+=1;} -var edge=null;var currentVertexId=this.renderPath[i];if(this.renderPathWithEdges) -{edge=this.graph.FindEdgeById(this.renderPath[i]);currentVertexId=this.renderPath[i-1];} -else if(this.renderMinPath) -{edge=this.graph.FindEdgeMin(this.renderPath[i],this.renderPath[i+1]);} -else -{edge=this.graph.FindEdge(this.renderPath[i],this.renderPath[i+1]);} -var progress=(this.renderPathCounter-currentLength)/edge.GetPixelLength();this.RedrawEdgeProgress(context,edge,edge.vertex1.id==currentVertexId?progress:1.0-progress);this.renderPathCounter+=movePixelStep;context.restore();}} -if(this.renderPathLoops>=5) -{this.stopRenderTimer();}} -Application.prototype._redrawGraphInWindow=function() -{var context=this.canvas.getContext('2d');context.save();context.scale(this.canvasScale,this.canvasScale);context.translate(this.canvasPosition.x,this.canvasPosition.y);this._RedrawGraph(context,this.canvasPosition,this.backgroundCommonStyle,true);context.restore();return context;} -Application.prototype._OffscreenRedrawGraph=function() -{var bbox=this.graph.getGraphBBox();var canvas=document.createElement('canvas');canvas.width=bbox.size().x;canvas.height=bbox.size().y;var context=canvas.getContext('2d');context.save();context.translate(bbox.minPoint.inverse().x,bbox.minPoint.inverse().y);this._RedrawGraph(context,bbox.minPoint.inverse(),this.backgroundCommonStyle,false);context.restore();return canvas;} -Application.prototype._PrintRedrawGraph=function() -{var bbox=this.graph.getGraphBBox();var canvas=document.createElement('canvas');canvas.width=bbox.size().x;canvas.height=bbox.size().y;var context=canvas.getContext('2d');context.save();context.translate(bbox.minPoint.inverse().x,bbox.minPoint.inverse().y);this._RedrawGraph(context,bbox.minPoint.inverse(),this.backgroundPrintStyle,false,this.vertexPrintCommonStyle,this.vertexPrintSelectedVertexStyles,this.edgePrintCommonStyle,this.edgePrintSelectedStyles);context.restore();return canvas;} -Application.prototype._printToSVG=function() -{var bbox=this.graph.getGraphBBox();var context=new C2S(bbox.size().x,bbox.size().y);context.save();context.translate(bbox.minPoint.inverse().x,bbox.minPoint.inverse().y);this._RedrawGraph(context,bbox.minPoint.inverse(),this.backgroundCommonStyle,false);context.restore();return context.getSerializedSvg();} -Application.prototype.updateRenderPathLength=function() -{this.renderPathLength=0;this.renderPathCounter=0;if(this.renderPath.length>1) -{for(var i=0;i0) -{this.startRenderTimer();} -else -{this.stopRenderTimer();}} -Application.prototype.setRenderPathWithEdges=function(renderPath) -{this.renderPath=renderPath;this.renderMinPath=false;this.renderPathWithEdges=true;if(this.renderPath.length>0) -{this.startRenderTimer();} -else -{this.stopRenderTimer();}} -Application.prototype.GetBaseArcDrawer=function(context,edge) -{var arcDrawer=new BaseEdgeDrawer(context);if(edge.model.type==EdgeModels.curve) -{var curvedArcDrawer=new CurvedArcDrawer(context,edge.model);arcDrawer=new BaseEdgeDrawer(context,{drawArc:curvedArcDrawer,startArrowDirection:curvedArcDrawer,finishArrowDirection:curvedArcDrawer,textCenterObject:curvedArcDrawer,getPointOnArc:curvedArcDrawer});} -return arcDrawer;} -Application.prototype.UpdateEdgeCurrentStyle=function(edge,ForceCommonStyle,ForceSelectedStyle) -{var commonStyle=(ForceCommonStyle===undefined)?this.edgeCommonStyle:ForceCommonStyle;var selectedStyle=(ForceSelectedStyle===undefined)?this.edgeSelectedStyles:ForceSelectedStyle;var selectedGroup=this.handler.GetSelectedGroup(edge);var selected=false;if(selectedGroup>0) -{selectedGroup=(selectedGroup-1)%selectedStyle.length;selected=true;} -var currentStyle=null;if(edge.hasOwnStyleFor((selected?1:0)+selectedGroup)) -currentStyle=edge.getStyleFor((selected?1:0)+selectedGroup);else -currentStyle=selected?selectedStyle[selectedGroup]:commonStyle;edge.currentStyle=currentStyle;} -Application.prototype.RedrawEdge=function(context,edge) -{var curvedArcDrawer=new CurvedArcDrawer(context,edge.model) -var arcDrawer=this.GetBaseArcDrawer(context,edge);this._RedrawEdge(edge,arcDrawer);} -Application.prototype._RedrawEdge=function(edge,arcDrawer,commonStyle,selectedStyles) -{this._RedrawEdgeWithStyle(edge,edge.currentStyle,arcDrawer,commonStyle,selectedStyles);} -Application.prototype._RedrawEdgeWithStyle=function(edge,style,arcDrawer,commonStyle,selectedStyles) -{arcDrawer.Draw(edge,style.GetStyle({},edge));} -Application.prototype.RedrawEdgeProgress=function(context,edge,progress) -{var progressDraw=new ProgressArcDrawer(context,this.GetBaseArcDrawer(context,edge),progress);var arcDrawer=new BaseEdgeDrawer(context,{drawObject:progressDraw});this._RedrawEdge(edge,arcDrawer,this.edgeCommonStyle,this.edgeSelectedStyles);} -Application.prototype.UpdateEdgesCurrentStyle=function(ForceCommonStyle,ForceSelectedStyle) -{for(i=0;i0) -{selectedGroup=(selectedGroup-1)%selectedStyle.length;selected=true;} -var currentStyle=null;if(this.graph.vertices[i].hasOwnStyleFor((selected?1:0)+selectedGroup)&&!force) -currentStyle=this.graph.vertices[i].getStyleFor((selected?1:0)+selectedGroup);else -currentStyle=selected?selectedStyle[selectedGroup]:commonStyle;this.graph.vertices[i].currentStyle=currentStyle;}} -Application.prototype.RedrawSelectionRect=function(context) -{context.lineWidth=1.0/this.canvasScale;context.strokeStyle=this.edgeSelectedStyles[0].strokeStyle;context.setLineDash([6,3]);context.beginPath();context.rect(this.selectionRect.left(),this.selectionRect.top(),this.selectionRect.size().x,this.selectionRect.size().y);context.closePath();context.stroke();context.setLineDash([]);} -Application.prototype.updateMessage=function() -{this.listener.updateMessage(this.handler.GetMessage());this.handler.InitControls();} -Application.prototype.CanvasOnMouseMove=function(e) -{var pos=this.getMousePos(this.canvas,e);this.handler.MouseMove(pos);if(this.handler.IsNeedRedraw()) -{this.handler.RestRedraw();this.redrawGraph();} -this.updateMessage();} -Application.prototype.CanvasOnMouseDown=function(e) -{if(e.which!==1)return;var pos=this.getMousePos(this.canvas,e);this.handler.MouseDown(pos);if(this.handler.IsNeedRedraw()) -{this.handler.RestRedraw();this.redrawGraph();} -this.updateMessage();} -Application.prototype.CanvasOnMouseUp=function(e) -{if(e.which!==1)return;var pos=this.getMousePos(this.canvas,e);this.handler.MouseUp(pos);if(this.handler.IsNeedRedraw()) -{this.handler.RestRedraw();this.redrawGraph();} -this.updateMessage();} -Application.prototype.multCanvasScale=function(factor,zoom_to=null) -{if(zoom_to) -{var pos1=this.getMousePos(this.canvas,zoom_to);this.canvasScale*=factor;var pos2=this.getMousePos(this.canvas,zoom_to);this.canvasPosition=this.canvasPosition.add(new Point(pos2.x-pos1.x,pos2.y-pos1.y));} -else -{var oldRealWidth=this.GetRealWidth();var oldRealHeight=this.GetRealHeight();this.canvasScale*=factor;this.canvasPosition=this.canvasPosition.add(new Point((this.GetRealWidth()-oldRealWidth)/2.0,(this.GetRealHeight()-oldRealHeight)/2.0));} -this.redrawGraph();} -Application.prototype.setCanvasScale=function(factor) -{var oldRealWidth=this.GetRealWidth();var oldRealHeight=this.GetRealHeight();this.canvasScale=factor;this.canvasPosition=this.canvasPosition.add(new Point((this.GetRealWidth()-oldRealWidth)/2.0,(this.GetRealHeight()-oldRealHeight)/2.0));this.redrawGraph();} -Application.prototype.onCanvasMove=function(point) -{this.canvasPosition=this.canvasPosition.add(point.multiply(1/this.canvasScale));this.redrawGraph();} -Application.prototype.AddNewVertex=function(vertex) -{return this.graph.AddNewVertex(vertex);} -Application.prototype.AddNewEdge=function(edge,replaceIfExists) -{return this.graph.AddNewEdge(edge,replaceIfExists);} -Application.prototype.CreateNewGraph=function(x,y) -{var app=this;this.currentEnumVerticesType.GetVertexTextAsync(function(enumType) -{app.graph.AddNewVertex(new BaseVertex(x,y,enumType));app.redrawGraph();});} -Application.prototype.CreateNewGraphEx=function(x,y,vertexEnume) -{return this.graph.AddNewVertex(new BaseVertex(x,y,vertexEnume));} -Application.prototype.CreateNewArc=function(graph1,graph2,isDirect,weight,replaceIfExist,upText) -{var edge=this.AddNewEdge(new BaseEdge(graph1,graph2,isDirect,weight,upText),replaceIfExist);this.graph.FixEdgeCurve(edge);var edgeObject=this.graph.edges[edge];if(edgeObject.useWeight) -this.UpdateEdgePresets(edgeObject.weight);return edge;} -Application.prototype.DeleteEdge=function(edgeObject) -{var vertex1=edgeObject.vertex1;var vertex2=edgeObject.vertex2;var hasPair=this.graph.hasPair(edgeObject);this.graph.DeleteEdge(edgeObject);if(hasPair) -{var pairEdges=this.FindAllEdges(vertex2.id,vertex1.id);if(pairEdges.length==1&&pairEdges[0].model.default) -pairEdges[0].model.type=EdgeModels.line;}} -Application.prototype.DeleteVertex=function(graphObject) -{this.graph.DeleteVertex(graphObject);} -Application.prototype.DeleteObject=function(object) -{if(object instanceof BaseVertex) -{this.DeleteVertex(object);} -else if(object instanceof BaseEdge) -{this.DeleteEdge(object);}} -Application.prototype.IsCorrectObject=function(object) -{return(object instanceof BaseVertex)||(object instanceof BaseEdge);} -Application.prototype.FindVertex=function(id) -{return this.graph.FindVertex(id);} -Application.prototype.FindEdge=function(id1,id2) -{return this.graph.FindEdge(id1,id2);} -Application.prototype.FindEdgeAny=function(id1,id2) -{return this.graph.FindEdgeAny(id1,id2);} -Application.prototype.FindAllEdges=function(id1,id2) -{return this.graph.FindAllEdges(id1,id2);} -Application.prototype.SetHandler=function(newHandler) -{if(this.handler) -{this.handler.RestoreAll();} -this.handler=newHandler;this.ToDefaultStateAndRedraw();} -Application.prototype.ToDefaultStateAndRedraw=function() -{this.setRenderPath([]);this.updateMessage();this.redrawGraph();} -Application.prototype.getParameterByName=function(name) -{name=name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var regex=new RegExp("[\\?&]"+name+"=([^&#]*)"),results=regex.exec(location.search);return results===null?"":decodeURIComponent(results[1].replace(/\+/g," "));} -Application.prototype.onPostLoadEvent=function() -{this.SetEnumVerticesType(document.cookie.replace(/(?:(?:^|.*;\s*)enumType\s*\=\s*([^;]*).*$)|^.*$/,"$1"));var wasLoad=false;var matrix=document.getElementById("inputMatrix").innerHTML;var separator=document.getElementById("separator").innerHTML=="space"?" ":",";console.log(matrix);console.log("separator: \""+separator+"\"");matrix=(matrix.length<=0)?this.getParameterByName("matrix"):matrix;if(matrix.length>0) -{if(!this.SetAdjacencyMatrixSmart(matrix,separator)) -{userAction("AdjacencyMatrix.Failed");this.listener.ShowAdjacencyMatrixErrorDialog(matrix);} -else -{userAction("AdjacencyMatrix.Success");} -this.updateMessage();this.redrawGraph();wasLoad=true;} -var matrix=document.getElementById("inputIncidenceMatrix").innerHTML;matrix=(matrix.length<=0)?this.getParameterByName("incidenceMatrix"):matrix;if(matrix.length>0) -{if(!this.SetIncidenceMatrixSmart(matrix)) -{userAction("IncidenceMatrix.Failed");this.listener.ShowIncidenceMatrixErrorDialog(matrix);} -else -{userAction("IncidenceMatrix.Success");} -this.updateMessage();this.redrawGraph();wasLoad=true;} -var pairs=document.getElementById("inputPair").innerHTML;if(pairs.length>0) -{pairs=pairs.replaceAll('>','>');pairs=pairs.replaceAll('<','<');if(!this.SetPairSmart(pairs)) -{userAction("Pair.Failed");this.listener.ShowPairErrorDialog(pairs);} -else -{userAction("Pair.Success");} -this.updateMessage();this.redrawGraph();wasLoad=true;} -if(!wasLoad) -{var graphName=this.getParameterByName("graph");if(graphName.length<=0) -{graphName=document.cookie.replace(/(?:(?:^|.*;\s*)graphName\s*\=\s*([^;]*).*$)|^.*$/,"$1");} -if(graphName.length>0) -{userAction("LoadGraphFromDisk");this.LoadGraphFromDisk(graphName);}} -if(this.undoStack.IsUndoStackEmpty()) -document.getElementById('GraphUndo').style.display='none';this.updateMessage();this.redrawGraph();} -Application.prototype.onLoad=function() -{this.canvas=this.document.getElementById('canvas');this.SetDefaultHandler() -this.updateMessage();this.redrawGraph();} -Application.prototype.NeedRedraw=function() -{this.updateMessage();this.redrawGraph();} -Application.prototype.SetStatus=function(name,value) -{this.status[name]=value;} -Application.prototype.GetStatus=function() -{return this.status[name];} -Application.prototype.GetAdjacencyMatrix=function() -{return this.graph.GetAdjacencyMatrixStr();} -Application.prototype.TestAdjacencyMatrix=function(matrix,rowsObj,colsObj,separator) -{if(separator===undefined) -{separator=",";} -return this.graph.TestAdjacencyMatrix(matrix,rowsObj,colsObj,separator);} -Application.prototype.SetAdjacencyMatrix=function(matrix,separator) -{if(separator===undefined) -{separator=",";} -var res=true;var r={};var c={};if(!this.TestAdjacencyMatrix(matrix,r,c,separator)) -{$.get("/"+SiteDir+"cgi-bin/addFailedMatrix.php?text=adjacency&matrix="+encodeURIComponent(matrix),function(data){;});res=false;} -this.graph.SetAdjacencyMatrix(matrix,new Point(this.GetRealWidth(),this.GetRealHeight()),this.currentEnumVerticesType,separator);this.AutoAdjustViewport();this.redrawGraph();return res;} -Application.prototype.SetPair=function(pair) -{var res=true;var r={};var c={};if(!this.TestPair(pair)) -{$.get("/"+SiteDir+"cgi-bin/addFailedMatrix.php?text=pair&matrix="+encodeURIComponent(pair),function(data){;});res=false;} -this.graph.SetPair(pair,new Point(this.GetRealWidth(),this.GetRealHeight()),this.currentEnumVerticesType);this.AutoAdjustViewport();this.redrawGraph();return res;} -Application.prototype.GetIncidenceMatrix=function() -{return this.graph.GetIncidenceMatrix();} -Application.prototype.TestIncidenceMatrix=function(matrix,rowsObj,colsObj) -{return this.graph.TestIncidenceMatrix(matrix,rowsObj,colsObj);} -Application.prototype.TestPair=function(pair) -{return this.graph.TestPair(pair);} -Application.prototype.SetIncidenceMatrix=function(matrix) -{var res=true;var r={};var c={};if(!this.TestIncidenceMatrix(matrix,r,c)) -{$.get("/"+SiteDir+"cgi-bin/addFailedMatrix.php?text=incidence&matrix="+encodeURIComponent(matrix),function(data){;});res=false;} -this.graph.SetIncidenceMatrix(matrix,new Point(this.GetRealWidth(),this.GetRealHeight()),this.currentEnumVerticesType);this.AutoAdjustViewport();this.redrawGraph();return res;} -Application.prototype.Test=function() -{this.graph.VerticesReposition(new Point(this.GetRealWidth(),this.GetRealHeight()),this.graph.vertices);this.redrawGraph();} -Application.prototype.SetAdjacencyMatrixSmart=function(matrix,separator) -{if(separator===undefined) -{separator=",";} -var res=false;if(this.TestAdjacencyMatrix(matrix,{},{},separator)) -{res=this.SetAdjacencyMatrix(matrix,separator);} -else if(this.TestIncidenceMatrix(matrix,{},{})) -{res=this.SetIncidenceMatrix(matrix);} -else -{res=this.SetAdjacencyMatrix(matrix);} -return res;} -Application.prototype.SetIncidenceMatrixSmart=function(matrix) -{var res=false;if(this.TestIncidenceMatrix(matrix,{},{})) -{res=this.SetIncidenceMatrix(matrix);} -else if(this.TestAdjacencyMatrix(matrix,{},{})) -{res=this.SetAdjacencyMatrix(matrix);} -else -{res=this.SetIncidenceMatrix(matrix);} -return res;} -Application.prototype.SetPairSmart=function(pair) -{var res=false;if(this.TestPair(pair)) -{res=this.SetPair(pair);} -else -{res=false;} -return res;} -Application.prototype.SaveGraphOnDisk=function() -{var graphAsString=this.graph.SaveToXML(this.SaveUserSettings());if(this.savedGraphName.length<=0) -{this.savedGraphName=this.GetNewGraphName();} -var app=this;DiskSaveLoad.SaveGraphOnDisk(this.savedGraphName,graphAsString,function(msg) -{document.cookie="graphName="+app.savedGraphName;});} -Application.prototype.SaveGraphImageOnDisk=function(showDialogCallback) -{var imageName=this.GetNewName();this.stopRenderTimer();this.redrawGraph();var bbox=this.graph.getGraphBBox();var rectParams="";if(this.IsGraphFitOnViewport()) -{var canvasWidth=this.GetRealWidth();var canvasHeight=this.GetRealHeight();var canvasPositionInverse=this.canvasPosition.inverse();var pos=bbox.minPoint.subtract(canvasPositionInverse);rectParams="&x="+Math.round(pos.x*this.canvasScale)+"&y="+Math.round(pos.y*this.canvasScale) -+"&width="+Math.round(bbox.size().x*this.canvasScale)+"&height="+Math.round(bbox.size().y*this.canvasScale);} -var imageBase64Data=this.canvas.toDataURL();DiskSaveLoad.SaveGraphImageOnDisk(imageName,rectParams,imageBase64Data,showDialogCallback);return imageName;} -Application.prototype.SaveFullGraphImageOnDisk=function(showDialogCallback,forPrint) -{var imageName=this.GetNewName();this.stopRenderTimer();var canvas=forPrint?this._PrintRedrawGraph():this._OffscreenRedrawGraph();var bbox=this.graph.getGraphBBox();var rectParams="";rectParams="&x=0"+"&y=0"+"&width="+bbox.size().x+"&height="+bbox.size().y;var imageBase64Data=canvas.toDataURL();DiskSaveLoad.SaveGraphImageOnDisk(imageName,rectParams,imageBase64Data,showDialogCallback);return imageName;} -Application.prototype.SaveSVGGraphOnDisk=function(showDialogCallback) -{var imageName=this.GetNewName();this.stopRenderTimer();var svgText=this._printToSVG();DiskSaveLoad.SaveSVGGraphOnDisk(imageName,svgText,showDialogCallback);return imageName;} -Application.prototype.LoadGraphFromString=function(str) -{var graph=new Graph();var userSettings={};graph.LoadFromXML(str,userSettings);if(userSettings.hasOwnProperty("data")&&userSettings["data"].length>0) -this.LoadUserSettings(userSettings["data"]);this.SetDefaultTransformations();this.graph=graph;if(this.graph.isNeedReposition()) -{this.graph.VerticesReposition(new Point(this.GetRealWidth(),this.GetRealHeight()),this.graph.vertices);} -this.AutoAdjustViewport();this.updateMessage();this.redrawGraph();} -Application.prototype.LoadGraphFromDisk=function(graphName) -{var app=this;DiskSaveLoad.LoadGraphFromDisk(graphName,function(msg) -{app.LoadGraphFromString(msg);});} -Application.prototype.GetNewGraphName=function() -{var name=this.GetNewName();if(this.isVertexCommonStyleCustom||this.isVertexSelectedVertexStylesCustom||this.isBackgroundCommonStyleCustom||this.isEdgeCommonStyleCustom||this.isEdgeSelectedStylesCustom) -{name=name+"ZZcst";} -return name;} -Application.prototype.GetNewName=function() -{var name="";var possible="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(var i=0;i0) -{if(bboxSize.x>this.GetRealWidth()||bboxSize.y>this.GetRealHeight()) -{this.canvasScale=Math.min(this.GetRealWidth()/bboxSize.x,this.GetRealHeight()/bboxSize.y);} -if(graphBBox.minPoint.x<0.0||graphBBox.minPoint.y<0.0||graphBBox.maxPoint.x>this.GetRealWidth()||graphBBox.maxPoint.y>this.GetRealHeight()) -{this.canvasPosition=graphBBox.minPoint.inverse();}}} -Application.prototype.OnAutoAdjustViewport=function() -{this.SetDefaultTransformations();this.AutoAdjustViewport();this.redrawGraph();} -Application.prototype.getAlgorithmNames=function() -{var res=[];for(var i=0;i=Math.floor(graphBBox.maxPoint.x)&&Math.floor(canvasPositionInverse.y+canvasHeight)>=Math.floor(graphBBox.maxPoint.y));} -Application.prototype.PushToStack=function(actionName) -{this.undoStack.PushToStack(actionName,this.graph.SaveToXML(this.SaveUserSettings()));document.getElementById('GraphUndo').style.display='inline-block';} -Application.prototype.Undo=function() -{let data=this.undoStack.Undo();if(data==null) -return;this.graph=new Graph();var userSettings={};this.graph.LoadFromXML(data,userSettings);if(userSettings.hasOwnProperty("data")&&userSettings["data"].length>0) -this.LoadUserSettings(userSettings["data"]);this.redrawGraph();if(this.undoStack.IsUndoStackEmpty()) -document.getElementById('GraphUndo').style.display='none';} -Application.prototype.SaveUserSettings=function() -{var res="{";var needEnd=false;var checkValue=[];checkValue.push({field:"edgeCommonStyle",value:this.edgeCommonStyle,check:this.isEdgeCommonStyleCustom});checkValue.push({field:"edgeSelectedStyles",value:this.edgeSelectedStyles,check:this.isEdgeSelectedStylesCustom});checkValue.push({field:"vertexCommonStyle",value:this.vertexCommonStyle,check:this.isVertexCommonStyleCustom});checkValue.push({field:"vertexSelectedVertexStyles",value:this.vertexSelectedVertexStyles,check:this.isVertexSelectedVertexStylesCustom});checkValue.push({field:"backgroundCommonStyle",value:this.backgroundCommonStyle,check:this.isBackgroundCommonStyleCustom});checkValue.push({field:"defaultVertexSize",value:this.defaultVertexSize,check:this.defaultVertexSize!=null});checkValue.push({field:"defaultEdgeWidth",value:this.defaultEdgeWidth,check:this.defaultEdgeWidth!=null});checkValue.forEach(function(entry){if(!entry.check) -return;if(needEnd) -res=res+",";let valueJson="";if(typeof entry.value.saveToJson==="function"){valueJson=entry.value.saveToJson();}else{valueJson=JSON.stringify(entry.value);} -res=res+"\""+entry.field+"\""+":"+valueJson;needEnd=true;});res=res+"}";return this.EncodeToHTML(res);} -Application.prototype.LoadUserSettings=function(json) -{var checkValue=[];checkValue.push({field:"edgeCommonStyle",value:this.edgeCommonStyle,check:"isEdgeCommonStyleCustom",deep:false});checkValue.push({field:"edgeSelectedStyles",value:this.edgeSelectedStyles,check:"isEdgeSelectedStylesCustom",deep:true});checkValue.push({field:"vertexCommonStyle",value:this.vertexCommonStyle,check:"isVertexCommonStyleCustom",deep:false});checkValue.push({field:"vertexSelectedVertexStyles",value:this.vertexSelectedVertexStyles,check:"isVertexSelectedVertexStylesCustom",deep:true});checkValue.push({field:"defaultVertexSize",value:"defaultVertexSize",check:null,deep:false});checkValue.push({field:"defaultEdgeWidth",value:"defaultEdgeWidth",check:null,deep:false});checkValue.push({field:"backgroundCommonStyle",value:this.backgroundCommonStyle,check:this.isBackgroundCommonStyleCustom,deep:false});var decoderStr=this.DecodeFromHTML(json);var parsedSave=JSON.parse(decoderStr);var app=this;checkValue.forEach(function(entry){if(parsedSave.hasOwnProperty(entry.field)) -{if(typeof parsedSave[entry.field]==='number') -{app[entry.value]=parseInt(parsedSave[entry.field]);} -else -{if(typeof entry.value.loadFromJson==="function"){entry.value.loadFromJson(parsedSave[entry.field],function(){setTimeout(function(){app.redrawGraph()},1000);});return;} -if(!entry.deep) -entry.value.Clear();for(var k in parsedSave[entry.field]) -{if(!entry.deep) -{if(entry.value.ShouldLoad(k)) -{entry.value[k]=parsedSave[entry.field][k];}} -else -{if(k%1!=0) -continue;entry.value[k].Clear();for(var deepK in parsedSave[entry.field][k]) -{if(k=this.maxEdgePresets) -break;}} -Application.prototype.GetEdgePresets=function() -{return this.edgePresets;} -Application.prototype.SetSelectionRect=function(rect) -{this.selectionRect=rect;} -Application.prototype.GetSelectionRect=function(rect) -{return this.selectionRect;} -Application.prototype.GetStyle=function(type,styleName,object,index) -{var correctIndex=index;if(correctIndex==undefined) -correctIndex=0;if(type=="vertex") -{if(styleName=="common") -{return object!==undefined?object.getStyleFor(0):this.vertexCommonStyle;} -else if(styleName=="selected") -{return object!==undefined&&object.hasOwnStyleFor(correctIndex+1)?object.getStyleFor(correctIndex+1):this.vertexSelectedVertexStyles[correctIndex];} -else if(styleName=="printed") -{return this.vertexPrintCommonStyle;} -else if(styleName=="printedSelected") -{return this.vertexPrintSelectedVertexStyles[correctIndex];} -return null;} -else if(type=="edge") -{if(styleName=="common") -{return object!==undefined?object.getStyleFor(0):this.edgeCommonStyle;} -else if(styleName=="selected") -{return object!==undefined&&object.hasOwnStyleFor(correctIndex+1)?object.getStyleFor(correctIndex+1):this.edgeSelectedStyles[correctIndex];} -else if(styleName=="printed") -{return this.edgePrintCommonStyle;} -else if(styleName=="printedSelected") -{return this.edgePrintSelectedStyles[correctIndex];} -return null;} -return null;} -Application.prototype._RedrawGraph=function(context,backgroundPosition,backgroundStyle,bDrawSelectedRect,forceVertexCommon,forceVertexSelected,forceEdgeCommon,forceEdgeSelected) -{var backgroundDrawer=new BaseBackgroundDrawer(context);backgroundDrawer.Draw(backgroundStyle,Math.max(this.canvas.width,this.GetRealWidth()),Math.max(this.canvas.height,this.GetRealHeight()),backgroundPosition,this.canvasScale);this.UpdateEdgesCurrentStyle(forceEdgeCommon,forceEdgeSelected);this.UpdateNodesCurrentStyle(forceVertexCommon,forceVertexSelected);this.RedrawEdges(context);this.RedrawNodes(context);if(bDrawSelectedRect&&this.selectionRect!=null) -this.RedrawSelectionRect(context);} -Application.prototype.GetSelectedVertices=function() -{var res=[];for(i=0;i0) -{res.push(this.graph.vertices[i]);}} -return res;} -Application.prototype.GetSelectedEdges=function() -{var res=[];for(i=0;i0) -{res.push(this.graph.edges[i]);}} -return res;} -Application.prototype.SetDefaultVertexSize=function(diameter) -{var oldDefaultDiameter=this.GetDefaultVertexSize();this.defaultVertexSize=diameter;for(i=0;i0) -{self.application.multCanvasScale(1.3,e);} -else -{self.application.multCanvasScale(1.0/1.3,e);}}} -Editor.prototype.initKeyActions=function(){let self=this;function getCharCode(event){if(event.which==null){return event.keyCode;} -if(event.which!=0&&event.charCode!=0){return event.which;} -return null;} -function getChar(event){return String.fromCharCode(getCharCode(event));} -function selectHandler(buttonName,handler) -{userAction(buttonName+"_shortcut");self.restButtons(buttonName);self.application.SetHandler(handler);} -document.onkeypress=function(e) -{if(event.defaultPrevented||($('#addVertex').hasClass('ui-dialog-content')&&$('#addVertex').dialog('isOpen'))||($('#adjacencyMatrix').hasClass('ui-dialog-content')&&$('#adjacencyMatrix').dialog('isOpen'))||($('#addEdge').hasClass('ui-dialog-content')&&$('#addEdge').dialog('isOpen'))||($('#incidenceMatrix').hasClass('ui-dialog-content')&&$('#incidenceMatrix').dialog('isOpen'))||($('#saveDialog').hasClass('ui-dialog-content')&&$('#saveDialog').dialog('isOpen'))||($('#saveImageDialog').hasClass('ui-dialog-content')&&$('#saveImageDialog').dialog('isOpen'))||($('#GroupRenameDialog').hasClass('ui-dialog-content')&&$('#GroupRenameDialog').dialog('isOpen'))||$('#developerTools').css("display")!="none"||($('#NeedAlgorithm').hasClass('ui-dialog-content')&&$('#NeedAlgorithm').dialog('isOpen'))) -{console.log("prevent");return;} -var key=getChar(event);var code=getCharCode(event);console.log(key+" code="+code);var evtobj=window.event?event:e;var isCtrl=evtobj?evtobj.ctrlKey:false;var moveValue=10;if(code==61||code==43) -{self.application.multCanvasScale(1.5);} -else if(code==45) -{self.application.multCanvasScale(1/1.5);} -else if(key=='w'||key=='ц') -{self.application.onCanvasMove(new Point(0,moveValue));} -else if(key=='s'||key=='ы') -{self.application.onCanvasMove(new Point(0,-moveValue));} -else if(key=='a'||key=='ф') -{self.application.onCanvasMove(new Point(moveValue,0));} -else if(key=='d'||key=='в') -{self.application.onCanvasMove(new Point(-moveValue,0));} -else if(key=='v'||key=='м') -{selectHandler('AddGraph',new AddGraphHandler(self.application));} -else if(key=='e'||key=='у') -{selectHandler('ConnectGraphs',new ConnectionGraphHandler(self.application));} -else if(key=='r'||key=='к') -{selectHandler('DeleteObject',new DeleteGraphHandler(self.application));} -else if(key=='m'||key=='ь') -{selectHandler('Default',new DefaultHandler(self.application));} -else if(code==26&&isCtrl) -{userAction("Key_GraphUndo");self.application.Undo();}} -$(document).keydown(function(event){if(event.which=="17"||event.which=="91") -g_ctrlPressed=true;});$(document).keyup(function(){g_ctrlPressed=false;});} -Editor.prototype.initButtonActions=function() -{let self=this;document.getElementById('ShowAdjacencyMatrix').onclick=function() -{userAction(this.id);var showAdjacencyMatrix=new ShowAdjacencyMatrix(self.application);showAdjacencyMatrix.show();} -document.getElementById('ShowIncidenceMatrix').onclick=function() -{userAction(this.id);var showIncidenceMatrix=new ShowIncidenceMatrix(self.application);showIncidenceMatrix.show();} -document.getElementById('ShowDistanceMatrix').onclick=function() -{userAction(this.id);var showDistanceMatrix=new ShowDistanceMatrix(self.application);showDistanceMatrix.show();} -document.getElementById('GroupRename').onclick=function() -{userAction(this.id);var groupRenameVertices=new GroupRenameVertices(self.application);groupRenameVertices.show();} -document.getElementById('groupRenameButton').onclick=function() -{userAction(this.id);var groupRenameVertices=new GroupRenameVertices(self.application);groupRenameVertices.show();} -document.getElementById('Default').onclick=function() -{userAction(this.id);self.restButtons('Default');self.application.SetHandler(new DefaultHandler(self.application));document.getElementById('Default').className="btn btn-primary btn-sm";} -document.getElementById('AddGraph').onclick=function() -{userAction(this.id);self.restButtons('AddGraph');self.application.SetHandler(document.getElementById('AddGraph').className!=""?new AddGraphHandler(self.application):new DefaultHandler(self.application));} -document.getElementById('ConnectGraphs').onclick=function() -{userAction(this.id);self.restButtons('ConnectGraphs');self.application.SetHandler(document.getElementById('ConnectGraphs').className!=""?new ConnectionGraphHandler(self.application):new DefaultHandler(self.application));} -document.getElementById('DeleteObject').onclick=function() -{userAction(this.id);self.restButtons('DeleteObject');self.application.SetHandler(document.getElementById('DeleteObject').className!=""?new DeleteGraphHandler(self.application):new DefaultHandler(self.application));} -document.getElementById('DeleteAll').onclick=function() -{userAction(this.id);var removeAll=new DeleteAllHandler(self.application);removeAll.clear();self.application.ToDefaultStateAndRedraw();} -document.getElementById('SaveGraph').onclick=function() -{userAction(this.id);var savedDialogGraphHandler=new SavedDialogGraphHandler(self.application);savedDialogGraphHandler.show();} -document.getElementById('NewGraph').onclick=function() -{userAction(this.id);var removeAll=new DeleteAllHandler(self.application);removeAll.clear();self.application.ToDefaultStateAndRedraw();self.application.SetDefaultTransformations();} -document.getElementById('SaveGraphImage').onclick=function() -{userAction(this.id);var savedDialogGraphImageHandler=new SavedDialogGraphImageHandler(self.application);savedDialogGraphImageHandler.showWorkspace();} -document.getElementById('SaveFullGraphImage').onclick=function() -{userAction(this.id);var savedDialogGraphImageHandler=new SavedDialogGraphImageHandler(self.application);savedDialogGraphImageHandler.showFullgraph();} -document.getElementById('SavePrintGraphImage').onclick=function() -{userAction(this.id);var savedDialogGraphImageHandler=new SavedDialogGraphImageHandler(self.application);savedDialogGraphImageHandler.showPrint();} -document.getElementById('SaveSvgGraphImage').onclick=function() -{userAction(this.id);var savedDialogGraphImageHandler=new SavedDialogGraphImageHandler(self.application);savedDialogGraphImageHandler.showSvg();} -document.getElementById('Zoom100').onclick=function() -{userAction(this.id);self.application.setCanvasScale(1.0);} -document.getElementById('Zoom50').onclick=function() -{userAction(this.id);self.application.setCanvasScale(50/100);} -document.getElementById('Zoom25').onclick=function() -{userAction(this.id);self.application.setCanvasScale(25/100);} -document.getElementById('ZoomFit').onclick=function() -{userAction(this.id);self.application.OnAutoAdjustViewport();} -document.getElementById('ZoomIn').onclick=function() -{userAction(this.id);self.application.multCanvasScale(1.5);} -document.getElementById('ZoomOut').onclick=function() -{userAction(this.id);self.application.multCanvasScale(1.0/1.5);} -document.getElementById('MoveWorspace').onclick=function() -{userAction(this.id);self.restButtons('Default');self.application.SetHandler(new DefaultHandler(self.application));document.getElementById('Default').className="btn btn-primary btn-sm";} -document.getElementById('SetupVertexStyle').onclick=function() -{userAction(this.id);var setupVertexStyle=new SetupVertexStyle(self.application);setupVertexStyle.show(0);} -document.getElementById('SetupVertexStyleSelected').onclick=function() -{userAction(this.id);var setupVertexStyle=new SetupVertexStyle(self.application);setupVertexStyle.show(1);} -document.getElementById('SetupEdgeStyle').onclick=function() -{userAction(this.id);var setupEdgeStyle=new SetupEdgeStyle(self.application);setupEdgeStyle.show(0);} -document.getElementById('SetupEdgeStyleSelected').onclick=function() -{userAction(this.id);var setupEdgeStyle=new SetupEdgeStyle(self.application);setupEdgeStyle.show(1);} -document.getElementById('SetupBackgroundStyle').onclick=function() -{userAction(this.id);var setupBackgroundStyle=new SetupBackgroundStyle(self.application);setupBackgroundStyle.show();} -document.getElementById('GraphUndo').onclick=function() -{userAction(this.id);self.application.Undo();} -document.getElementById('runUserScript').onclick=function() -{} -document.getElementById('submitUserScript').onclick=function() -{var script=document.getElementById('userScript');var data="message="+script.value+"&";$.ajax({type:"POST",url:"/feedback",data:data});$("#sentAlgorithm").dialog({resizable:false,height:"auto",width:400,modal:true,dialogClass:'EdgeDialog'});} -document.getElementById('devToolsZoom').onclick=function() -{var devTools=document.getElementById('developerTools');if(devTools.hasOwnProperty("isMin")&&!devTools["isMin"]) -{devTools["isMin"]=true;devTools.style.width="30%";} -else -{devTools["isMin"]=false;devTools.style.width="100%";}} -document.getElementById('ExportGraph').onclick=function() -{userAction(this.id);var graphAsString=self.application.graph.SaveToXML("");var savedGraphName=self.application.GetNewGraphName();var element=document.createElement('a');element.setAttribute('href','data:text/plain;charset=utf-8,'+encodeURIComponent(graphAsString));element.setAttribute('download',"graph_"+savedGraphName+".graphml");element.style.display='none';document.body.appendChild(element);element.click();document.body.removeChild(element);} -document.getElementById('ImportGraph').onclick=function() -{userAction(this.id);if(ImportGraphFiles){ImportGraphFiles.click();}} -document.getElementById('openAlgorithmList').onclick=function() -{setTimeout(function() -{var button=document.getElementById('openAlgorithmList');var buttonRect=button.getBoundingClientRect();var algorithmList=document.getElementById('algorithmList');var delta=buttonRect.right-algorithmList.offsetWidth;if(delta<0) -{var value=(delta-4)+"px";algorithmList.style.right=value;} -else -{algorithmList.style.right="0";}},1);} -document.getElementById('Fullscreen').onclick=function() -{var idList=["h1Header","h1Text","navigation","footerContent","bottom_adv"];self.fullscreen=!self.fullscreen -userAction(self.fullscreen?"fullscreen_on":"fullscreen_off");for(var i=0;i','>');pair=pair.replaceAll('<','<');dialogButtons[g_readMatrixHelp]=function(){window.location.assign(g_language=="ru"?"./wiki/Справка/СписокРебер":"./wiki/Help/EdgeList");};dialogButtons[g_fix]=function(){window.location.assign("./create_graph_by_edge_list?pair="+pair);};dialogButtons[g_close]=function(){$(this).dialog("close");};$("#pairErrorInc").dialog({resizable:false,title:g_pairWrongFormat,width:400,modal:true,dialogClass:'EdgeDialog',buttons:dialogButtons,});} -Editor.prototype.ShowAdjacencyMatrixErrorDialog=function(matrix) -{var dialogButtons={};matrixRes=matrix.replace(/\n/g,'%0A');dialogButtons[g_readMatrixHelp]=function(){window.location.assign(g_language=="ru"?"./wiki/Справка/МатрицаСмежности#matrixFormat":"./wiki/Help/AdjacencyMatrix#matrixFormat");};dialogButtons[g_fixMatrix]=function(){window.location.assign("./create_graph_by_matrix?matrix="+matrixRes);};dialogButtons[g_close]=function(){$(this).dialog("close");};$("#matrixError").dialog({resizable:false,title:g_matrixWrongFormat,width:400,modal:true,dialogClass:'EdgeDialog',buttons:dialogButtons,});} -Editor.prototype.SetDefaultHandler=function() -{this.restButtons('Default');this.application.SetHandler(new DefaultHandler(this.application));} -Editor.prototype.OnGraphTypeChanged=function(isMulti) -{$("#CanvasMessage").text(isMulti?g_GraphIsMultiMessage:g_GraphIsGeneralMessage);} -Editor.prototype.updateMessage=function(message) -{$("#message").html(message);} -let DisableEmscripten=false;let PostLoadedCalled=false;let editor=new Editor(document,window);function resizeCanvas() -{var adv=document.getElementById('bottom_info');var canvas=document.getElementById('canvas');canvas.width=document.getElementById('canvasSection').offsetWidth;var mainContainer=document.getElementById('mainContainer');var offset=(mainContainer.offsetTop+mainContainer.offsetHeight)-(canvas.offsetTop+canvas.offsetHeight)+ -($("#footerContent").css("display")==='block'?0:24);canvas.height=$(window).height()-document.getElementById('canvas').offsetTop- -(adv&&$("#bottom_info").css("display")==='block'?document.getElementById('bottom_info').offsetHeight:0)- -($("#footer").css("display")==='block'?document.getElementById('footer').offsetHeight:0)-offset;editor.redraw();} -function touchHandler(event) -{var touches=event.changedTouches,first=touches[0],type="";switch(event.type) -{case"touchstart":type="mousedown";break;case"touchmove":type="mousemove";break;case"touchend":type="mouseup";break;default:return;} -var simulatedEvent=document.createEvent("MouseEvent");simulatedEvent.initMouseEvent(type,true,true,window,1,first.screenX,first.screenY,first.clientX,first.clientY,false,false,false,false,0,null);first.target.dispatchEvent(simulatedEvent);event.preventDefault();} -function handelImportGraph(files){var graphFileToLoad=files[0];var fileReader=new FileReader();fileReader.onload=function(fileLoadedEvent){var textFromFileLoaded=fileLoadedEvent.target.result;console.log(textFromFileLoaded);editor.application.LoadGraphFromString(textFromFileLoaded);ImportGraphFiles.value="";};fileReader.readAsText(graphFileToLoad,"UTF-8");} -function postLoadPage() -{if(!PostLoadedCalled) -{loadTexts();editor.init();PostLoadedCalled=true;}} -$(document).ready(function() -{window.onresize=function(event) -{resizeCanvas();} -document.getElementById('canvas').addEventListener("touchstart",touchHandler,true);document.getElementById('canvas').addEventListener("touchmove",touchHandler,true);document.getElementById('canvas').addEventListener("touchend",touchHandler,true);document.getElementById('canvas').addEventListener("touchcancel",touchHandler,true);var isMobile=navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i);if(!isMobile&&!DisableEmscripten){let fullPathToGraphffoline="features/graphoffline/Graphoffline.Emscripten.js"+"?v="+globalVersion;doIncludeAsync([include(fullPathToGraphffoline),],()=>{Module['onRuntimeInitialized']=onRuntimeInitialized;var process=Module.cwrap('ProcessAlgorithm','string',['string']);function onRuntimeInitialized(){editor.application.setEmscripten(process);}})}});moduleLoader.endCacheLoading(); \ No newline at end of file +{$("#BadFormatMessage").hide();}} +window.onload=function() +{if(document.getElementById('CreateByAdjacencyMatrix')) +{document.getElementById('CreateByAdjacencyMatrix').onclick=function() +{$("#matrixForm").submit();}} +$("#AdjacencyMatrixFieldPage").on('keyup change',function(eventObject) +{checkFormat();});$("#BadFormatMessage").hide();$("#AdjacencyMatrixFieldPage").hide();$("#showMatrix").on('click',function(eventObject) +{_ShowMatrixInput();});$("#showText").on('click',function(eventObject) +{_ShowTextInput();});$('input:radio[name="separator"]').change(function(){checkFormat()});CopyMatrixToMatrixInput();$(document).keydown(function(event){if(event.which=="17"||event.which=="91") +g_ctrlPressed=true;});$(document).keyup(function(event){if(event.which=="17"||event.which=="91") +g_ctrlPressed=false;});} +moduleLoader.endCacheLoading(); \ No newline at end of file diff --git a/script/pages/editor/api/index.js.cache b/script/pages/editor/api/index.js.cache index cec3a03..dc356e5 100644 --- a/script/pages/editor/api/index.js.cache +++ b/script/pages/editor/api/index.js.cache @@ -1,4 +1,4 @@ -moduleLoader.beginCacheLoading(["/script/shared/utils.js?v=78","/script/entities/graph/api/index.js?v=78","/script/shared/point.js?v=78","/script/entities/edge/api/index.js?v=78","/script/entities/edge/model/BaseEdge.js?v=78","/script/entities/edge/model/EdgeModel.js?v=78","/script/entities/vertex/api/index.js?v=78","/script/entities/vertex/model/BaseVertex.js?v=78","/script/entities/vertex/model/VertexModel.js?v=78","/script/entities/graph/model/Graph.js?v=78","/script/features/draw_graph/api/index.js?v=78","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=78","/script/features/draw_graph/model/EdgeStyle.js?v=78","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=78","/script/features/draw_graph/model/VertexShape.js?v=78","/script/features/draw_graph/model/VertexStyle.js?v=78","/script/features/draw_graph/model/BaseVertexDrawer.js?v=78","/script/features/algorithms/api/index.js?v=78","/script/features/algorithms/model/Algorithms.js?v=78","/script/features/algorithms/model/BaseTraversal.js?v=78","/script/features/base_handler/index.js?v=78","/script/features/default_handler/index.js?v=78","/script/features/add_vertices_handler/index.js?v=78","/script/features/connect_vertices_handler/index.js?v=78","/script/features/delete_objects_handler/index.js?v=78","/script/features/algorithm_handler/index.js?v=78","/script/features/serialization/api/index.js?v=78","/script/features/serialization/model/GraphMLCreator.js?v=78","/script/features/enum_vertices/EnumVertices.js?v=78","/script/pages/editor/model/texts.js?v=78","/script/pages/editor/model/UndoStack.js?v=78","/script/pages/editor/model/DiskSaveLoad.js?v=78","/script/pages/editor/model/Application.js?v=78","/script/pages/editor/ui/ya_metrika.js?v=78","/script/pages/editor/ui/editor.js?v=78","/script/pages/editor/ui/main.js?v=78",]);{function onloadEditor(){console.log("onload() call");doIncludeAsync([include("shared/canvas2svg.js"),include("features/group_rename_handler/index.js"),include("features/saved_graph_handler/index.js"),include("features/saved_graph_image_handler/index.js"),include("features/show_adjacency_matrix/index.js"),include("features/show_distance_matrix/index.js"),include("features/show_incidence_matrix/index.js"),include("features/setup_background_style/index.js"),include("features/setup_edge_style/index.js"),include("features/setup_vertex_style/index.js"),]);postLoadPage();} +moduleLoader.beginCacheLoading(["/script/shared/utils.js?v=79","/script/entities/graph/api/index.js?v=79","/script/shared/point.js?v=79","/script/entities/edge/api/index.js?v=79","/script/entities/edge/model/BaseEdge.js?v=79","/script/entities/edge/model/EdgeModel.js?v=79","/script/entities/vertex/api/index.js?v=79","/script/entities/vertex/model/BaseVertex.js?v=79","/script/entities/vertex/model/VertexModel.js?v=79","/script/entities/graph/model/Graph.js?v=79","/script/features/draw_graph/api/index.js?v=79","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=79","/script/features/draw_graph/model/EdgeStyle.js?v=79","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=79","/script/features/draw_graph/model/VertexShape.js?v=79","/script/features/draw_graph/model/VertexStyle.js?v=79","/script/features/draw_graph/model/BaseVertexDrawer.js?v=79","/script/features/algorithms/api/index.js?v=79","/script/features/algorithms/model/Algorithms.js?v=79","/script/features/algorithms/model/BaseTraversal.js?v=79","/script/features/base_handler/index.js?v=79","/script/features/default_handler/index.js?v=79","/script/features/add_vertices_handler/index.js?v=79","/script/features/connect_vertices_handler/index.js?v=79","/script/features/delete_objects_handler/index.js?v=79","/script/features/algorithm_handler/index.js?v=79","/script/features/serialization/api/index.js?v=79","/script/features/serialization/model/GraphMLCreator.js?v=79","/script/features/enum_vertices/EnumVertices.js?v=79","/script/pages/editor/model/texts.js?v=79","/script/pages/editor/model/UndoStack.js?v=79","/script/pages/editor/model/DiskSaveLoad.js?v=79","/script/pages/editor/model/Application.js?v=79","/script/pages/editor/ui/ya_metrika.js?v=79","/script/pages/editor/ui/editor.js?v=79","/script/pages/editor/ui/main.js?v=79",]);{function onloadEditor(){console.log("onload() call");doIncludeAsync([include("shared/canvas2svg.js"),include("features/group_rename_handler/index.js"),include("features/saved_graph_handler/index.js"),include("features/saved_graph_image_handler/index.js"),include("features/show_adjacency_matrix/index.js"),include("features/show_distance_matrix/index.js"),include("features/show_incidence_matrix/index.js"),include("features/setup_background_style/index.js"),include("features/setup_edge_style/index.js"),include("features/setup_vertex_style/index.js"),]);postLoadPage();} let modulDir="pages/editor/";doInclude([include("shared/utils.js"),include("entities/graph/api/index.js"),include("features/draw_graph/api/index.js"),include("features/algorithms/api/index.js"),include("features/base_handler/index.js"),include("features/default_handler/index.js"),include("features/add_vertices_handler/index.js"),include("features/connect_vertices_handler/index.js"),include("features/delete_objects_handler/index.js"),include("features/algorithm_handler/index.js"),include("features/serialization/api/index.js"),include("features/enum_vertices/EnumVertices.js"),include("model/texts.js",modulDir),include("model/UndoStack.js",modulDir),include("model/DiskSaveLoad.js",modulDir),include("model/Application.js",modulDir),include("ui/ya_metrika.js",modulDir),include("ui/editor.js",modulDir),include("ui/main.js",modulDir)],onloadEditor);} function gEncodeToHTML(str) {if(typeof str!=='string') @@ -846,7 +846,7 @@ this.context.fillText(text,position.x,position.y);} BaseVertexDrawer.prototype.DrawCenterText=function(position,text,color,outlineColor,bold,outline,size) {this.context.textBaseline="middle";this.context.font=(bold?"bold ":"")+size+DefaultFont;var textWidth=this.context.measureText(text).width;this.DrawText(new Point(position.x-textWidth/2,position.y),text,color,outlineColor,outline,this.context.font);} {let modulDir="features/algorithms/";doInclude([include("model/Algorithms.js",modulDir),include("model/BaseTraversal.js",modulDir)]) -function loadAsyncAlgorithms(onFinish){let modulDir="features/algorithms/";let pluginsList=["BFS.js","Coloring.js","ConnectedComponent.js","DFS.js","EulerianLoop.js","EulerianPath.js","FindAllPatches.js","FindLongestPath.js","FindShortPatchsFromOne.js","Floid.js","GraphReorder.js","HamiltonianLoop.js","HamiltonianPath.js","IsomorphismCheck.js","MaxClique.js","MaxFlow.js","MinimumSpanningTree.js","ModernGraphStyle.js","RadiusAndDiameter.js","ShortestPath.js","VerticesDegree.js"];doIncludeAsync(pluginsList.map((plugin)=>include("model/plugins/"+plugin+"?v="+globalVersion,modulDir)),onFinish);}} +function loadAsyncAlgorithms(onFinish){let modulDir="features/algorithms/";let pluginsList=["BFS.js","Coloring.js","ConnectedComponent.js","DFS.js","EulerianLoop.js","EulerianPath.js","FindAllPatches.js","FindLongestPath.js","FindShortPatchsFromOne.js","Floid.js","GraphReorder.js","HamiltonianLoop.js","HamiltonianPath.js","IsomorphismCheck.js","MaxClique.js","MaxFlow.js","MinimumSpanningTree.js","ModernGraphStyle.js","RadiusAndDiameter.js","ShortestPath.js","VerticesDegree.js"];doIncludeAsync(pluginsList.map((plugin)=>include("model/plugins/"+plugin,modulDir)),onFinish);}} function getVertexToVertexArray(graph,ignoreDirection) {res={};for(var i=0;i=0;if(isMac) g_selectGroupText=document.getElementById("selectGroupMac").innerHTML;else -g_selectGroupText=document.getElementById("selectGroupWin").innerHTML;g_dragGroupText=document.getElementById("dragSelectedGroup").innerHTML;g_copyGroupeButton=document.getElementById("copySelectedGroup").innerHTML;g_removeGroupeButton=document.getElementById("removeSelectedGroup").innerHTML;g_BFSName=document.getElementById("BFSName").innerHTML;g_ColoringName=document.getElementById("ColoringName").innerHTML;g_findConnectedComponent=document.getElementById("findConnectedComponent").innerHTML;g_DFSName=document.getElementById("DFSName").innerHTML;g_EulerinLoopName=document.getElementById("EulerinLoopName").innerHTML;g_EulerinPath=document.getElementById("EulerinPath").innerHTML;g_FloidName=document.getElementById("FloidName").innerHTML;g_GraphReorder=document.getElementById("GraphReorder").innerHTML;g_HamiltoianCycleName=document.getElementById("HamiltoianCycleName").innerHTML;g_HamiltonianPath=document.getElementById("HamiltonianPath").innerHTML;g_MaxFlowName=document.getElementById("MaxFlowName").innerHTML;g_minimumSpanningTree=document.getElementById("minimumSpanningTree").innerHTML;g_modernGraphStyleName=document.getElementById("modernGraphStyleName").innerHTML;g_RadiusAndDiameter=document.getElementById("RadiusAndDiameter").innerHTML;g_findShortPathName=document.getElementById("findShortPathName").innerHTML;g_VerticesDegreeName=document.getElementById("VerticesDegreeName").innerHTML;g_SpanningTreeResult=document.getElementById("MinSpanningTreeResult").innerHTML;g_SpanningTreeIgnoreDir=document.getElementById("MinSpanningIgnoreDir").innerHTML;g_SpanningTreeNotConnected=document.getElementById("MinSpanningNotConnected").innerHTML;g_selectFirstGraphIsomorphismCheck=document.getElementById("SelectFirstGraphIsomorphismCheck").innerHTML;g_selectSecondGraphIsomorphismCheck=document.getElementById("SelectSecondGraphIsomorphismCheck").innerHTML;g_selectFirstGraphPatternCheck=document.getElementById("SelectFirstGraphPatternCheck").innerHTML;g_selectSecondGraphForSearchSubgraph=document.getElementById("SelectSecondGraphForSearchSubgraph").innerHTML;g_graphsIsomorph=document.getElementById("GraphsIsomorph").innerHTML;g_graphsNotIsomorph=document.getElementById("GraphsNotIsomorph").innerHTML;g_numberOfIsomorphSubgraphIs=document.getElementById("NumberOfIsomorphSubgraphIs").innerHTML;g_graphHasNoIsomorphSubgraph=document.getElementById("GraphHasNoIsomorphSubgraph").innerHTML;g_searchIsomorphSubgraph=document.getElementById("SearchIsomorphSubgraph").innerHTML;g_subgraphNo=document.getElementById("SubgraphNo").innerHTML;g_graphHasNoAtleast2Graphs=document.getElementById("GraphHasNoAtleast2Graphs").innerHTML;g_IsomorphismCheck=document.getElementById("IsomorphismCheck").innerHTML;g_graphIsDisconnected=document.getElementById("GraphIsDisconnected").innerHTML;g_graphIsTrivial=document.getElementById("GraphIsTrivial").innerHTML;g_graphRadius=document.getElementById("GraphRadius").innerHTML;g_graphDiameter=document.getElementById("GraphDiameter").innerHTML;g_vertexCentral=document.getElementById("VertexCentral").innerHTML;g_vertexPeripheral=document.getElementById("VertexPeripheral").innerHTML;g_maximumDegreeOfGraph=document.getElementById("MaximumDegreeOfGraph").innerHTML;g_colorNumber=document.getElementById("ColorNumber").innerHTML;g_done=document.getElementById("Done").innerHTML;g_action=document.getElementById("ActionText").innerHTML;g_commonEdgeStyle=document.getElementById("CommonEdgeStyleText").innerHTML;g_selectedEdgeStyle=document.getElementById("SelectedEdgeStyleText").innerHTML;g_commonVertexStyle=document.getElementById("CommonVertexStyleText").innerHTML;g_selectedVertexStyle=document.getElementById("SelectedVertexStyleText").innerHTML;g_findAllPathes=document.getElementById("FindAllPathes").innerHTML;g_numberOfPathesFrom=document.getElementById("NumberOfPathesFrom").innerHTML;g_to=document.getElementById("To").innerHTML;g_are=document.getElementById("Are").innerHTML;g_pathN=document.getElementById("PathN").innerHTML;g_selectFinishVertex=document.getElementById("SelectFinishVertex").innerHTML;g_selectStartVertex=document.getElementById("SelectStartVertex").innerHTML;g_findAllPathesFromVertex=document.getElementById("findAllPathsFromVertex").innerHTML;g_distanceFrom=document.getElementById("distanceFrom").innerHTML;g_pathTo=document.getElementById("pathTo").innerHTML;g_useContextMenuText=document.getElementById("UseContextMenuText").innerHTML;g_findLongestPath=document.getElementById("findLongestPath").innerHTML;g_LengthOfLongestPathFrom=document.getElementById("LengthOfLongestPathFrom").innerHTML;g_additionalActions=document.getElementById("additionlActions").innerHTML;g_reverseAllEdges=document.getElementById("reverseAllEdges").innerHTML;g_makeAllUndirected=document.getElementById("makeAllUndirected").innerHTML;g_makeAllDirected=document.getElementById("makeAllDirected").innerHTML;g_pairWrongFormat=document.getElementById("pairWrongFormat").innerHTML;g_fix=document.getElementById("fixButton").innerHTML;g_reuseSavedEdge=document.getElementById("reuseSavedEdge").innerHTML;g_MaxClique=document.getElementById("maxClique").innerHTML;g_MaxCliqueNotFound=document.getElementById("maxCliqueNotFound").innerHTML;g_MaxCliqueSizeIs=document.getElementById("maxCliqueSizeIs").innerHTML;g_MaxCliqueContains=document.getElementById("maxCliqueContains").innerHTML;g_wrongImageFormatPNGAndJPEG=document.getElementById("wrongImageFormatPNGAndJPEG").innerHTML;g_wrongImageSizeP1=document.getElementById("wrongImageSizeP1").innerHTML;} +g_selectGroupText=document.getElementById("selectGroupWin").innerHTML;g_dragGroupText=document.getElementById("dragSelectedGroup").innerHTML;g_copyGroupeButton=document.getElementById("copySelectedGroup").innerHTML;g_removeGroupeButton=document.getElementById("removeSelectedGroup").innerHTML;g_BFSName=document.getElementById("BFSName").innerHTML;g_ColoringName=document.getElementById("ColoringName").innerHTML;g_findConnectedComponent=document.getElementById("findConnectedComponent").innerHTML;g_DFSName=document.getElementById("DFSName").innerHTML;g_EulerinLoopName=document.getElementById("EulerinLoopName").innerHTML;g_EulerinPath=document.getElementById("EulerinPath").innerHTML;g_FloidName=document.getElementById("FloidName").innerHTML;g_GraphReorder=document.getElementById("GraphReorder").innerHTML;g_HamiltoianCycleName=document.getElementById("HamiltoianCycleName").innerHTML;g_HamiltonianPath=document.getElementById("HamiltonianPath").innerHTML;g_MaxFlowName=document.getElementById("MaxFlowName").innerHTML;g_minimumSpanningTree=document.getElementById("minimumSpanningTree").innerHTML;g_modernGraphStyleName=document.getElementById("modernGraphStyleName").innerHTML;g_RadiusAndDiameter=document.getElementById("RadiusAndDiameter").innerHTML;g_findShortPathName=document.getElementById("findShortPathName").innerHTML;g_findShortPathBellmanFordName=document.getElementById("findShortPathBellmanFordName").innerHTML;g_VerticesDegreeName=document.getElementById("VerticesDegreeName").innerHTML;g_SpanningTreeResult=document.getElementById("MinSpanningTreeResult").innerHTML;g_SpanningTreeIgnoreDir=document.getElementById("MinSpanningIgnoreDir").innerHTML;g_SpanningTreeNotConnected=document.getElementById("MinSpanningNotConnected").innerHTML;g_selectFirstGraphIsomorphismCheck=document.getElementById("SelectFirstGraphIsomorphismCheck").innerHTML;g_selectSecondGraphIsomorphismCheck=document.getElementById("SelectSecondGraphIsomorphismCheck").innerHTML;g_selectFirstGraphPatternCheck=document.getElementById("SelectFirstGraphPatternCheck").innerHTML;g_selectSecondGraphForSearchSubgraph=document.getElementById("SelectSecondGraphForSearchSubgraph").innerHTML;g_graphsIsomorph=document.getElementById("GraphsIsomorph").innerHTML;g_graphsNotIsomorph=document.getElementById("GraphsNotIsomorph").innerHTML;g_numberOfIsomorphSubgraphIs=document.getElementById("NumberOfIsomorphSubgraphIs").innerHTML;g_graphHasNoIsomorphSubgraph=document.getElementById("GraphHasNoIsomorphSubgraph").innerHTML;g_searchIsomorphSubgraph=document.getElementById("SearchIsomorphSubgraph").innerHTML;g_subgraphNo=document.getElementById("SubgraphNo").innerHTML;g_graphHasNoAtleast2Graphs=document.getElementById("GraphHasNoAtleast2Graphs").innerHTML;g_IsomorphismCheck=document.getElementById("IsomorphismCheck").innerHTML;g_graphIsDisconnected=document.getElementById("GraphIsDisconnected").innerHTML;g_graphIsTrivial=document.getElementById("GraphIsTrivial").innerHTML;g_graphRadius=document.getElementById("GraphRadius").innerHTML;g_graphDiameter=document.getElementById("GraphDiameter").innerHTML;g_vertexCentral=document.getElementById("VertexCentral").innerHTML;g_vertexPeripheral=document.getElementById("VertexPeripheral").innerHTML;g_maximumDegreeOfGraph=document.getElementById("MaximumDegreeOfGraph").innerHTML;g_colorNumber=document.getElementById("ColorNumber").innerHTML;g_done=document.getElementById("Done").innerHTML;g_action=document.getElementById("ActionText").innerHTML;g_commonEdgeStyle=document.getElementById("CommonEdgeStyleText").innerHTML;g_selectedEdgeStyle=document.getElementById("SelectedEdgeStyleText").innerHTML;g_commonVertexStyle=document.getElementById("CommonVertexStyleText").innerHTML;g_selectedVertexStyle=document.getElementById("SelectedVertexStyleText").innerHTML;g_findAllPathes=document.getElementById("FindAllPathes").innerHTML;g_numberOfPathesFrom=document.getElementById("NumberOfPathesFrom").innerHTML;g_to=document.getElementById("To").innerHTML;g_are=document.getElementById("Are").innerHTML;g_pathN=document.getElementById("PathN").innerHTML;g_selectFinishVertex=document.getElementById("SelectFinishVertex").innerHTML;g_selectStartVertex=document.getElementById("SelectStartVertex").innerHTML;g_findAllPathesFromVertex=document.getElementById("findAllPathsFromVertex").innerHTML;g_distanceFrom=document.getElementById("distanceFrom").innerHTML;g_pathTo=document.getElementById("pathTo").innerHTML;g_useContextMenuText=document.getElementById("UseContextMenuText").innerHTML;g_findLongestPath=document.getElementById("findLongestPath").innerHTML;g_LengthOfLongestPathFrom=document.getElementById("LengthOfLongestPathFrom").innerHTML;g_additionalActions=document.getElementById("additionlActions").innerHTML;g_reverseAllEdges=document.getElementById("reverseAllEdges").innerHTML;g_makeAllUndirected=document.getElementById("makeAllUndirected").innerHTML;g_makeAllDirected=document.getElementById("makeAllDirected").innerHTML;g_pairWrongFormat=document.getElementById("pairWrongFormat").innerHTML;g_fix=document.getElementById("fixButton").innerHTML;g_reuseSavedEdge=document.getElementById("reuseSavedEdge").innerHTML;g_MaxClique=document.getElementById("maxClique").innerHTML;g_MaxCliqueNotFound=document.getElementById("maxCliqueNotFound").innerHTML;g_MaxCliqueSizeIs=document.getElementById("maxCliqueSizeIs").innerHTML;g_MaxCliqueContains=document.getElementById("maxCliqueContains").innerHTML;g_wrongImageFormatPNGAndJPEG=document.getElementById("wrongImageFormatPNGAndJPEG").innerHTML;g_wrongImageSizeP1=document.getElementById("wrongImageSizeP1").innerHTML;} function UndoStack(maxUndoStackSize){this.undoStack=[];this.maxUndoStackSize=maxUndoStackSize;} UndoStack.prototype.PushToStack=function(actionName,dataToSave) {var object={};object.actionName=actionName;object.data=dataToSave;this.undoStack.push(object);while(this.undoStack.length>this.maxUndoStackSize) @@ -1985,7 +1985,7 @@ Editor.prototype.createAlgorithmMenu=function() var eventData={};eventData.index=i;eventData.object=clone;eventData.algorithm=algorithm;$("#openAlgorithmList").bind('click',eventData,function(_eventData){var data=_eventData.data;var algorithm=g_Algorithms[g_AlgorithmIds.indexOf(data.algorithm.id)](self.application.graph,self.application);if((self.application.graph.isMulti()&&!algorithm.IsSupportMultiGraph())||(self.application.graph.hasNegative()&&!algorithm.IsSupportNegativeWeight())) {$(data.object).hide();} else -{$(data.object).show();}});list.insertBefore(clone,document.getElementById("insert"+algorithm.category));index++;}} +{$(data.object).show();var textSpan=data.object.getElementsByTagName("span")[1];textSpan.innerHTML=algorithm.getName();}});list.insertBefore(clone,document.getElementById("insert"+algorithm.category));index++;}} Editor.prototype.restButtons=function(me) {var needSetDefault=false;for(let i=0;i - - + +