From 2bc0bda1306a2f4c1b02d020e451674278072b9f Mon Sep 17 00:00:00 2001 From: Oleg Sh Date: Sun, 15 Jun 2025 15:52:55 +0200 Subject: [PATCH] Add vertex finder feature. --- core/config/main.php | 2 +- i/css/home.css | 31 ++++++- lang/bg/home.php | 2 + lang/ch/home.php | 2 + lang/cs/home.php | 2 + lang/de/home.php | 2 + lang/el/home.php | 2 + lang/en/home.php | 2 + lang/es/home.php | 2 + lang/fr/home.php | 2 + lang/nl/home.php | 2 + lang/pl/home.php | 2 + lang/pt/home.php | 2 + lang/ru/home.php | 2 + lang/sv/home.php | 2 + lang/ua/home.php | 2 + script/features/base_handler/index.js | 3 +- .../api/index.js.cache | 2 +- .../api/index.js.cache | 2 +- .../create_graph_by_matrix/api/index.js.cache | 2 +- script/pages/editor/api/index.js.cache | 50 +++++++++--- script/pages/editor/model/Application.js | 42 +++++++++- script/pages/editor/model/texts.js | 3 + script/pages/editor/ui/editor.js | 81 ++++++++++++++++++- script/shared/utils.js | 15 ++++ tpl/home.php | 12 ++- 26 files changed, 249 insertions(+), 24 deletions(-) diff --git a/core/config/main.php b/core/config/main.php index 913d595..3cf8162 100755 --- a/core/config/main.php +++ b/core/config/main.php @@ -94,5 +94,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'] = 97; + $g_config['engine_version'] = 98; ?> diff --git a/i/css/home.css b/i/css/home.css index cc6c607..71f3c17 100755 --- a/i/css/home.css +++ b/i/css/home.css @@ -261,7 +261,7 @@ #CanvasMessage { position: absolute; - right: 48px; + left: 4px; z-index: 10; -webkit-touch-callout: none; /* iOS Safari */ -webkit-user-select: none; /* Safari */ @@ -272,6 +272,35 @@ supported by Chrome and Opera */ } +#CanvasSearchText +{ + width: 120px; + position: absolute; + top: 6px; + right: 38px; + z-index: 10; + padding-left: 2px; + padding-right: 2px; + padding-top: 2px; + padding-bottom: 2px; + min-height: 1em; +} + +#ShowArrow +{ + position: absolute; + top: 60px; + right: 60px; + width: 32px; + z-index: 10; + font-size: 32px; + padding: 0; + border: none; + margin: 0; + pointer-events: none; + display: none; +} + .MarginLeft { margin-right: 32px !important; diff --git a/lang/bg/home.php b/lang/bg/home.php index a372625..73d0fde 100644 --- a/lang/bg/home.php +++ b/lang/bg/home.php @@ -315,4 +315,6 @@ We have added Dutch translation 🇳🇱. Thank you Willie de Wit"; $g_lang['autosaved_graph'] = "Autosaved graph"; $g_lang['open_last_used_graph'] = "Open Recent Graph"; + + $g_lang['vertex_name_place_holder'] = "vertex name"; ?> diff --git a/lang/ch/home.php b/lang/ch/home.php index b456063..6d9b45f 100644 --- a/lang/ch/home.php +++ b/lang/ch/home.php @@ -317,4 +317,6 @@ $g_lang['autosaved_graph'] = "Autosaved graph"; $g_lang['open_last_used_graph'] = "Open Recent Graph"; + + $g_lang['vertex_name_place_holder'] = "vertex name"; ?> diff --git a/lang/cs/home.php b/lang/cs/home.php index b68f0a4..366c5df 100644 --- a/lang/cs/home.php +++ b/lang/cs/home.php @@ -321,4 +321,6 @@ $g_lang['autosaved_graph'] = "Autosaved graph"; $g_lang['open_last_used_graph'] = "Open Recent Graph"; + + $g_lang['vertex_name_place_holder'] = "vertex name"; ?> \ No newline at end of file diff --git a/lang/de/home.php b/lang/de/home.php index 92ee79f..799504a 100644 --- a/lang/de/home.php +++ b/lang/de/home.php @@ -279,4 +279,6 @@ $g_lang['autosaved_graph'] = "Autosaved graph"; $g_lang['open_last_used_graph'] = "Open Recent Graph"; + + $g_lang['vertex_name_place_holder'] = "vertex name"; ?> diff --git a/lang/el/home.php b/lang/el/home.php index 486c312..0259395 100644 --- a/lang/el/home.php +++ b/lang/el/home.php @@ -318,4 +318,6 @@ $g_lang['autosaved_graph'] = "Autosaved graph"; $g_lang['open_last_used_graph'] = "Open Recent Graph"; + + $g_lang['vertex_name_place_holder'] = "vertex name"; ?> diff --git a/lang/en/home.php b/lang/en/home.php index ccc1971..9cfba7b 100755 --- a/lang/en/home.php +++ b/lang/en/home.php @@ -323,4 +323,6 @@ We have added Dutch translation 🇳🇱. Thank you Willie de Wit"; $g_lang['autosaved_graph'] = "Autosaved graph"; $g_lang['open_last_used_graph'] = "Open Recent Graph"; + + $g_lang['vertex_name_place_holder'] = "vertex name"; ?> diff --git a/lang/es/home.php b/lang/es/home.php index b7438ec..d235766 100755 --- a/lang/es/home.php +++ b/lang/es/home.php @@ -322,4 +322,6 @@ Tenemos traducciones en griego 🇬🇷. diff --git a/lang/fr/home.php b/lang/fr/home.php index ee81113..1894e5e 100644 --- a/lang/fr/home.php +++ b/lang/fr/home.php @@ -289,4 +289,6 @@ $g_lang['autosaved_graph'] = "Autosaved graph"; $g_lang['open_last_used_graph'] = "Open Recent Graph"; + + $g_lang['vertex_name_place_holder'] = "vertex name"; ?> diff --git a/lang/nl/home.php b/lang/nl/home.php index 331ee31..c9743bc 100644 --- a/lang/nl/home.php +++ b/lang/nl/home.php @@ -286,4 +286,6 @@ $g_lang['autosaved_graph'] = "Autosaved graph"; $g_lang['open_last_used_graph'] = "Open Recent Graph"; + + $g_lang['vertex_name_place_holder'] = "vertex name"; ?> diff --git a/lang/pl/home.php b/lang/pl/home.php index 5363c8f..0495b2b 100644 --- a/lang/pl/home.php +++ b/lang/pl/home.php @@ -322,4 +322,6 @@ Dodaliśmy polskie tłumaczenie, Patryk"; $g_lang['autosaved_graph'] = "Autosaved graph"; $g_lang['open_last_used_graph'] = "Open Recent Graph"; + + $g_lang['vertex_name_place_holder'] = "vertex name"; ?> diff --git a/lang/pt/home.php b/lang/pt/home.php index 747e34a..64fa31b 100644 --- a/lang/pt/home.php +++ b/lang/pt/home.php @@ -287,4 +287,6 @@ $g_lang['autosaved_graph'] = "Autosaved graph"; $g_lang['open_last_used_graph'] = "Open Recent Graph"; + + $g_lang['vertex_name_place_holder'] = "vertex name"; ?> diff --git a/lang/ru/home.php b/lang/ru/home.php index b753858..19a839e 100755 --- a/lang/ru/home.php +++ b/lang/ru/home.php @@ -327,4 +327,6 @@ $g_lang['autosaved_graph'] = "Автосохранение графа"; $g_lang['open_last_used_graph'] = "Открыть недавний граф"; + + $g_lang['vertex_name_place_holder'] = "вершина"; ?> diff --git a/lang/sv/home.php b/lang/sv/home.php index 69770a0..2862472 100644 --- a/lang/sv/home.php +++ b/lang/sv/home.php @@ -283,4 +283,6 @@ $g_lang['autosaved_graph'] = "Autosaved graph"; $g_lang['open_last_used_graph'] = "Open Recent Graph"; + + $g_lang['vertex_name_place_holder'] = "vertex name"; ?> diff --git a/lang/ua/home.php b/lang/ua/home.php index 74fa86b..4a9a59f 100644 --- a/lang/ua/home.php +++ b/lang/ua/home.php @@ -325,4 +325,6 @@ $g_lang['autosaved_graph'] = "Автозбереження графа"; $g_lang['open_last_used_graph'] = "Відкрити нещодавній граф"; + + $g_lang['vertex_name_place_holder'] = "вершина"; ?> diff --git a/script/features/base_handler/index.js b/script/features/base_handler/index.js index 0966198..532ab12 100644 --- a/script/features/base_handler/index.js +++ b/script/features/base_handler/index.js @@ -165,7 +165,8 @@ BaseHandler.prototype.RestoreAll = function() BaseHandler.prototype.GetSelectVertexMenu = function(menuName) { - var res = "" + + var res = "" + ""; for (var i = 0; i < this.app.graph.vertices.length; i++) 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 63c0c16..7d10311 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,4 +1,4 @@ -moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=97","/script/shared/point.js?v=97","/script/entities/edge/api/index.js?v=97","/script/entities/edge/model/BaseEdge.js?v=97","/script/entities/edge/model/EdgeModel.js?v=97","/script/entities/vertex/api/index.js?v=97","/script/entities/vertex/model/BaseVertex.js?v=97","/script/entities/vertex/model/VertexModel.js?v=97","/script/entities/graph/model/Graph.js?v=97",]);{let modulDir="pages/create_graph_by_edge_list/";doInclude([include("entities/graph/api/index.js")]);} +moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=98","/script/shared/point.js?v=98","/script/entities/edge/api/index.js?v=98","/script/entities/edge/model/BaseEdge.js?v=98","/script/entities/edge/model/EdgeModel.js?v=98","/script/entities/vertex/api/index.js?v=98","/script/entities/vertex/model/BaseVertex.js?v=98","/script/entities/vertex/model/VertexModel.js?v=98","/script/entities/graph/model/Graph.js?v=98",]);{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() 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 0792a97..ba27fa0 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,4 +1,4 @@ -moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=97","/script/shared/point.js?v=97","/script/entities/edge/api/index.js?v=97","/script/entities/edge/model/BaseEdge.js?v=97","/script/entities/edge/model/EdgeModel.js?v=97","/script/entities/vertex/api/index.js?v=97","/script/entities/vertex/model/BaseVertex.js?v=97","/script/entities/vertex/model/VertexModel.js?v=97","/script/entities/graph/model/Graph.js?v=97",]);{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js")]);} +moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=98","/script/shared/point.js?v=98","/script/entities/edge/api/index.js?v=98","/script/entities/edge/model/BaseEdge.js?v=98","/script/entities/edge/model/EdgeModel.js?v=98","/script/entities/vertex/api/index.js?v=98","/script/entities/vertex/model/BaseVertex.js?v=98","/script/entities/vertex/model/VertexModel.js?v=98","/script/entities/graph/model/Graph.js?v=98",]);{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() 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 c8b37b0..5da468e 100644 --- a/script/pages/create_graph_by_matrix/api/index.js.cache +++ b/script/pages/create_graph_by_matrix/api/index.js.cache @@ -1,4 +1,4 @@ -moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=97","/script/shared/point.js?v=97","/script/entities/edge/api/index.js?v=97","/script/entities/edge/model/BaseEdge.js?v=97","/script/entities/edge/model/EdgeModel.js?v=97","/script/entities/vertex/api/index.js?v=97","/script/entities/vertex/model/BaseVertex.js?v=97","/script/entities/vertex/model/VertexModel.js?v=97","/script/entities/graph/model/Graph.js?v=97","/script/pages/create_graph_by_matrix/model/createByMatrixMain.js?v=97","/script/pages/create_graph_by_matrix/model/main.js?v=97",]);{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js"),include("model/createByMatrixMain.js",modulDir),include("model/main.js",modulDir)]);} +moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=98","/script/shared/point.js?v=98","/script/entities/edge/api/index.js?v=98","/script/entities/edge/model/BaseEdge.js?v=98","/script/entities/edge/model/EdgeModel.js?v=98","/script/entities/vertex/api/index.js?v=98","/script/entities/vertex/model/BaseVertex.js?v=98","/script/entities/vertex/model/VertexModel.js?v=98","/script/entities/graph/model/Graph.js?v=98","/script/pages/create_graph_by_matrix/model/createByMatrixMain.js?v=98","/script/pages/create_graph_by_matrix/model/main.js?v=98",]);{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js"),include("model/createByMatrixMain.js",modulDir),include("model/main.js",modulDir)]);} {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() diff --git a/script/pages/editor/api/index.js.cache b/script/pages/editor/api/index.js.cache index f7ea3bc..69bbd72 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=97","/script/shared/gzip.js?v=97","/script/entities/graph/api/index.js?v=97","/script/shared/point.js?v=97","/script/entities/edge/api/index.js?v=97","/script/entities/edge/model/BaseEdge.js?v=97","/script/entities/edge/model/EdgeModel.js?v=97","/script/entities/vertex/api/index.js?v=97","/script/entities/vertex/model/BaseVertex.js?v=97","/script/entities/vertex/model/VertexModel.js?v=97","/script/entities/graph/model/Graph.js?v=97","/script/features/draw_graph/api/index.js?v=97","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=97","/script/features/draw_graph/model/EdgeStyle.js?v=97","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=97","/script/features/draw_graph/model/VertexShape.js?v=97","/script/features/draw_graph/model/VertexStyle.js?v=97","/script/features/draw_graph/model/BaseVertexDrawer.js?v=97","/script/features/draw_graph/model/GraphFullStyle.js?v=97","/script/features/algorithms/api/index.js?v=97","/script/features/algorithms/model/Algorithms.js?v=97","/script/features/algorithms/model/BaseTraversal.js?v=97","/script/features/base_handler/index.js?v=97","/script/features/default_handler/index.js?v=97","/script/features/add_vertices_handler/index.js?v=97","/script/features/connect_vertices_handler/index.js?v=97","/script/features/delete_objects_handler/index.js?v=97","/script/features/algorithm_handler/index.js?v=97","/script/features/select_auto_save_graph_or_not/index.js?v=97","/script/features/graph_preview/index.js?v=97","/script/features/serialization/api/index.js?v=97","/script/features/serialization/model/GraphMLCreator.js?v=97","/script/features/enum_vertices/EnumVertices.js?v=97","/script/pages/editor/model/texts.js?v=97","/script/pages/editor/model/UndoStack.js?v=97","/script/pages/editor/model/DiskSaveLoad.js?v=97","/script/pages/editor/model/Application.js?v=97","/script/pages/editor/ui/ya_metrika.js?v=97","/script/pages/editor/ui/editor.js?v=97","/script/pages/editor/ui/main.js?v=97",]);{function onloadEditor(){console.log("onload() call");doIncludeAsync([include("shared/canvas2svg.min.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=98","/script/shared/gzip.js?v=98","/script/entities/graph/api/index.js?v=98","/script/shared/point.js?v=98","/script/entities/edge/api/index.js?v=98","/script/entities/edge/model/BaseEdge.js?v=98","/script/entities/edge/model/EdgeModel.js?v=98","/script/entities/vertex/api/index.js?v=98","/script/entities/vertex/model/BaseVertex.js?v=98","/script/entities/vertex/model/VertexModel.js?v=98","/script/entities/graph/model/Graph.js?v=98","/script/features/draw_graph/api/index.js?v=98","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=98","/script/features/draw_graph/model/EdgeStyle.js?v=98","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=98","/script/features/draw_graph/model/VertexShape.js?v=98","/script/features/draw_graph/model/VertexStyle.js?v=98","/script/features/draw_graph/model/BaseVertexDrawer.js?v=98","/script/features/draw_graph/model/GraphFullStyle.js?v=98","/script/features/algorithms/api/index.js?v=98","/script/features/algorithms/model/Algorithms.js?v=98","/script/features/algorithms/model/BaseTraversal.js?v=98","/script/features/base_handler/index.js?v=98","/script/features/default_handler/index.js?v=98","/script/features/add_vertices_handler/index.js?v=98","/script/features/connect_vertices_handler/index.js?v=98","/script/features/delete_objects_handler/index.js?v=98","/script/features/algorithm_handler/index.js?v=98","/script/features/select_auto_save_graph_or_not/index.js?v=98","/script/features/graph_preview/index.js?v=98","/script/features/serialization/api/index.js?v=98","/script/features/serialization/model/GraphMLCreator.js?v=98","/script/features/enum_vertices/EnumVertices.js?v=98","/script/pages/editor/model/texts.js?v=98","/script/pages/editor/model/UndoStack.js?v=98","/script/pages/editor/model/DiskSaveLoad.js?v=98","/script/pages/editor/model/Application.js?v=98","/script/pages/editor/ui/ya_metrika.js?v=98","/script/pages/editor/ui/editor.js?v=98","/script/pages/editor/ui/main.js?v=98",]);{function onloadEditor(){console.log("onload() call");doIncludeAsync([include("shared/canvas2svg.min.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("shared/gzip.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/select_auto_save_graph_or_not/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') @@ -11,7 +11,8 @@ function FullObjectCopy(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;};async function compress_text_into_zip_base64(str,callback,mode="gzip") +Array.prototype.swap=function(x,y){var b=this[x];this[x]=this[y];this[y]=b;return this;} +function InvertColor(hex){hex=hex.replace(/^#/,'');let r=255-parseInt(hex.slice(0,2),16);let g=255-parseInt(hex.slice(2,4),16);let b=255-parseInt(hex.slice(4,6),16);const toHex=(n)=>n.toString(16).padStart(2,'0');return`#${toHex(r)}${toHex(g)}${toHex(b)}`;};async function compress_text_into_zip_base64(str,callback,mode="gzip") {try {const blobToBase64=blob=>new Promise((resolve,_)=>{const reader=new FileReader();reader.onloadend=()=>resolve(reader.result.split(',')[1]);reader.readAsDataURL(blob);});const byteArray=new TextEncoder().encode(str);const cs=new CompressionStream(mode);const writer=cs.writable.getWriter();writer.write(byteArray);writer.close();return await new Response(cs.readable).blob().then(blobToBase64).then(res=>callback(res));} catch(err) @@ -1053,7 +1054,7 @@ return res;} BaseHandler.prototype.RestoreAll=function() {} BaseHandler.prototype.GetSelectVertexMenu=function(menuName) -{var res=""+"";for(var i=0;i"+"";for(var i=0;i";} return res+"";} BaseHandler.prototype.GetSelect2VertexMenu=function() @@ -1467,10 +1468,10 @@ TextEnumVerticesCustom.prototype.ShowDialog=function(callback,buttonText,titleTi 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_findShortPathBellmanFordName="Find shortest path using Bellman–Ford 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.";var g_originalGraph="Original graph";var g_autoSavedGraph="Autosaved graph";var g_selectGraphToLoad="Would you like to load original graph or autosaved graph?";function loadTexts() +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.";var g_originalGraph="Original graph";var g_autoSavedGraph="Autosaved graph";var g_selectGraphToLoad="Would you like to load original graph or autosaved graph?";var g_vertexNamePlaceHolder="vertex name";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_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;g_originalGraph=document.getElementById("originalGraph").innerHTML;g_autoSavedGraph=document.getElementById("autoSavedGraph").innerHTML;g_selectGraphToLoad=document.getElementById("selectGraphToLoad").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;g_originalGraph=document.getElementById("originalGraph").innerHTML;g_autoSavedGraph=document.getElementById("autoSavedGraph").innerHTML;g_selectGraphToLoad=document.getElementById("selectGraphToLoad").innerHTML;g_vertexNamePlaceHolder=document.getElementById("vertexNamePlaceHolder").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) @@ -1832,8 +1833,10 @@ Application.prototype.GetCurrentValue=function(paramName,defaultValue) {return(paramName in this.algorithmsValues)?this.algorithmsValues[paramName]:defaultValue;} Application.prototype.SetCurrentValue=function(paramName,value) {this.algorithmsValues[paramName]=value;} +Application.prototype.IsPointFitOnViewport=function(point) +{var canvasWidth=this.GetRealWidth();var canvasHeight=this.GetRealHeight();var canvasPositionInverse=this.canvasPosition.inverse();return(Math.floor(canvasPositionInverse.x)<=Math.floor(point.x)&&Math.floor(canvasPositionInverse.y)<=Math.floor(point.y)&&Math.floor(canvasPositionInverse.x+canvasWidth)>=Math.floor(point.x)&&Math.floor(canvasPositionInverse.y+canvasHeight)>=Math.floor(point.y));} Application.prototype.IsGraphFitOnViewport=function() -{res=true;graphBBox=this.graph.getGraphBBox();var canvasWidth=this.GetRealWidth();var canvasHeight=this.GetRealHeight();var canvasPositionInverse=this.canvasPosition.inverse();return(Math.floor(canvasPositionInverse.x)<=Math.floor(graphBBox.minPoint.x)&&Math.floor(canvasPositionInverse.y)<=Math.floor(graphBBox.minPoint.y)&&Math.floor(canvasPositionInverse.x+canvasWidth)>=Math.floor(graphBBox.maxPoint.x)&&Math.floor(canvasPositionInverse.y+canvasHeight)>=Math.floor(graphBBox.maxPoint.y));} +{graphBBox=this.graph.getGraphBBox();var canvasWidth=this.GetRealWidth();var canvasHeight=this.GetRealHeight();var canvasPositionInverse=this.canvasPosition.inverse();return(Math.floor(canvasPositionInverse.x)<=Math.floor(graphBBox.minPoint.x)&&Math.floor(canvasPositionInverse.y)<=Math.floor(graphBBox.minPoint.y)&&Math.floor(canvasPositionInverse.x+canvasWidth)>=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() @@ -2056,19 +2059,26 @@ Application.prototype.LoadLastUsedGraphsFromCookie=function() {let graphs=document.cookie.replace(/(?:(?:^|.*;\s*)lastUsedGraphs\s*\=\s*([^;]*).*$)|^.*$/,"$1");if(graphs.length>0) {this.lastUsedGraphs=JSON.parse(graphs);for(let i=0;i0) +{self.StopArrowForVertexTimer();var e=window.event||e;var delta=Math.max(-1,Math.min(1,(e.wheelDelta||-e.detail)));if(delta>0) {self.application.multCanvasScale(1.3,e);} else {self.application.multCanvasScale(1.0/1.3,e);}}} @@ -2079,7 +2089,7 @@ 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'))) +{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'))||$('#CanvasSearchText:focus').is(":focus")||$('#Vertex1:focus').is(":focus")||$('#Vertex2:focus').is(":focus")) {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);} @@ -2184,7 +2194,25 @@ document.getElementById('Fullscreen').onclick=function() userAction(self.fullscreen?"fullscreen_on":"fullscreen_off");for(var i=0;i{let datalist=document.getElementById('vertexListCanvas');const options=datalist.options;for(let i=options.length-1;i>=0;i--){options[i].remove();} +self.application.graph.vertices.forEach(vertex=>{const option=document.createElement('option');option.value=vertex.mainText;datalist.appendChild(option);});});document.getElementById('CanvasSearchText').addEventListener('input',function(event){let vertex=self.application.GetVertexByName(event.target.value);if(vertex!=null) +{let size=vertex.getBBox(vertex.getStyleFor(0));let point1=vertex.position.add(new Point(-size.x/2,-size.y/2));let point2=vertex.position.add(new Point(size.x/2,size.y/2));if(!self.application.IsPointFitOnViewport(point1)||!self.application.IsPointFitOnViewport(point2)) +{self.application.canvasPosition=vertex.position.inverse().add(new Point(self.application.GetRealWidth()/2,self.application.GetRealHeight()/2));self.application.redrawGraph();} +self.HighlightVertex(vertex);} +else +{self.StopArrowForVertexTimer();}});} +Editor.prototype.StopArrowForVertexTimer=function() +{if(this.arrowForVertexTimer!=null) +{clearInterval(this.arrowForVertexTimer);this.arrowForVertexTimer=null;} +this.arrowForVertex.style.display="none";} +Editor.prototype.HighlightVertex=function(vertex) +{let pos=vertex.position.add(new Point(vertex.model.diameter/2*Math.sin(Math.PI/4)+this.arrowForVertex.clientWidth*0,-vertex.model.diameter/2*Math.sin(Math.PI/4)-40/this.application.canvasScale));let posInWindow=this.application.GraphPosToCanvasPos(pos);this.arrowForVertex.style.top=posInWindow.y+'px';this.arrowForVertex.style.left=posInWindow.x+'px';this.arrowForVertex.style.color=InvertColor(this.application.style.backgroundCommonStyle.commonColor);this.arrowForVertex.style.display="block";if(this.arrowForVertexTimer==null) +{this.arrowForVertexTimer=setInterval(function() +{if(this.arrowForVertex.style.display=="none") +{this.arrowForVertex.style.display="block";} +else +{this.arrowForVertex.style.display="none";}}.bind(this),400)}} Editor.prototype.initVoteButton=function() {let self=this;if(document.getElementById('VoteButton')!==null) document.getElementById('VoteButton').onclick=function() diff --git a/script/pages/editor/model/Application.js b/script/pages/editor/model/Application.js index eb8bdf4..8cc19a4 100644 --- a/script/pages/editor/model/Application.js +++ b/script/pages/editor/model/Application.js @@ -1295,9 +1295,20 @@ Application.prototype.SetCurrentValue = function(paramName, value) this.algorithmsValues[paramName] = value; } +Application.prototype.IsPointFitOnViewport = function(point) +{ + var canvasWidth = this.GetRealWidth();// * this.canvasScale; + var canvasHeight = this.GetRealHeight();// * this.canvasScale; + var canvasPositionInverse = this.canvasPosition./*multiply(this.canvasScale).*/inverse(); + + return (Math.floor(canvasPositionInverse.x) <= Math.floor(point.x) && + Math.floor(canvasPositionInverse.y) <= Math.floor(point.y) && + Math.floor(canvasPositionInverse.x + canvasWidth) >= Math.floor(point.x) && + Math.floor(canvasPositionInverse.y + canvasHeight) >= Math.floor(point.y)); +} + Application.prototype.IsGraphFitOnViewport = function() { - res = true; graphBBox = this.graph.getGraphBBox(); var canvasWidth = this.GetRealWidth();// * this.canvasScale; var canvasHeight = this.GetRealHeight();// * this.canvasScale; @@ -1306,8 +1317,9 @@ Application.prototype.IsGraphFitOnViewport = function() // + " Position" + canvasPositionInverse.toString() + " - cw = " + canvasWidth + " ch = " + canvasHeight); return (Math.floor(canvasPositionInverse.x) <= Math.floor(graphBBox.minPoint.x) && - Math.floor(canvasPositionInverse.y) <= Math.floor(graphBBox.minPoint.y) && Math.floor(canvasPositionInverse.x + canvasWidth) >= Math.floor(graphBBox.maxPoint.x) - && Math.floor(canvasPositionInverse.y + canvasHeight) >= Math.floor(graphBBox.maxPoint.y)); + Math.floor(canvasPositionInverse.y) <= Math.floor(graphBBox.minPoint.y) && + Math.floor(canvasPositionInverse.x + canvasWidth) >= Math.floor(graphBBox.maxPoint.x) && + Math.floor(canvasPositionInverse.y + canvasHeight) >= Math.floor(graphBBox.maxPoint.y)); } Application.prototype.PushToStack = function(actionName) @@ -2005,4 +2017,26 @@ Application.prototype.LoadLastUsedGraphsFromCookie = function() graph.date = new Date(graph.date); } } -} \ No newline at end of file +} + +Application.prototype.GetVertexByName = function(vertex_name, withIndex) +{ + for (let i = 0; i < this.graph.vertices.length; i++) + { + if (this.graph.vertices[i].mainText == vertex_name) + { + return this.graph.vertices[i]; + } + } + + return null; +} + +Application.prototype.GraphPosToCanvasPos = function(pos) +{ + let windowPos = new Point(pos.x, pos.y); + windowPos.x = (windowPos.x + this.canvasPosition.x) * this.canvasScale; + windowPos.y = (windowPos.y + this.canvasPosition.y) * this.canvasScale; + + return windowPos; +} diff --git a/script/pages/editor/model/texts.js b/script/pages/editor/model/texts.js index 443122b..5a349d4 100644 --- a/script/pages/editor/model/texts.js +++ b/script/pages/editor/model/texts.js @@ -211,6 +211,8 @@ var g_originalGraph = "Original graph"; var g_autoSavedGraph = "Autosaved graph"; var g_selectGraphToLoad = "Would you like to load original graph or autosaved graph?"; +var g_vertexNamePlaceHolder = "vertex name"; + function loadTexts() { g_textsSelectAndMove = document.getElementById("SelectAndMoveObject").innerHTML; @@ -430,4 +432,5 @@ function loadTexts() g_originalGraph = document.getElementById("originalGraph").innerHTML; g_autoSavedGraph = document.getElementById("autoSavedGraph").innerHTML; g_selectGraphToLoad = document.getElementById("selectGraphToLoad").innerHTML; + g_vertexNamePlaceHolder = document.getElementById("vertexNamePlaceHolder").innerHTML; } \ No newline at end of file diff --git a/script/pages/editor/ui/editor.js b/script/pages/editor/ui/editor.js index 97c4c08..b1af729 100644 --- a/script/pages/editor/ui/editor.js +++ b/script/pages/editor/ui/editor.js @@ -6,6 +6,8 @@ function Editor(document, window) { this.application = new Application(document, window, self); this.fullscreen = false; this.buttonsList = ['AddGraph', 'ConnectGraphs', 'DeleteObject', 'Default']; + this.arrowForVertex = document.getElementById('ShowArrow'); + this.arrowForVertexTimer = null; } Editor.prototype.initMouseActions = function() { @@ -18,6 +20,7 @@ Editor.prototype.initMouseActions = function() { this.application.canvas.onmousedown = function (e) { + self.StopArrowForVertexTimer(); return self.application.CanvasOnMouseDown(e); }; @@ -28,6 +31,7 @@ Editor.prototype.initMouseActions = function() { this.application.canvas.onwheel = function (e) { + self.StopArrowForVertexTimer(); var e = window.event || e; // old IE support var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail))); if (delta > 0) @@ -78,7 +82,10 @@ Editor.prototype.initKeyActions = function() { || ($('#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'))) + || ($('#NeedAlgorithm').hasClass('ui-dialog-content') && $('#NeedAlgorithm').dialog('isOpen')) + || $('#CanvasSearchText:focus').is(":focus") + || $('#Vertex1:focus').is(":focus") + || $('#Vertex2:focus').is(":focus")) { console.log("prevent"); return; // Should do nothing if the default action has been cancelled @@ -467,6 +474,78 @@ Editor.prototype.initButtonActions = function() resizeCanvas(); } + + document.getElementById('CanvasSearchText').addEventListener('focus', (event) => { + let datalist = document.getElementById('vertexListCanvas'); + const options = datalist.options; + for (let i = options.length - 1; i >= 0; i--) { + options[i].remove(); + } + + self.application.graph.vertices.forEach(vertex => { + const option = document.createElement('option'); + option.value = vertex.mainText; + datalist.appendChild(option); + }); + }); + + document.getElementById('CanvasSearchText').addEventListener('input', function(event) { + let vertex = self.application.GetVertexByName(event.target.value); + if (vertex != null) + { + let size = vertex.getBBox(vertex.getStyleFor(0)); + let point1 = vertex.position.add(new Point(-size.x / 2, -size.y / 2)); + let point2 = vertex.position.add(new Point(size.x / 2, size.y / 2)); + if (!self.application.IsPointFitOnViewport(point1) || !self.application.IsPointFitOnViewport(point2)) + { + self.application.canvasPosition = vertex.position.inverse().add( + new Point(self.application.GetRealWidth() / 2, self.application.GetRealHeight() / 2)); + self.application.redrawGraph(); + } + self.HighlightVertex(vertex); + } + else + { + self.StopArrowForVertexTimer(); + } + }); +} + +Editor.prototype.StopArrowForVertexTimer = function() +{ + if (this.arrowForVertexTimer != null) + { + clearInterval(this.arrowForVertexTimer); + this.arrowForVertexTimer = null; + } + this.arrowForVertex.style.display = "none"; +} + +Editor.prototype.HighlightVertex = function(vertex) +{ + let pos = vertex.position.add(new Point( + vertex.model.diameter / 2 * Math.sin(Math.PI / 4 /* 45 degree*/) + this.arrowForVertex.clientWidth * 0, + -vertex.model.diameter / 2 * Math.sin(Math.PI / 4 /* 45 degree*/) - 40 / this.application.canvasScale)); + let posInWindow = this.application.GraphPosToCanvasPos(pos); + this.arrowForVertex.style.top = posInWindow.y + 'px'; + this.arrowForVertex.style.left = posInWindow.x + 'px'; + this.arrowForVertex.style.color = InvertColor(this.application.style.backgroundCommonStyle.commonColor); + this.arrowForVertex.style.display = "block"; + + if (this.arrowForVertexTimer == null) + { + this.arrowForVertexTimer = setInterval(function () + { + if (this.arrowForVertex.style.display == "none") + { + this.arrowForVertex.style.display = "block"; + } + else + { + this.arrowForVertex.style.display = "none"; + } + }.bind(this), 400) + } } Editor.prototype.initVoteButton = function() diff --git a/script/shared/utils.js b/script/shared/utils.js index 5ba5497..3acd91e 100644 --- a/script/shared/utils.js +++ b/script/shared/utils.js @@ -54,4 +54,19 @@ Array.prototype.swap = function (x, y) { this[x] = this[y]; this[y] = b; return this; +} + +function InvertColor(hex) { + // Remove '#' if present + hex = hex.replace(/^#/, ''); + + // Parse r, g, b values + let r = 255 - parseInt(hex.slice(0, 2), 16); + let g = 255 - parseInt(hex.slice(2, 4), 16); + let b = 255 - parseInt(hex.slice(4, 6), 16); + + // Convert back to hex and pad with 0s if necessary + const toHex = (n) => n.toString(16).padStart(2, '0'); + + return `#${toHex(r)}${toHex(g)}${toHex(b)}`; } \ No newline at end of file diff --git a/tpl/home.php b/tpl/home.php index 15f5b62..8132d58 100755 --- a/tpl/home.php +++ b/tpl/home.php @@ -239,9 +239,15 @@
- + + + + + + + - +

@@ -974,6 +980,8 @@

+ +