Implement style switching functionality. Add default, night, and high contrast styles.

This commit is contained in:
Oleg Sh
2026-01-12 19:05:49 +01:00
parent dee5d4c4ea
commit 6f5fb0fc9c
30 changed files with 661 additions and 63 deletions

View File

@@ -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'] = 107;
$g_config['engine_version'] = 108;
?>

View File

@@ -341,4 +341,9 @@ We have added Dutch translation 🇳🇱. Thank you Willie de Wit</a>";
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
$g_lang['shortest_path_is'] = "The length of shortest path is ";
$g_lang['default_style'] = "Default";
$g_lang['night_style'] = "Night";
$g_lang['large_high_contrast_style'] = "Large High Contrast";
$g_lang['styles'] = "Styles";
?>

View File

@@ -343,4 +343,9 @@
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
$g_lang['shortest_path_is'] = "The length of shortest path is ";
$g_lang['default_style'] = "Default";
$g_lang['night_style'] = "Night";
$g_lang['large_high_contrast_style'] = "Large High Contrast";
$g_lang['styles'] = "Styles";
?>

View File

@@ -342,4 +342,9 @@
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
$g_lang['shortest_path_is'] = "The length of shortest path is ";
$g_lang['default_style'] = "Default";
$g_lang['night_style'] = "Night";
$g_lang['large_high_contrast_style'] = "Large High Contrast";
$g_lang['styles'] = "Styles";
?>

View File

@@ -300,4 +300,9 @@
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
$g_lang['shortest_path_is'] = "The length of shortest path is ";
$g_lang['default_style'] = "Default";
$g_lang['night_style'] = "Night";
$g_lang['large_high_contrast_style'] = "Large High Contrast";
$g_lang['styles'] = "Styles";
?>

View File

@@ -339,4 +339,9 @@
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
$g_lang['shortest_path_is'] = "The length of shortest path is ";
$g_lang['default_style'] = "Default";
$g_lang['night_style'] = "Night";
$g_lang['large_high_contrast_style'] = "Large High Contrast";
$g_lang['styles'] = "Styles";
?>

View File

@@ -344,4 +344,9 @@ We have added Dutch translation 🇳🇱. Thank you Willie de Wit</a>";
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
$g_lang['shortest_path_is'] = "The length of shortest path is ";
$g_lang['default_style'] = "Default";
$g_lang['night_style'] = "Night";
$g_lang['large_high_contrast_style'] = "Large High Contrast";
$g_lang['styles'] = "Styles";
?>

View File

@@ -343,4 +343,9 @@ Tenemos traducciones en griego 🇬🇷.</a> <a href=\"https://github.com/UnickS
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
$g_lang['shortest_path_is'] = "The length of shortest path is ";
$g_lang['default_style'] = "Default";
$g_lang['night_style'] = "Night";
$g_lang['large_high_contrast_style'] = "Large High Contrast";
$g_lang['styles'] = "Styles";
?>

View File

@@ -310,4 +310,9 @@
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
$g_lang['shortest_path_is'] = "The length of shortest path is ";
$g_lang['default_style'] = "Default";
$g_lang['night_style'] = "Night";
$g_lang['large_high_contrast_style'] = "Large High Contrast";
$g_lang['styles'] = "Styles";
?>

View File

@@ -307,4 +307,9 @@
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
$g_lang['shortest_path_is'] = "The length of shortest path is ";
$g_lang['default_style'] = "Default";
$g_lang['night_style'] = "Night";
$g_lang['large_high_contrast_style'] = "Large High Contrast";
$g_lang['styles'] = "Styles";
?>

View File

@@ -343,4 +343,9 @@ Dodaliśmy polskie tłumaczenie, Patryk</a>";
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
$g_lang['shortest_path_is'] = "The length of shortest path is ";
$g_lang['default_style'] = "Default";
$g_lang['night_style'] = "Night";
$g_lang['large_high_contrast_style'] = "Large High Contrast";
$g_lang['styles'] = "Styles";
?>

View File

@@ -308,4 +308,9 @@
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
$g_lang['shortest_path_is'] = "The length of shortest path is ";
$g_lang['default_style'] = "Default";
$g_lang['night_style'] = "Night";
$g_lang['large_high_contrast_style'] = "Large High Contrast";
$g_lang['styles'] = "Styles";
?>

View File

@@ -348,4 +348,9 @@
$g_lang['shortest_loop_is'] = "Кратчайший цикл имеет длинну ";
$g_lang['salesman_path_problem'] = "Задача коммивояжёра для пути";
$g_lang['shortest_path_is'] = "Кратчайший путь имеет длинну ";
$g_lang['default_style'] = "По умолчанию";
$g_lang['night_style'] = "Ночной";
$g_lang['large_high_contrast_style'] = "Крупный высоко-контрастностный";
$g_lang['styles'] = "Стили";
?>

View File

@@ -304,4 +304,9 @@
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
$g_lang['shortest_path_is'] = "The length of shortest path is ";
$g_lang['default_style'] = "Default";
$g_lang['night_style'] = "Night";
$g_lang['large_high_contrast_style'] = "Large High Contrast";
$g_lang['styles'] = "Styles";
?>

View File

@@ -346,4 +346,9 @@
$g_lang['shortest_loop_is'] = "Найкоротший цикл має довжину ";
$g_lang['salesman_path_problem'] = "Задача комівояжера для шляху";
$g_lang['shortest_path_is'] = "Найкоротший шлях має довжину ";
$g_lang['default_style'] = "По умолчанию";
$g_lang['night_style'] = "Ночной";
$g_lang['large_high_contrast_style'] = "Крупный высоко-контрастностный";
$g_lang['styles'] = "Стили";
?>

View File

@@ -1317,29 +1317,42 @@ Graph.prototype.checkMutiGraph = function ()
{
var res = false;
var start = {};
let start = {};
let check_pair = function(id1, id2, start)
{
return (start.hasOwnProperty(id1) && start[id1].includes(id2));
}
let add_to_start = function(id1, id2, start)
{
if (!start.hasOwnProperty(id1))
{
start[id1] = [];
}
start[id1].push(id2);
}
for (var i = 0; i < this.edges.length; i++)
{
var edge = this.edges[i];
if (start.hasOwnProperty(edge.vertex1.id) &&
start[edge.vertex1.id] == edge.vertex2.id)
if (check_pair(edge.vertex1.id, edge.vertex2.id, start))
{
res = true;
break;
}
start[edge.vertex1.id] = edge.vertex2.id;
add_to_start(edge.vertex1.id, edge.vertex2.id, start);
if (!edge.isDirect)
{
if (start.hasOwnProperty(edge.vertex2.id) &&
start[edge.vertex2.id] == edge.vertex1.id)
if (check_pair(edge.vertex2.id, edge.vertex1.id, start))
{
res = true;
break;
}
start[edge.vertex2.id] = edge.vertex1.id;
add_to_start(edge.vertex2.id, edge.vertex1.id, start);
}
}

View File

@@ -14,6 +14,10 @@ doInclude ([
include ("model/PrintEdgeStyle.js", modulDir),
include ("model/VertexNewWhiteStyle.js", modulDir),
include ("model/EdgeNewWhiteStyle.js", modulDir),
include ("model/EdgeNewNightStyle.js", modulDir),
include ("model/VertexNewNightStyle.js", modulDir),
include ("model/EdgeContrastStyle.js", modulDir),
include ("model/VertexContrastStyle.js", modulDir),
include ("model/BaseVertexDrawer.js", modulDir),
include ("model/GraphFullStyle.js", modulDir)
])

View File

@@ -25,11 +25,27 @@ function PrintBackgroundStyle()
PrintBackgroundStyle.prototype = Object.create(CommonBackgroundStyle.prototype);
function NightBackgroundStyle()
{
CommonBackgroundStyle.apply(this, arguments);
this.commonColor = '#0f172a';
this.commonOpacity = 1.0;
this.image = null;
}
NightBackgroundStyle.prototype = Object.create(CommonBackgroundStyle.prototype);
function GetWhiteBackgroundStyle()
{
return new CommonBackgroundStyle();
}
function GetNightBackgroundStyle()
{
return new NightBackgroundStyle();
}
function DefaultCommonBackgroundStyle()
{
return GetWhiteBackgroundStyle();

View File

@@ -0,0 +1,43 @@
/**
* New Contrast edge styles.
*/
function ContrastCommonEdgeStyle()
{
BaseEdgeStyle.apply(this, arguments);
this.strokeStyle = '#000000';
this.weightText = '#000000';
this.fillStyle = '#ffffff';
this.textPadding = 4;
this.textStrokeWidth = 2;
this.lineDash = 0;
this.additionalTextColor = '#000000';
this.weightPosition = WeightTextCenter;
this.mainTextFontSize = 16;
}
ContrastCommonEdgeStyle.prototype = Object.create(BaseEdgeStyle.prototype);
function ContrastSelectedEdgeStyle0()
{
BaseEdgeStyle.apply(this, arguments);
this.strokeStyle = '#000000';
this.weightText = '#000000';
this.fillStyle = '#ffffff';
this.additionalTextColor = '#000000';
this.lineDash = 1
this.baseStyles.push("common");
}
ContrastSelectedEdgeStyle0.prototype = Object.create(BaseEdgeStyle.prototype);
function GetContrastCommonEdgeStyle()
{
return new ContrastCommonEdgeStyle();
}
var ContrastSelectedEdgeStyles = [new ContrastSelectedEdgeStyle0(), new ContrastSelectedEdgeStyle0(),
new ContrastSelectedEdgeStyle0(), new ContrastSelectedEdgeStyle0(), new ContrastSelectedEdgeStyle0()];

View File

@@ -0,0 +1,95 @@
/**
* New night edge styles.
*/
function NightCommonEdgeStyle()
{
BaseEdgeStyle.apply(this, arguments);
this.strokeStyle = '#cbd5e1';
this.weightText = '#f8fafc';
this.fillStyle = '#020617';
this.textPadding = 4;
this.textStrokeWidth = 2;
this.lineDash = 0;
this.additionalTextColor = '#cbd5e1';
this.weightPosition = WeightTextCenter;
}
NightCommonEdgeStyle.prototype = Object.create(BaseEdgeStyle.prototype);
function NightSelectedEdgeStyle0()
{
BaseEdgeStyle.apply(this, arguments);
this.strokeStyle = '#fdba74';
this.weightText = '#fff7ed';
this.fillStyle = '#7c2d12';
this.additionalTextColor = '#fff7ed';
this.baseStyles.push("common");
}
NightSelectedEdgeStyle0.prototype = Object.create(BaseEdgeStyle.prototype);
function NightSelectedEdgeStyle1()
{
BaseEdgeStyle.apply(this, arguments);
this.strokeStyle = '#34d399';
this.weightText = '#ecfdf5';
this.fillStyle = '#064e3b';
this.additionalTextColor = '#ecfdf5';
this.baseStyles.push("selected");
}
NightSelectedEdgeStyle1.prototype = Object.create(BaseEdgeStyle.prototype);
function NightSelectedEdgeStyle2()
{
BaseEdgeStyle.apply(this, arguments);
this.strokeStyle = '#a5b4fc';
this.weightText = '#ecfeff';
this.fillStyle = '#312e81';
this.additionalTextColor = '#ecfeff';
this.baseStyles.push("selected");
}
NightSelectedEdgeStyle2.prototype = Object.create(BaseEdgeStyle.prototype);
function NightSelectedEdgeStyle3()
{
BaseEdgeStyle.apply(this, arguments);
this.strokeStyle = '#fca5a5';
this.weightText = '#fef2f2';
this.fillStyle = '#7f1d1d';
this.additionalTextColor = '#fef2f2';
this.baseStyles.push("selected");
}
NightSelectedEdgeStyle3.prototype = Object.create(BaseEdgeStyle.prototype);
function NightSelectedEdgeStyle4()
{
BaseEdgeStyle.apply(this, arguments);
this.strokeStyle = '#d4d4d8';
this.weightText = '#fafafa';
this.fillStyle = '#3f3f46';
this.additionalTextColor = '#fafafa';
this.baseStyles.push("selected");
}
NightSelectedEdgeStyle4.prototype = Object.create(BaseEdgeStyle.prototype);
function GetNightCommonEdgeStyle()
{
return new NightCommonEdgeStyle();
}
var NightSelectedEdgeStyles = [new NightSelectedEdgeStyle0(), new NightSelectedEdgeStyle1(),
new NightSelectedEdgeStyle2(), new NightSelectedEdgeStyle3(), new NightSelectedEdgeStyle4()];

View File

@@ -18,8 +18,8 @@ function GraphFullStyle(redrawCallback)
this.backgroundCommonStyle = DefaultCommonBackgroundStyle();
this.isBackgroundCommonStyleCustom = false;
this.defaultVertexSize = null;
this.defaultEdgeWidth = null;
this.defaultVertexSize = 30;
this.defaultEdgeWidth = 3;
this.redrawCallback = redrawCallback;
}
@@ -238,6 +238,63 @@ function OldGraphFullStyle()
this.vertexSelectedVertexStyles = FullArrayCopy(OldSelectedGraphStyles);
this.backgroundCommonStyle = GetWhiteBackgroundStyle();
this.defaultVertexSize = 30;
this.defaultEdgeWidth = 4;
}
OldGraphFullStyle.prototype = Object.create(GraphFullStyle.prototype);
function NightGraphFullStyle()
{
GraphFullStyle.apply(this, arguments);
this.version = 1;
this.edgeCommonStyle = GetNightCommonEdgeStyle();
this.edgeSelectedStyles = FullArrayCopy(NightSelectedEdgeStyles);
this.vertexCommonStyle = GetNightCommonVertexStyle();
this.vertexSelectedVertexStyles = FullArrayCopy(NightSelectedGraphStyles);
this.backgroundCommonStyle = GetNightBackgroundStyle();
this.defaultVertexSize = 30;
this.defaultEdgeWidth = 3;
this.isEdgeCommonStyleCustom = true;
this.isEdgeSelectedStylesCustom = true;
this.isVertexCommonStyleCustom = true;
this.isVertexSelectedVertexStylesCustom = true;
this.isBackgroundCommonStyleCustom = true;
}
NightGraphFullStyle.prototype = Object.create(GraphFullStyle.prototype);
function ContrastGraphFullStyle()
{
GraphFullStyle.apply(this, arguments);
this.version = 1;
this.edgeCommonStyle = GetContrastCommonEdgeStyle();
this.edgeSelectedStyles = FullArrayCopy(ContrastSelectedEdgeStyles);
this.vertexCommonStyle = GetContrastCommonVertexStyle();
this.vertexSelectedVertexStyles = FullArrayCopy(ContrastSelectedGraphStyles);
this.backgroundCommonStyle = GetWhiteBackgroundStyle();
this.defaultVertexSize = 36;
this.defaultEdgeWidth = 4;
this.isEdgeCommonStyleCustom = true;
this.isEdgeSelectedStylesCustom = true;
this.isVertexCommonStyleCustom = true;
this.isVertexSelectedVertexStylesCustom = true;
this.isBackgroundCommonStyleCustom = true;
}
ContrastGraphFullStyle.prototype = Object.create(GraphFullStyle.prototype);

View File

@@ -0,0 +1,47 @@
/**
* Contrast vertex style.
*/
// Common style of Graphs.
function ContrastCommonVertexStyle()
{
BaseVertexStyle.apply(this, arguments);
this.lineWidth = 4;
this.strokeStyle = '#000000';
this.fillStyle = '#ffffff';
this.mainTextColor = '#000000';
this.shape = VertexCircleShape;
this.upTextColor = '#000000';
this.commonTextPosition = CommonTextCenter;
this.mainTextFontSize = 16;
this.baseStyles = [];
}
ContrastCommonVertexStyle.prototype = Object.create(BaseVertexStyle.prototype);
// Selected style of Graphs.
function ContrastSelectedVertexStyle0()
{
BaseVertexStyle.apply(this, arguments);
this.strokeStyle = '#000000';
this.mainTextColor = '#ffffff';
this.fillStyle = '#000000';
this.upTextColor = '#ffffff';
this.baseStyles.push("common");
}
ContrastSelectedVertexStyle0.prototype = Object.create(BaseVertexStyle.prototype);
function GetContrastCommonVertexStyle()
{
return new ContrastCommonVertexStyle();
}
var ContrastSelectedGraphStyles = [new ContrastSelectedVertexStyle0(), new ContrastSelectedVertexStyle0(),
new ContrastSelectedVertexStyle0(), new ContrastSelectedVertexStyle0(), new ContrastSelectedVertexStyle0()];

View File

@@ -0,0 +1,103 @@
/**
* Night vertex style.
*/
// Common style of Graphs.
function NightCommonVertexStyle()
{
BaseVertexStyle.apply(this, arguments);
this.lineWidth = 2;
this.strokeStyle = '#38bdf8';
this.fillStyle = '#334155';
this.mainTextColor = '#e5e7eb';
this.shape = VertexCircleShape;
this.upTextColor = '#94a3b8';
this.commonTextPosition = CommonTextCenter;
this.baseStyles = [];
}
NightCommonVertexStyle.prototype = Object.create(BaseVertexStyle.prototype);
// Selected style of Graphs.
function NightSelectedVertexStyle0()
{
BaseVertexStyle.apply(this, arguments);
this.strokeStyle = '#fdba74';
this.mainTextColor = '#fff7ed';
this.fillStyle = '#7c2d12';
this.upTextColor = '#fff7ed';
this.baseStyles.push("common");
}
NightSelectedVertexStyle0.prototype = Object.create(BaseVertexStyle.prototype);
function NightSelectedVertexStyle1()
{
BaseVertexStyle.apply(this, arguments);
this.strokeStyle = '#34d399';
this.mainTextColor = '#ecfdf5';
this.fillStyle = '#064e3b';
this.upTextColor = '#ecfdf5';
this.baseStyles.push("selected");
}
NightSelectedVertexStyle1.prototype = Object.create(BaseVertexStyle.prototype);
function NightSelectedVertexStyle2()
{
BaseVertexStyle.apply(this, arguments);
this.strokeStyle = '#a5b4fc';
this.mainTextColor = '#ffffff';
this.fillStyle = '#312e81';
this.upTextColor = '#ffffff';
this.baseStyles.push("selected");
}
NightSelectedVertexStyle2.prototype = Object.create(BaseVertexStyle.prototype);
function NightSelectedVertexStyle3()
{
BaseVertexStyle.apply(this, arguments);
this.strokeStyle = '#fca5a5';
this.mainTextColor = '#fef2f2';
this.fillStyle = '#7f1d1d';
this.upTextColor = '#fef2f2';
this.baseStyles.push("selected");
}
NightSelectedVertexStyle3.prototype = Object.create(BaseVertexStyle.prototype);
function NightSelectedVertexStyle4()
{
BaseVertexStyle.apply(this, arguments);
this.strokeStyle = '#d4d4d8';
this.mainTextColor = '#fafafa';
this.fillStyle = '#3f3f46';
this.upTextColor = '#fafafa';
this.baseStyles.push("selected");
}
NightSelectedVertexStyle4.prototype = Object.create(BaseVertexStyle.prototype);
function GetNightCommonVertexStyle()
{
return new NightCommonVertexStyle();
}
var NightSelectedGraphStyles = [new NightSelectedVertexStyle0(), new NightSelectedVertexStyle1(),
new NightSelectedVertexStyle2(), new NightSelectedVertexStyle3(), new NightSelectedVertexStyle4()];

View File

@@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=107","/script/shared/point.js?v=107","/script/entities/edge/api/index.js?v=107","/script/entities/edge/model/BaseEdge.js?v=107","/script/entities/edge/model/EdgeModel.js?v=107","/script/entities/vertex/api/index.js?v=107","/script/entities/vertex/model/BaseVertex.js?v=107","/script/entities/vertex/model/VertexModel.js?v=107","/script/entities/graph/model/Graph.js?v=107",]);{let modulDir="pages/create_graph_by_edge_list/";doInclude([include("entities/graph/api/index.js")]);}
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=108","/script/shared/point.js?v=108","/script/entities/edge/api/index.js?v=108","/script/entities/edge/model/BaseEdge.js?v=108","/script/entities/edge/model/EdgeModel.js?v=108","/script/entities/vertex/api/index.js?v=108","/script/entities/vertex/model/BaseVertex.js?v=108","/script/entities/vertex/model/VertexModel.js?v=108","/script/entities/graph/model/Graph.js?v=108",]);{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()
@@ -574,13 +574,19 @@ continue;if((curEdge.vertex1.id==edge.vertex1.id&&curEdge.vertex2.id==edge.verte
{res.push(curEdge);}}
return res;}
Graph.prototype.checkMutiGraph=function()
{var res=false;var start={};for(var i=0;i<this.edges.length;i++)
{var edge=this.edges[i];if(start.hasOwnProperty(edge.vertex1.id)&&start[edge.vertex1.id]==edge.vertex2.id)
{var res=false;let start={};let check_pair=function(id1,id2,start)
{return(start.hasOwnProperty(id1)&&start[id1].includes(id2));}
let add_to_start=function(id1,id2,start)
{if(!start.hasOwnProperty(id1))
{start[id1]=[];}
start[id1].push(id2);}
for(var i=0;i<this.edges.length;i++)
{var edge=this.edges[i];if(check_pair(edge.vertex1.id,edge.vertex2.id,start))
{res=true;break;}
start[edge.vertex1.id]=edge.vertex2.id;if(!edge.isDirect)
{if(start.hasOwnProperty(edge.vertex2.id)&&start[edge.vertex2.id]==edge.vertex1.id)
add_to_start(edge.vertex1.id,edge.vertex2.id,start);if(!edge.isDirect)
{if(check_pair(edge.vertex2.id,edge.vertex1.id,start))
{res=true;break;}
start[edge.vertex2.id]=edge.vertex1.id;}}
add_to_start(edge.vertex2.id,edge.vertex1.id,start);}}
return res;}
Graph.prototype.checkNegativeWeight=function()
{var res=false;for(var i=0;i<this.edges.length&&!res;i++)

View File

@@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=107","/script/shared/point.js?v=107","/script/entities/edge/api/index.js?v=107","/script/entities/edge/model/BaseEdge.js?v=107","/script/entities/edge/model/EdgeModel.js?v=107","/script/entities/vertex/api/index.js?v=107","/script/entities/vertex/model/BaseVertex.js?v=107","/script/entities/vertex/model/VertexModel.js?v=107","/script/entities/graph/model/Graph.js?v=107",]);{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js")]);}
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=108","/script/shared/point.js?v=108","/script/entities/edge/api/index.js?v=108","/script/entities/edge/model/BaseEdge.js?v=108","/script/entities/edge/model/EdgeModel.js?v=108","/script/entities/vertex/api/index.js?v=108","/script/entities/vertex/model/BaseVertex.js?v=108","/script/entities/vertex/model/VertexModel.js?v=108","/script/entities/graph/model/Graph.js?v=108",]);{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()
@@ -574,13 +574,19 @@ continue;if((curEdge.vertex1.id==edge.vertex1.id&&curEdge.vertex2.id==edge.verte
{res.push(curEdge);}}
return res;}
Graph.prototype.checkMutiGraph=function()
{var res=false;var start={};for(var i=0;i<this.edges.length;i++)
{var edge=this.edges[i];if(start.hasOwnProperty(edge.vertex1.id)&&start[edge.vertex1.id]==edge.vertex2.id)
{var res=false;let start={};let check_pair=function(id1,id2,start)
{return(start.hasOwnProperty(id1)&&start[id1].includes(id2));}
let add_to_start=function(id1,id2,start)
{if(!start.hasOwnProperty(id1))
{start[id1]=[];}
start[id1].push(id2);}
for(var i=0;i<this.edges.length;i++)
{var edge=this.edges[i];if(check_pair(edge.vertex1.id,edge.vertex2.id,start))
{res=true;break;}
start[edge.vertex1.id]=edge.vertex2.id;if(!edge.isDirect)
{if(start.hasOwnProperty(edge.vertex2.id)&&start[edge.vertex2.id]==edge.vertex1.id)
add_to_start(edge.vertex1.id,edge.vertex2.id,start);if(!edge.isDirect)
{if(check_pair(edge.vertex2.id,edge.vertex1.id,start))
{res=true;break;}
start[edge.vertex2.id]=edge.vertex1.id;}}
add_to_start(edge.vertex2.id,edge.vertex1.id,start);}}
return res;}
Graph.prototype.checkNegativeWeight=function()
{var res=false;for(var i=0;i<this.edges.length&&!res;i++)

View File

@@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=107","/script/shared/point.js?v=107","/script/entities/edge/api/index.js?v=107","/script/entities/edge/model/BaseEdge.js?v=107","/script/entities/edge/model/EdgeModel.js?v=107","/script/entities/vertex/api/index.js?v=107","/script/entities/vertex/model/BaseVertex.js?v=107","/script/entities/vertex/model/VertexModel.js?v=107","/script/entities/graph/model/Graph.js?v=107","/script/pages/create_graph_by_matrix/model/createByMatrixMain.js?v=107","/script/pages/create_graph_by_matrix/model/main.js?v=107",]);{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=108","/script/shared/point.js?v=108","/script/entities/edge/api/index.js?v=108","/script/entities/edge/model/BaseEdge.js?v=108","/script/entities/edge/model/EdgeModel.js?v=108","/script/entities/vertex/api/index.js?v=108","/script/entities/vertex/model/BaseVertex.js?v=108","/script/entities/vertex/model/VertexModel.js?v=108","/script/entities/graph/model/Graph.js?v=108","/script/pages/create_graph_by_matrix/model/createByMatrixMain.js?v=108","/script/pages/create_graph_by_matrix/model/main.js?v=108",]);{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()
@@ -574,13 +574,19 @@ continue;if((curEdge.vertex1.id==edge.vertex1.id&&curEdge.vertex2.id==edge.verte
{res.push(curEdge);}}
return res;}
Graph.prototype.checkMutiGraph=function()
{var res=false;var start={};for(var i=0;i<this.edges.length;i++)
{var edge=this.edges[i];if(start.hasOwnProperty(edge.vertex1.id)&&start[edge.vertex1.id]==edge.vertex2.id)
{var res=false;let start={};let check_pair=function(id1,id2,start)
{return(start.hasOwnProperty(id1)&&start[id1].includes(id2));}
let add_to_start=function(id1,id2,start)
{if(!start.hasOwnProperty(id1))
{start[id1]=[];}
start[id1].push(id2);}
for(var i=0;i<this.edges.length;i++)
{var edge=this.edges[i];if(check_pair(edge.vertex1.id,edge.vertex2.id,start))
{res=true;break;}
start[edge.vertex1.id]=edge.vertex2.id;if(!edge.isDirect)
{if(start.hasOwnProperty(edge.vertex2.id)&&start[edge.vertex2.id]==edge.vertex1.id)
add_to_start(edge.vertex1.id,edge.vertex2.id,start);if(!edge.isDirect)
{if(check_pair(edge.vertex2.id,edge.vertex1.id,start))
{res=true;break;}
start[edge.vertex2.id]=edge.vertex1.id;}}
add_to_start(edge.vertex2.id,edge.vertex1.id,start);}}
return res;}
Graph.prototype.checkNegativeWeight=function()
{var res=false;for(var i=0;i<this.edges.length&&!res;i++)

View File

@@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/shared/utils.js?v=107","/script/shared/gzip.js?v=107","/script/entities/graph/api/index.js?v=107","/script/shared/point.js?v=107","/script/entities/edge/api/index.js?v=107","/script/entities/edge/model/BaseEdge.js?v=107","/script/entities/edge/model/EdgeModel.js?v=107","/script/entities/vertex/api/index.js?v=107","/script/entities/vertex/model/BaseVertex.js?v=107","/script/entities/vertex/model/VertexModel.js?v=107","/script/entities/graph/model/Graph.js?v=107","/script/features/draw_graph/api/index.js?v=107","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=107","/script/features/draw_graph/model/BackgroundStyle.js?v=107","/script/features/draw_graph/model/EdgeStyle.js?v=107","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=107","/script/features/draw_graph/model/VertexShape.js?v=107","/script/features/draw_graph/model/VertexStyle.js?v=107","/script/features/draw_graph/model/VertexOldStyle.js?v=107","/script/features/draw_graph/model/VertexPrintStyle.js?v=107","/script/features/draw_graph/model/OldEdgeStyle.js?v=107","/script/features/draw_graph/model/PrintEdgeStyle.js?v=107","/script/features/draw_graph/model/VertexNewWhiteStyle.js?v=107","/script/features/draw_graph/model/EdgeNewWhiteStyle.js?v=107","/script/features/draw_graph/model/BaseVertexDrawer.js?v=107","/script/features/draw_graph/model/GraphFullStyle.js?v=107","/script/features/algorithms/api/index.js?v=107","/script/features/algorithms/model/Algorithms.js?v=107","/script/features/algorithms/model/BaseTraversal.js?v=107","/script/features/base_handler/index.js?v=107","/script/features/default_handler/index.js?v=107","/script/features/add_vertices_handler/index.js?v=107","/script/features/connect_vertices_handler/index.js?v=107","/script/features/delete_objects_handler/index.js?v=107","/script/features/algorithm_handler/index.js?v=107","/script/features/select_auto_save_graph_or_not/index.js?v=107","/script/features/graph_preview/index.js?v=107","/script/features/serialization/api/index.js?v=107","/script/features/serialization/model/GraphMLCreator.js?v=107","/script/features/enum_vertices/EnumVertices.js?v=107","/script/pages/editor/model/texts.js?v=107","/script/pages/editor/model/UndoStack.js?v=107","/script/pages/editor/model/DiskSaveLoad.js?v=107","/script/pages/editor/model/Application.js?v=107","/script/pages/editor/ui/ya_metrika.js?v=107","/script/pages/editor/ui/editor.js?v=107","/script/pages/editor/ui/main.js?v=107",]);{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=108","/script/shared/gzip.js?v=108","/script/entities/graph/api/index.js?v=108","/script/shared/point.js?v=108","/script/entities/edge/api/index.js?v=108","/script/entities/edge/model/BaseEdge.js?v=108","/script/entities/edge/model/EdgeModel.js?v=108","/script/entities/vertex/api/index.js?v=108","/script/entities/vertex/model/BaseVertex.js?v=108","/script/entities/vertex/model/VertexModel.js?v=108","/script/entities/graph/model/Graph.js?v=108","/script/features/draw_graph/api/index.js?v=108","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=108","/script/features/draw_graph/model/BackgroundStyle.js?v=108","/script/features/draw_graph/model/EdgeStyle.js?v=108","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=108","/script/features/draw_graph/model/VertexShape.js?v=108","/script/features/draw_graph/model/VertexStyle.js?v=108","/script/features/draw_graph/model/VertexOldStyle.js?v=108","/script/features/draw_graph/model/VertexPrintStyle.js?v=108","/script/features/draw_graph/model/OldEdgeStyle.js?v=108","/script/features/draw_graph/model/PrintEdgeStyle.js?v=108","/script/features/draw_graph/model/VertexNewWhiteStyle.js?v=108","/script/features/draw_graph/model/EdgeNewWhiteStyle.js?v=108","/script/features/draw_graph/model/EdgeNewNightStyle.js?v=108","/script/features/draw_graph/model/VertexNewNightStyle.js?v=108","/script/features/draw_graph/model/EdgeContrastStyle.js?v=108","/script/features/draw_graph/model/VertexContrastStyle.js?v=108","/script/features/draw_graph/model/BaseVertexDrawer.js?v=108","/script/features/draw_graph/model/GraphFullStyle.js?v=108","/script/features/algorithms/api/index.js?v=108","/script/features/algorithms/model/Algorithms.js?v=108","/script/features/algorithms/model/BaseTraversal.js?v=108","/script/features/base_handler/index.js?v=108","/script/features/default_handler/index.js?v=108","/script/features/add_vertices_handler/index.js?v=108","/script/features/connect_vertices_handler/index.js?v=108","/script/features/delete_objects_handler/index.js?v=108","/script/features/algorithm_handler/index.js?v=108","/script/features/select_auto_save_graph_or_not/index.js?v=108","/script/features/graph_preview/index.js?v=108","/script/features/serialization/api/index.js?v=108","/script/features/serialization/model/GraphMLCreator.js?v=108","/script/features/enum_vertices/EnumVertices.js?v=108","/script/pages/editor/model/texts.js?v=108","/script/pages/editor/model/UndoStack.js?v=108","/script/pages/editor/model/DiskSaveLoad.js?v=108","/script/pages/editor/model/Application.js?v=108","/script/pages/editor/ui/ya_metrika.js?v=108","/script/pages/editor/ui/editor.js?v=108","/script/pages/editor/ui/main.js?v=108",]);{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')
@@ -609,13 +609,19 @@ continue;if((curEdge.vertex1.id==edge.vertex1.id&&curEdge.vertex2.id==edge.verte
{res.push(curEdge);}}
return res;}
Graph.prototype.checkMutiGraph=function()
{var res=false;var start={};for(var i=0;i<this.edges.length;i++)
{var edge=this.edges[i];if(start.hasOwnProperty(edge.vertex1.id)&&start[edge.vertex1.id]==edge.vertex2.id)
{var res=false;let start={};let check_pair=function(id1,id2,start)
{return(start.hasOwnProperty(id1)&&start[id1].includes(id2));}
let add_to_start=function(id1,id2,start)
{if(!start.hasOwnProperty(id1))
{start[id1]=[];}
start[id1].push(id2);}
for(var i=0;i<this.edges.length;i++)
{var edge=this.edges[i];if(check_pair(edge.vertex1.id,edge.vertex2.id,start))
{res=true;break;}
start[edge.vertex1.id]=edge.vertex2.id;if(!edge.isDirect)
{if(start.hasOwnProperty(edge.vertex2.id)&&start[edge.vertex2.id]==edge.vertex1.id)
add_to_start(edge.vertex1.id,edge.vertex2.id,start);if(!edge.isDirect)
{if(check_pair(edge.vertex2.id,edge.vertex1.id,start))
{res=true;break;}
start[edge.vertex2.id]=edge.vertex1.id;}}
add_to_start(edge.vertex2.id,edge.vertex1.id,start);}}
return res;}
Graph.prototype.checkNegativeWeight=function()
{var res=false;for(var i=0;i<this.edges.length&&!res;i++)
@@ -662,7 +668,7 @@ 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/BackgroundStyle.js",modulDir),include("model/EdgeStyle.js",modulDir),include("model/BaseEdgeDrawer.js",modulDir),include("model/VertexShape.js",modulDir),include("model/VertexStyle.js",modulDir),include("model/VertexOldStyle.js",modulDir),include("model/VertexPrintStyle.js",modulDir),include("model/OldEdgeStyle.js",modulDir),include("model/PrintEdgeStyle.js",modulDir),include("model/VertexNewWhiteStyle.js",modulDir),include("model/EdgeNewWhiteStyle.js",modulDir),include("model/BaseVertexDrawer.js",modulDir),include("model/GraphFullStyle.js",modulDir)])}
{let modulDir="features/draw_graph/";doInclude([include("model/BaseBackgroundDrawer.js",modulDir),include("model/BackgroundStyle.js",modulDir),include("model/EdgeStyle.js",modulDir),include("model/BaseEdgeDrawer.js",modulDir),include("model/VertexShape.js",modulDir),include("model/VertexStyle.js",modulDir),include("model/VertexOldStyle.js",modulDir),include("model/VertexPrintStyle.js",modulDir),include("model/OldEdgeStyle.js",modulDir),include("model/PrintEdgeStyle.js",modulDir),include("model/VertexNewWhiteStyle.js",modulDir),include("model/EdgeNewWhiteStyle.js",modulDir),include("model/EdgeNewNightStyle.js",modulDir),include("model/VertexNewNightStyle.js",modulDir),include("model/EdgeContrastStyle.js",modulDir),include("model/VertexContrastStyle.js",modulDir),include("model/BaseVertexDrawer.js",modulDir),include("model/GraphFullStyle.js",modulDir)])}
function BaseBackgroundStyle()
{this.commonColor='#ffffff';this.commonOpacity=1.0;this.image=null;}
BaseBackgroundStyle.prototype.Clear=function()
@@ -687,8 +693,12 @@ function CommonBackgroundStyle()
{BaseBackgroundStyle.apply(this,arguments);this.commonColor='#ffffff';this.commonOpacity=1.0;this.image=null;}
CommonBackgroundStyle.prototype=Object.create(BaseBackgroundStyle.prototype);function PrintBackgroundStyle()
{CommonBackgroundStyle.apply(this,arguments);this.commonColor='#ffffff';this.commonOpacity=1.0;this.image=null;}
PrintBackgroundStyle.prototype=Object.create(CommonBackgroundStyle.prototype);function GetWhiteBackgroundStyle()
PrintBackgroundStyle.prototype=Object.create(CommonBackgroundStyle.prototype);function NightBackgroundStyle()
{CommonBackgroundStyle.apply(this,arguments);this.commonColor='#0f172a';this.commonOpacity=1.0;this.image=null;}
NightBackgroundStyle.prototype=Object.create(CommonBackgroundStyle.prototype);function GetWhiteBackgroundStyle()
{return new CommonBackgroundStyle();}
function GetNightBackgroundStyle()
{return new NightBackgroundStyle();}
function DefaultCommonBackgroundStyle()
{return GetWhiteBackgroundStyle();}
function DefaultPrintBackgroundStyle()
@@ -925,7 +935,48 @@ WhiteSelectedEdgeStyle4.prototype=Object.create(BaseEdgeStyle.prototype);functio
{return new WhiteCommonEdgeStyle();}
var WhiteSelectedEdgeStyles=[new WhiteSelectedEdgeStyle0(),new WhiteSelectedEdgeStyle1(),new WhiteSelectedEdgeStyle2(),new WhiteSelectedEdgeStyle3(),new WhiteSelectedEdgeStyle4()];function DefaultCommonEdgeStyle()
{return GetWhiteCommonEdgeStyle();}
var DefaultSelectedEdgeStyles=WhiteSelectedEdgeStyles;function BaseVertexDrawer(context)
var DefaultSelectedEdgeStyles=WhiteSelectedEdgeStyles;function NightCommonEdgeStyle()
{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#cbd5e1';this.weightText='#f8fafc';this.fillStyle='#020617';this.textPadding=4;this.textStrokeWidth=2;this.lineDash=0;this.additionalTextColor='#cbd5e1';this.weightPosition=WeightTextCenter;}
NightCommonEdgeStyle.prototype=Object.create(BaseEdgeStyle.prototype);function NightSelectedEdgeStyle0()
{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#fdba74';this.weightText='#fff7ed';this.fillStyle='#7c2d12';this.additionalTextColor='#fff7ed';this.baseStyles.push("common");}
NightSelectedEdgeStyle0.prototype=Object.create(BaseEdgeStyle.prototype);function NightSelectedEdgeStyle1()
{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#34d399';this.weightText='#ecfdf5';this.fillStyle='#064e3b';this.additionalTextColor='#ecfdf5';this.baseStyles.push("selected");}
NightSelectedEdgeStyle1.prototype=Object.create(BaseEdgeStyle.prototype);function NightSelectedEdgeStyle2()
{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#a5b4fc';this.weightText='#ecfeff';this.fillStyle='#312e81';this.additionalTextColor='#ecfeff';this.baseStyles.push("selected");}
NightSelectedEdgeStyle2.prototype=Object.create(BaseEdgeStyle.prototype);function NightSelectedEdgeStyle3()
{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#fca5a5';this.weightText='#fef2f2';this.fillStyle='#7f1d1d';this.additionalTextColor='#fef2f2';this.baseStyles.push("selected");}
NightSelectedEdgeStyle3.prototype=Object.create(BaseEdgeStyle.prototype);function NightSelectedEdgeStyle4()
{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#d4d4d8';this.weightText='#fafafa';this.fillStyle='#3f3f46';this.additionalTextColor='#fafafa';this.baseStyles.push("selected");}
NightSelectedEdgeStyle4.prototype=Object.create(BaseEdgeStyle.prototype);function GetNightCommonEdgeStyle()
{return new NightCommonEdgeStyle();}
var NightSelectedEdgeStyles=[new NightSelectedEdgeStyle0(),new NightSelectedEdgeStyle1(),new NightSelectedEdgeStyle2(),new NightSelectedEdgeStyle3(),new NightSelectedEdgeStyle4()];function NightCommonVertexStyle()
{BaseVertexStyle.apply(this,arguments);this.lineWidth=2;this.strokeStyle='#38bdf8';this.fillStyle='#334155';this.mainTextColor='#e5e7eb';this.shape=VertexCircleShape;this.upTextColor='#94a3b8';this.commonTextPosition=CommonTextCenter;this.baseStyles=[];}
NightCommonVertexStyle.prototype=Object.create(BaseVertexStyle.prototype);function NightSelectedVertexStyle0()
{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#fdba74';this.mainTextColor='#fff7ed';this.fillStyle='#7c2d12';this.upTextColor='#fff7ed';this.baseStyles.push("common");}
NightSelectedVertexStyle0.prototype=Object.create(BaseVertexStyle.prototype);function NightSelectedVertexStyle1()
{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#34d399';this.mainTextColor='#ecfdf5';this.fillStyle='#064e3b';this.upTextColor='#ecfdf5';this.baseStyles.push("selected");}
NightSelectedVertexStyle1.prototype=Object.create(BaseVertexStyle.prototype);function NightSelectedVertexStyle2()
{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#a5b4fc';this.mainTextColor='#ffffff';this.fillStyle='#312e81';this.upTextColor='#ffffff';this.baseStyles.push("selected");}
NightSelectedVertexStyle2.prototype=Object.create(BaseVertexStyle.prototype);function NightSelectedVertexStyle3()
{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#fca5a5';this.mainTextColor='#fef2f2';this.fillStyle='#7f1d1d';this.upTextColor='#fef2f2';this.baseStyles.push("selected");}
NightSelectedVertexStyle3.prototype=Object.create(BaseVertexStyle.prototype);function NightSelectedVertexStyle4()
{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#d4d4d8';this.mainTextColor='#fafafa';this.fillStyle='#3f3f46';this.upTextColor='#fafafa';this.baseStyles.push("selected");}
NightSelectedVertexStyle4.prototype=Object.create(BaseVertexStyle.prototype);function GetNightCommonVertexStyle()
{return new NightCommonVertexStyle();}
var NightSelectedGraphStyles=[new NightSelectedVertexStyle0(),new NightSelectedVertexStyle1(),new NightSelectedVertexStyle2(),new NightSelectedVertexStyle3(),new NightSelectedVertexStyle4()];function ContrastCommonEdgeStyle()
{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#000000';this.weightText='#000000';this.fillStyle='#ffffff';this.textPadding=4;this.textStrokeWidth=2;this.lineDash=0;this.additionalTextColor='#000000';this.weightPosition=WeightTextCenter;this.mainTextFontSize=16;}
ContrastCommonEdgeStyle.prototype=Object.create(BaseEdgeStyle.prototype);function ContrastSelectedEdgeStyle0()
{BaseEdgeStyle.apply(this,arguments);this.strokeStyle='#000000';this.weightText='#000000';this.fillStyle='#ffffff';this.additionalTextColor='#000000';this.lineDash=1
this.baseStyles.push("common");}
ContrastSelectedEdgeStyle0.prototype=Object.create(BaseEdgeStyle.prototype);function GetContrastCommonEdgeStyle()
{return new ContrastCommonEdgeStyle();}
var ContrastSelectedEdgeStyles=[new ContrastSelectedEdgeStyle0(),new ContrastSelectedEdgeStyle0(),new ContrastSelectedEdgeStyle0(),new ContrastSelectedEdgeStyle0(),new ContrastSelectedEdgeStyle0()];function ContrastCommonVertexStyle()
{BaseVertexStyle.apply(this,arguments);this.lineWidth=4;this.strokeStyle='#000000';this.fillStyle='#ffffff';this.mainTextColor='#000000';this.shape=VertexCircleShape;this.upTextColor='#000000';this.commonTextPosition=CommonTextCenter;this.mainTextFontSize=16;this.baseStyles=[];}
ContrastCommonVertexStyle.prototype=Object.create(BaseVertexStyle.prototype);function ContrastSelectedVertexStyle0()
{BaseVertexStyle.apply(this,arguments);this.strokeStyle='#000000';this.mainTextColor='#ffffff';this.fillStyle='#000000';this.upTextColor='#ffffff';this.baseStyles.push("common");}
ContrastSelectedVertexStyle0.prototype=Object.create(BaseVertexStyle.prototype);function GetContrastCommonVertexStyle()
{return new ContrastCommonVertexStyle();}
var ContrastSelectedGraphStyles=[new ContrastSelectedVertexStyle0(),new ContrastSelectedVertexStyle0(),new ContrastSelectedVertexStyle0(),new ContrastSelectedVertexStyle0(),new ContrastSelectedVertexStyle0()];function BaseVertexDrawer(context)
{this.context=context;}
BaseVertexDrawer.prototype.Draw=function(baseGraph,graphStyle)
{this.SetupStyle(graphStyle);this.DrawShape(baseGraph);if(this.currentStyle.lineWidth!=0)
@@ -948,7 +999,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);}
function GraphFullStyle(redrawCallback)
{this.version=1;this.edgeCommonStyle=DefaultCommonEdgeStyle();this.isEdgeCommonStyleCustom=false;this.edgeSelectedStyles=FullArrayCopy(DefaultSelectedEdgeStyles);this.isEdgeSelectedStylesCustom=false;this.vertexCommonStyle=DefaultCommonVertexStyle();this.isVertexCommonStyleCustom=false;this.vertexSelectedVertexStyles=FullArrayCopy(DefaultSelectedGraphStyles);this.isVertexSelectedVertexStylesCustom=false;this.backgroundCommonStyle=DefaultCommonBackgroundStyle();this.isBackgroundCommonStyleCustom=false;this.defaultVertexSize=null;this.defaultEdgeWidth=null;this.redrawCallback=redrawCallback;}
{this.version=1;this.edgeCommonStyle=DefaultCommonEdgeStyle();this.isEdgeCommonStyleCustom=false;this.edgeSelectedStyles=FullArrayCopy(DefaultSelectedEdgeStyles);this.isEdgeSelectedStylesCustom=false;this.vertexCommonStyle=DefaultCommonVertexStyle();this.isVertexCommonStyleCustom=false;this.vertexSelectedVertexStyles=FullArrayCopy(DefaultSelectedGraphStyles);this.isVertexSelectedVertexStylesCustom=false;this.backgroundCommonStyle=DefaultCommonBackgroundStyle();this.isBackgroundCommonStyleCustom=false;this.defaultVertexSize=30;this.defaultEdgeWidth=3;this.redrawCallback=redrawCallback;}
GraphFullStyle.prototype.Save=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)
@@ -985,8 +1036,12 @@ GraphFullStyle.prototype.Print=function()
{for(const[key,value]of Object.entries(style)){console.log(`${key}:`,value);}}
console.log("Graph Full Style:");console.log("Edge Common Style: ");print_all_fields(this.edgeCommonStyle);console.log("Edge Selected Styles:");this.edgeSelectedStyles.forEach(function(edge_style,index){console.log(`[${index}]`);print_all_fields(edge_style);});console.log("Vertex Common Style: ");print_all_fields(this.vertexCommonStyle);console.log("Vertex Selected Styles: ");this.vertexSelectedVertexStyles.forEach(function(vertex_style,index){console.log(`[${index}]`);print_all_fields(vertex_style);});console.log("Background Common Style: ");print_all_fields(this.backgroundCommonStyle);}
function OldGraphFullStyle()
{GraphFullStyle.apply(this,arguments);this.version=0;this.edgeCommonStyle=GetOldCommonEdgeStyle();this.edgeSelectedStyles=FullArrayCopy(OldSelectedEdgeStyles);this.vertexCommonStyle=GetOldCommonVertexStyle();this.vertexSelectedVertexStyles=FullArrayCopy(OldSelectedGraphStyles);this.backgroundCommonStyle=GetWhiteBackgroundStyle();}
OldGraphFullStyle.prototype=Object.create(GraphFullStyle.prototype);{let modulDir="features/algorithms/";doInclude([include("model/Algorithms.js",modulDir),include("model/BaseTraversal.js",modulDir)])
{GraphFullStyle.apply(this,arguments);this.version=0;this.edgeCommonStyle=GetOldCommonEdgeStyle();this.edgeSelectedStyles=FullArrayCopy(OldSelectedEdgeStyles);this.vertexCommonStyle=GetOldCommonVertexStyle();this.vertexSelectedVertexStyles=FullArrayCopy(OldSelectedGraphStyles);this.backgroundCommonStyle=GetWhiteBackgroundStyle();this.defaultVertexSize=30;this.defaultEdgeWidth=4;}
OldGraphFullStyle.prototype=Object.create(GraphFullStyle.prototype);function NightGraphFullStyle()
{GraphFullStyle.apply(this,arguments);this.version=1;this.edgeCommonStyle=GetNightCommonEdgeStyle();this.edgeSelectedStyles=FullArrayCopy(NightSelectedEdgeStyles);this.vertexCommonStyle=GetNightCommonVertexStyle();this.vertexSelectedVertexStyles=FullArrayCopy(NightSelectedGraphStyles);this.backgroundCommonStyle=GetNightBackgroundStyle();this.defaultVertexSize=30;this.defaultEdgeWidth=3;this.isEdgeCommonStyleCustom=true;this.isEdgeSelectedStylesCustom=true;this.isVertexCommonStyleCustom=true;this.isVertexSelectedVertexStylesCustom=true;this.isBackgroundCommonStyleCustom=true;}
NightGraphFullStyle.prototype=Object.create(GraphFullStyle.prototype);function ContrastGraphFullStyle()
{GraphFullStyle.apply(this,arguments);this.version=1;this.edgeCommonStyle=GetContrastCommonEdgeStyle();this.edgeSelectedStyles=FullArrayCopy(ContrastSelectedEdgeStyles);this.vertexCommonStyle=GetContrastCommonVertexStyle();this.vertexSelectedVertexStyles=FullArrayCopy(ContrastSelectedGraphStyles);this.backgroundCommonStyle=GetWhiteBackgroundStyle();this.defaultVertexSize=36;this.defaultEdgeWidth=4;this.isEdgeCommonStyleCustom=true;this.isEdgeSelectedStylesCustom=true;this.isVertexCommonStyleCustom=true;this.isVertexSelectedVertexStylesCustom=true;this.isBackgroundCommonStyleCustom=true;}
ContrastGraphFullStyle.prototype=Object.create(GraphFullStyle.prototype);{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","MaxIndependentSet.js","FindAllShortestPatches.js","SalesmanProblem.js","SalesmanProblemPath.js"];doIncludeAsync(pluginsList.map((plugin)=>include("model/plugins/"+plugin,modulDir)),onFinish);}}
function getVertexToVertexArray(graph,ignoreDirection)
{res={};for(var i=0;i<graph.edges.length;i++)
@@ -1590,7 +1645,7 @@ 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();}}
{this.listener.OnRenderToEditor();this._redrawGraphInWindow();this.GraphTypeChanged();}}
Application.prototype.redrawGraphTimer=function()
{if(this.isTimerRender)
{var context=this._redrawGraphInWindow();if(this.renderPath.length>1)
@@ -1940,12 +1995,17 @@ let g_base_style_str=" \"base_style\":";let g_base_style_0_str=" \"base_style\":
Application.prototype.LoadUserSettings=function(json)
{let decoded_json=gDecodeFromHTML(json);if(decoded_json!=null&&decoded_json.length>("{"+g_base_style_1_str+"+ some other}").length)
{if(decoded_json.indexOf(g_base_style_str)===-1||decoded_json.indexOf(g_base_style_0_str)!==-1)
{this.style=new OldGraphFullStyle(function()
{this.redrawGraph();}.bind(this));}
{this.UpdateFullStyle(OldGraphFullStyle);}
else if(decoded_json.indexOf(g_base_style_1_str)!==-1)
{this.style=new GraphFullStyle(function()
{this.redrawGraph();}.bind(this));}}
{this.UpdateFullStyle(GraphFullStyle);}}
this.style.Load(decoded_json);}
Application.prototype.UpdateFullStyle=function(FullStyleType)
{let newStyle=new FullStyleType(function()
{this.redrawGraph();}.bind(this));if(newStyle.defaultVertexSize!=null)
{this.SetDefaultVertexSize(newStyle.defaultVertexSize);}
if(newStyle.defaultEdgeWidth!=null)
{this.SetDefaultEdgeWidth(newStyle.defaultEdgeWidth);}
this.style=newStyle;}
Application.prototype.SetVertexStyle=function(index,style)
{if(index==0)
{this.style.vertexCommonStyle=style;this.style.isVertexCommonStyleCustom=true;}
@@ -2291,6 +2351,12 @@ userAction(self.fullscreen?"fullscreen_on":"fullscreen_off");for(var i=0;i<idLis
element.style.display="none";else
element.style.display="block";}
document.getElementById("mainContainer").className=self.fullscreen?"container-fluid page-wrap":"container page-wrap";document.getElementById("FullscreenIcon").className=self.fullscreen?"bi bi-fullscreen-exit":"bi bi-arrows-fullscreen";resizeCanvas();}
document.getElementById("ApplyDefaultStyle").onclick=function()
{userAction("select_default_style");self.application.PushToStack("change_style");self.application.UpdateFullStyle(GraphFullStyle);self.application.redrawGraph();}
document.getElementById("ApplyNightStyle").onclick=function()
{userAction("select_night_style");self.application.PushToStack("change_style");self.application.UpdateFullStyle(NightGraphFullStyle);self.application.redrawGraph();}
document.getElementById("ApplyLargeStyle").onclick=function()
{userAction("select_contrast_style");self.application.PushToStack("change_style");self.application.UpdateFullStyle(ContrastGraphFullStyle);self.application.redrawGraph();}
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))
@@ -2325,6 +2391,8 @@ $(document.getElementById("algorithmCategoryBtn1").querySelector('span[name="hid
Editor.prototype.init=function()
{this.application.onLoad();this.initMouseActions();this.initKeyActions();this.initButtonActions();this.initVoteButton();let self=this;loadAsyncAlgorithms(function(){self.createAlgorithmMenu();});var devTools=document.getElementById('developerTools');devTools.style.left=0;resizeCanvas();this.application.onPostLoadEvent();this.initAlgorithmList();}
Editor.prototype.redraw=function(){this.application.redrawGraph();}
Editor.prototype.OnRenderToEditor=function()
{$("#CanvasMessage").css('color',this.application.style.edgeCommonStyle.strokeStyle);$("#FullscreenIcon").css('color',this.application.style.edgeCommonStyle.strokeStyle);}
Editor.prototype.createAlgorithmMenu=function()
{let self=this;var algorithmBaseId="Algo";var algorithms=this.application.getAlgorithmNames();var index=0;for(var i=0;i<algorithms.length;i++)
{algorithm=algorithms[i];var list=document.getElementById("algorithmCategoryElements"+algorithm.category);var item=document.getElementById("algTopic"+algorithm.category);var clone=item.cloneNode(true);var button=clone.getElementsByTagName("a")[0];var textSpan=button.getElementsByTagName("span")[1];button.id=algorithm.id;textSpan.innerHTML=algorithm.name;clone.style.display="block";button.onclick=function(e)

View File

@@ -106,6 +106,8 @@ Application.prototype.redrawGraph = function()
{
if (!this.isTimerRender)
{
this.listener.OnRenderToEditor();
this._redrawGraphInWindow();
this.GraphTypeChanged();
@@ -1406,23 +1408,35 @@ Application.prototype.LoadUserSettings = function(json)
if (decoded_json.indexOf(g_base_style_str) === -1 || decoded_json.indexOf(g_base_style_0_str) !== -1)
{
// No base_style or base_style = 0
this.style = new OldGraphFullStyle(function()
{
this.redrawGraph();
}.bind(this));
this.UpdateFullStyle(OldGraphFullStyle);
}
else if (decoded_json.indexOf(g_base_style_1_str) !== -1)
{
// base_style = 1
this.style = new GraphFullStyle(function()
{
this.redrawGraph();
}.bind(this));
this.UpdateFullStyle(GraphFullStyle);
}
}
this.style.Load(decoded_json);
}
Application.prototype.UpdateFullStyle = function (FullStyleType)
{
let newStyle = new FullStyleType(function()
{
this.redrawGraph();
}.bind(this));
if (newStyle.defaultVertexSize != null)
{
this.SetDefaultVertexSize(newStyle.defaultVertexSize);
}
if (newStyle.defaultEdgeWidth != null)
{
this.SetDefaultEdgeWidth(newStyle.defaultEdgeWidth);
}
this.style = newStyle;
}
Application.prototype.SetVertexStyle = function (index, style)
{
if (index == 0)

View File

@@ -475,6 +475,33 @@ Editor.prototype.initButtonActions = function()
resizeCanvas();
}
document.getElementById("ApplyDefaultStyle").onclick = function()
{
userAction("select_default_style");
self.application.PushToStack("change_style");
self.application.UpdateFullStyle(GraphFullStyle);
self.application.redrawGraph();
}
document.getElementById("ApplyNightStyle").onclick = function()
{
userAction("select_night_style");
self.application.PushToStack("change_style");
self.application.UpdateFullStyle(NightGraphFullStyle);
self.application.redrawGraph();
}
document.getElementById("ApplyLargeStyle").onclick = function()
{
userAction("select_contrast_style");
self.application.PushToStack("change_style");
self.application.UpdateFullStyle(ContrastGraphFullStyle);
self.application.redrawGraph();
}
document.getElementById('CanvasSearchText').addEventListener('focus', (event) => {
let datalist = document.getElementById('vertexListCanvas');
const options = datalist.options;
@@ -661,6 +688,12 @@ Editor.prototype.redraw = function() {
this.application.redrawGraph();
}
Editor.prototype.OnRenderToEditor = function()
{
$("#CanvasMessage").css('color', this.application.style.edgeCommonStyle.strokeStyle);
$("#FullscreenIcon").css('color', this.application.style.edgeCommonStyle.strokeStyle);
}
Editor.prototype.createAlgorithmMenu = function()
{
let self = this;

View File

@@ -200,21 +200,38 @@
</a>
<ul class="dropdown-menu dropdown-menu-right" role="menu" id="Settings">
<li>
<a class="dropdown-item btn btn-sm btn-submenu" href="javascript:;" role="button" id="SetupVertexStyle"><?= L('common_vertex_settings')?></a>
<a class="dropdown-item dropdown-toggle btn btn-sm btn-submenu" href="javascript:;" role="button">
<span class="bi bi-brush"></span> <?= L('styles')?>
</a>
<ul class="dropdown-menu dropdown-submenu" id="LastUsedGraphsList">
<li>
<a class="dropdown-item btn btn-sm" href="javascript:;" role="button" id="ApplyDefaultStyle"><?= L('default_style')?></a>
</li>
<li>
<a class="dropdown-item btn btn-sm btn-submenu" href="javascript:;" role="button" id="SetupVertexStyleSelected"><?= L('selected_vertex_settings')?></a>
<a class="dropdown-item btn btn-sm" href="javascript:;" role="button" id="ApplyNightStyle"><?= L('night_style')?></a>
</li>
<li>
<a class="dropdown-item btn btn-sm" href="javascript:;" role="button" id="ApplyLargeStyle"><?= L('large_high_contrast_style')?></a>
</li>
</ul>
</li>
<li><hr class="dropdown-divider hidden-phone"></li>
<li>
<a class="dropdown-item btn btn-sm btn-submenu" href="javascript:;" role="button" id="SetupEdgeStyle"><?= L('common_edge_settings')?></a>
<a class="dropdown-item btn btn-sm btn-submenu" href="javascript:;" role="button" id="SetupVertexStyle"><span class="bi bi-1-circle"></span> <?= L('common_vertex_settings')?></a>
</li>
<li>
<a class="dropdown-item btn btn-sm btn-submenu" href="javascript:;" role="button" id="SetupEdgeStyleSelected"><?= L('selected_edge_settings')?></a>
<a class="dropdown-item btn btn-sm btn-submenu" href="javascript:;" role="button" id="SetupVertexStyleSelected"><span class="bi bi-1-circle-fill"></span> <?= L('selected_vertex_settings')?></a>
</li>
<li><hr class="dropdown-divider hidden-phone"></li>
<li>
<a class="dropdown-item btn btn-sm btn-submenu" href="javascript:;" role="button" id="SetupBackgroundStyle"><?= L('background_style') ?></a>
<a class="dropdown-item btn btn-sm btn-submenu" href="javascript:;" role="button" id="SetupEdgeStyle"><span class="bi bi-arrow-up-right"></span> <?= L('common_edge_settings')?></a>
</li>
<li>
<a class="dropdown-item btn btn-sm btn-submenu" href="javascript:;" role="button" id="SetupEdgeStyleSelected"><span class="bi bi-arrow-up-right"></span> <?= L('selected_edge_settings')?></a>
</li>
<li><hr class="dropdown-divider hidden-phone"></li>
<li>
<a class="dropdown-item btn btn-sm btn-submenu" href="javascript:;" role="button" id="SetupBackgroundStyle"><span class="bi bi-back"></span> <?= L('background_style') ?></a>
</li>
</ul>
</li>