Add text animation during calculating algorithm

This commit is contained in:
Oleg Sh 2025-05-23 16:25:09 +02:00
parent 6e8ee286d2
commit 0facf52c63
6 changed files with 38 additions and 8 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'] = 95;
$g_config['engine_version'] = 96;
?>

View File

@ -165,8 +165,33 @@ function BaseAlgorithmEx(graph, app)
// inheritance.
BaseAlgorithmEx.prototype = Object.create(BaseAlgorithm.prototype);
/* This class add animation during processing algorithm. Add animation for ...*/
class ProcessingMessage
{
constructor(algorithm_object) {
this.algorithm_object = algorithm_object;
this.processing_index = 0;
this.original_message = this.algorithm_object.message;
this.processing_timer = setInterval(function()
{
this.processing_index = (this.processing_index + 1) % 3;
this.algorithm_object.message = this.original_message + ".".repeat(this.processing_index);
this.algorithm_object.app.updateMessage();
}.bind(this), 500);
}
stop() {
this.algorithm_object.message = this.original_message;
this.algorithm_object.app.updateMessage();
clearInterval(this.processing_timer);
}
}
BaseAlgorithmEx.prototype.CalculateAlgorithm = function(algorithmName, otherParams, resultCallback, ignoreSeparateNodes = false)
{
// Setup processing message
let processing_message = new ProcessingMessage(this);
if (location.hostname === "localhost" || location.hostname === "127.0.0.1")
console.log(algorithmName + " " + otherParams);
@ -252,6 +277,7 @@ BaseAlgorithmEx.prototype.CalculateAlgorithm = function(algorithmName, otherPara
console.log(result);
processing_message.stop();
resultCallback(pathObjects, properties, result);
};

View File

@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=95","/script/shared/point.js?v=95","/script/entities/edge/api/index.js?v=95","/script/entities/edge/model/BaseEdge.js?v=95","/script/entities/edge/model/EdgeModel.js?v=95","/script/entities/vertex/api/index.js?v=95","/script/entities/vertex/model/BaseVertex.js?v=95","/script/entities/vertex/model/VertexModel.js?v=95","/script/entities/graph/model/Graph.js?v=95",]);{let modulDir="pages/create_graph_by_edge_list/";doInclude([include("entities/graph/api/index.js")]);}
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=96","/script/shared/point.js?v=96","/script/entities/edge/api/index.js?v=96","/script/entities/edge/model/BaseEdge.js?v=96","/script/entities/edge/model/EdgeModel.js?v=96","/script/entities/vertex/api/index.js?v=96","/script/entities/vertex/model/BaseVertex.js?v=96","/script/entities/vertex/model/VertexModel.js?v=96","/script/entities/graph/model/Graph.js?v=96",]);{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()

View File

@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=95","/script/shared/point.js?v=95","/script/entities/edge/api/index.js?v=95","/script/entities/edge/model/BaseEdge.js?v=95","/script/entities/edge/model/EdgeModel.js?v=95","/script/entities/vertex/api/index.js?v=95","/script/entities/vertex/model/BaseVertex.js?v=95","/script/entities/vertex/model/VertexModel.js?v=95","/script/entities/graph/model/Graph.js?v=95",]);{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js")]);}
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=96","/script/shared/point.js?v=96","/script/entities/edge/api/index.js?v=96","/script/entities/edge/model/BaseEdge.js?v=96","/script/entities/edge/model/EdgeModel.js?v=96","/script/entities/vertex/api/index.js?v=96","/script/entities/vertex/model/BaseVertex.js?v=96","/script/entities/vertex/model/VertexModel.js?v=96","/script/entities/graph/model/Graph.js?v=96",]);{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()

View File

@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=95","/script/shared/point.js?v=95","/script/entities/edge/api/index.js?v=95","/script/entities/edge/model/BaseEdge.js?v=95","/script/entities/edge/model/EdgeModel.js?v=95","/script/entities/vertex/api/index.js?v=95","/script/entities/vertex/model/BaseVertex.js?v=95","/script/entities/vertex/model/VertexModel.js?v=95","/script/entities/graph/model/Graph.js?v=95","/script/pages/create_graph_by_matrix/model/createByMatrixMain.js?v=95","/script/pages/create_graph_by_matrix/model/main.js?v=95",]);{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=96","/script/shared/point.js?v=96","/script/entities/edge/api/index.js?v=96","/script/entities/edge/model/BaseEdge.js?v=96","/script/entities/edge/model/EdgeModel.js?v=96","/script/entities/vertex/api/index.js?v=96","/script/entities/vertex/model/BaseVertex.js?v=96","/script/entities/vertex/model/VertexModel.js?v=96","/script/entities/graph/model/Graph.js?v=96","/script/pages/create_graph_by_matrix/model/createByMatrixMain.js?v=96","/script/pages/create_graph_by_matrix/model/main.js?v=96",]);{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()

View File

@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/shared/utils.js?v=95","/script/shared/gzip.js?v=95","/script/entities/graph/api/index.js?v=95","/script/shared/point.js?v=95","/script/entities/edge/api/index.js?v=95","/script/entities/edge/model/BaseEdge.js?v=95","/script/entities/edge/model/EdgeModel.js?v=95","/script/entities/vertex/api/index.js?v=95","/script/entities/vertex/model/BaseVertex.js?v=95","/script/entities/vertex/model/VertexModel.js?v=95","/script/entities/graph/model/Graph.js?v=95","/script/features/draw_graph/api/index.js?v=95","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=95","/script/features/draw_graph/model/EdgeStyle.js?v=95","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=95","/script/features/draw_graph/model/VertexShape.js?v=95","/script/features/draw_graph/model/VertexStyle.js?v=95","/script/features/draw_graph/model/BaseVertexDrawer.js?v=95","/script/features/draw_graph/model/GraphFullStyle.js?v=95","/script/features/algorithms/api/index.js?v=95","/script/features/algorithms/model/Algorithms.js?v=95","/script/features/algorithms/model/BaseTraversal.js?v=95","/script/features/base_handler/index.js?v=95","/script/features/default_handler/index.js?v=95","/script/features/add_vertices_handler/index.js?v=95","/script/features/connect_vertices_handler/index.js?v=95","/script/features/delete_objects_handler/index.js?v=95","/script/features/algorithm_handler/index.js?v=95","/script/features/select_auto_save_graph_or_not/index.js?v=95","/script/features/graph_preview/index.js?v=95","/script/features/serialization/api/index.js?v=95","/script/features/serialization/model/GraphMLCreator.js?v=95","/script/features/enum_vertices/EnumVertices.js?v=95","/script/pages/editor/model/texts.js?v=95","/script/pages/editor/model/UndoStack.js?v=95","/script/pages/editor/model/DiskSaveLoad.js?v=95","/script/pages/editor/model/Application.js?v=95","/script/pages/editor/ui/ya_metrika.js?v=95","/script/pages/editor/ui/editor.js?v=95","/script/pages/editor/ui/main.js?v=95",]);{function onloadEditor(){console.log("onload() call");doIncludeAsync([include("shared/canvas2svg.js"),include("features/group_rename_handler/index.js"),include("features/saved_graph_handler/index.js"),include("features/saved_graph_image_handler/index.js"),include("features/show_adjacency_matrix/index.js"),include("features/show_distance_matrix/index.js"),include("features/show_incidence_matrix/index.js"),include("features/setup_background_style/index.js"),include("features/setup_edge_style/index.js"),include("features/setup_vertex_style/index.js"),]);postLoadPage();}
moduleLoader.beginCacheLoading(["/script/shared/utils.js?v=96","/script/shared/gzip.js?v=96","/script/entities/graph/api/index.js?v=96","/script/shared/point.js?v=96","/script/entities/edge/api/index.js?v=96","/script/entities/edge/model/BaseEdge.js?v=96","/script/entities/edge/model/EdgeModel.js?v=96","/script/entities/vertex/api/index.js?v=96","/script/entities/vertex/model/BaseVertex.js?v=96","/script/entities/vertex/model/VertexModel.js?v=96","/script/entities/graph/model/Graph.js?v=96","/script/features/draw_graph/api/index.js?v=96","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=96","/script/features/draw_graph/model/EdgeStyle.js?v=96","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=96","/script/features/draw_graph/model/VertexShape.js?v=96","/script/features/draw_graph/model/VertexStyle.js?v=96","/script/features/draw_graph/model/BaseVertexDrawer.js?v=96","/script/features/draw_graph/model/GraphFullStyle.js?v=96","/script/features/algorithms/api/index.js?v=96","/script/features/algorithms/model/Algorithms.js?v=96","/script/features/algorithms/model/BaseTraversal.js?v=96","/script/features/base_handler/index.js?v=96","/script/features/default_handler/index.js?v=96","/script/features/add_vertices_handler/index.js?v=96","/script/features/connect_vertices_handler/index.js?v=96","/script/features/delete_objects_handler/index.js?v=96","/script/features/algorithm_handler/index.js?v=96","/script/features/select_auto_save_graph_or_not/index.js?v=96","/script/features/graph_preview/index.js?v=96","/script/features/serialization/api/index.js?v=96","/script/features/serialization/model/GraphMLCreator.js?v=96","/script/features/enum_vertices/EnumVertices.js?v=96","/script/pages/editor/model/texts.js?v=96","/script/pages/editor/model/UndoStack.js?v=96","/script/pages/editor/model/DiskSaveLoad.js?v=96","/script/pages/editor/model/Application.js?v=96","/script/pages/editor/ui/ya_metrika.js?v=96","/script/pages/editor/ui/editor.js?v=96","/script/pages/editor/ui/main.js?v=96",]);{function onloadEditor(){console.log("onload() call");doIncludeAsync([include("shared/canvas2svg.js"),include("features/group_rename_handler/index.js"),include("features/saved_graph_handler/index.js"),include("features/saved_graph_image_handler/index.js"),include("features/show_adjacency_matrix/index.js"),include("features/show_distance_matrix/index.js"),include("features/show_incidence_matrix/index.js"),include("features/setup_background_style/index.js"),include("features/setup_edge_style/index.js"),include("features/setup_vertex_style/index.js"),]);postLoadPage();}
let modulDir="pages/editor/";doInclude([include("shared/utils.js"),include("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')
@ -956,8 +956,12 @@ BaseAlgorithm.prototype.IsSupportNegativeWeight=function()
{return false;}
function BaseAlgorithmEx(graph,app)
{BaseAlgorithm.apply(this,arguments);}
BaseAlgorithmEx.prototype=Object.create(BaseAlgorithm.prototype);BaseAlgorithmEx.prototype.CalculateAlgorithm=function(algorithmName,otherParams,resultCallback,ignoreSeparateNodes=false)
{if(location.hostname==="localhost"||location.hostname==="127.0.0.1")
BaseAlgorithmEx.prototype=Object.create(BaseAlgorithm.prototype);class ProcessingMessage
{constructor(algorithm_object){this.algorithm_object=algorithm_object;this.processing_index=0;this.original_message=this.algorithm_object.message;this.processing_timer=setInterval(function()
{this.processing_index=(this.processing_index+1)%3;this.algorithm_object.message=this.original_message+".".repeat(this.processing_index);this.algorithm_object.app.updateMessage();}.bind(this),500);}
stop(){this.algorithm_object.message=this.original_message;this.algorithm_object.app.updateMessage();clearInterval(this.processing_timer);}}
BaseAlgorithmEx.prototype.CalculateAlgorithm=function(algorithmName,otherParams,resultCallback,ignoreSeparateNodes=false)
{let processing_message=new ProcessingMessage(this);if(location.hostname==="localhost"||location.hostname==="127.0.0.1")
console.log(algorithmName+" "+otherParams);var graph=this.graph;var ignoreNodes={};if(ignoreSeparateNodes)
for(var i=0;i<graph.vertices.length;i++)
if(!graph.HasConnectedNodes(graph.vertices[i]))
@ -970,7 +974,7 @@ properties[id][$(this).attr('key')]=$(this).text();}});});$edges=$xml.find("edge
{edge=graph.FindEdgeById($(this).attr('id'));}
pathObjects.push(edge);$data=$(this).find("data");$data.each(function(){if(!properties[edge.id])
{properties[edge.id]={};}
properties[edge.id][$(this).attr('key')]=$(this).text();});});console.log(result);resultCallback(pathObjects,properties,result);};var callCGIAlgorithms=function()
properties[edge.id][$(this).attr('key')]=$(this).text();});});console.log(result);processing_message.stop();resultCallback(pathObjects,properties,result);};var callCGIAlgorithms=function()
{var queryString=algorithmName+"=cgiInput&report=xml";otherParams.forEach((param)=>queryString+="&"+param.name+"="+param.value);$.ajax({type:"POST",url:"/"+SiteDir+"cgi-bin/GraphCGI.exe?"+queryString,data:xml,dataType:"text",}).done(function(msg)
{processResult(msg);});};if(this.app.isSupportEmscripten()){console.log("Use Emscripten");var delimiter="<s\\emscript_split\\s>";var processData=algorithmName+delimiter+xml+
delimiter+"report"+delimiter+"xml";otherParams.forEach((param)=>processData+=delimiter+param.name+delimiter+param.value);var res={};try{res=this.app.processEmscripten(processData);}