Improved incidence matrix dialog. Add enumeration for edges.

This commit is contained in:
Oleg Sh
2026-10-03 14:41:23 +02:00
parent b53487dda0
commit c9ff7ab3f9
24 changed files with 333 additions and 54 deletions
+13 -6
View File
@@ -869,7 +869,7 @@ Graph.prototype.TestIncidenceMatrix = function (matrix, rowsObj, colsObj, separa
if (bGoodFormat)
{
for (var i = 0; i < colsObj.cols[0].length; i++)
for (var i = 0; i < columnCount; i++)
{
var values = [];
for (j = 0; j < colsObj.cols.length; ++j)
@@ -908,7 +908,8 @@ Graph.prototype.SetIncidenceMatrix = function (matrix, viewportSize, currentEnum
}
var newVertices = [];
var bWeightGraph = false;
for (var i = 0; i < cols[0].length; i++)
var columnCount = cols.length > 0 ? cols[0].length : 0;
for (var i = 0; i < columnCount; i++)
{
var edgeValue = [];
var edgeIndex = [];
@@ -965,17 +966,18 @@ Graph.prototype.SetIncidenceMatrix = function (matrix, viewportSize, currentEnum
});
}
for (var i = cols.length; i < Math.max(this.vertices.length, cols.length); i++)
var rowCount = rows.length > 0 ? rows.length : this.vertices.length;
for (var i = rowCount; i < this.vertices.length; i++)
{
this.DeleteVertex(this.vertices[i]);
i--;
i--;
}
this.VerticesReposition(viewportSize, newVertices);
}
}
Graph.prototype.GetIncidenceMatrix = function ()
Graph.prototype.GetIncidenceMatrix = function (res_columns_width)
{
var matrix = "";
let cols_width = [];
@@ -1001,7 +1003,7 @@ Graph.prototype.GetIncidenceMatrix = function ()
for (var j = 0; j < this.edges.length; j++)
{
let max_width = 0;
let max_width = Math.min(this.edges[j].GetUpText().toString().length, 2);
for (var i = 0; i < this.vertices.length; i++)
{
let str = "" + get_edge_weight_str(i, j);
@@ -1026,6 +1028,11 @@ Graph.prototype.GetIncidenceMatrix = function ()
matrix = matrix + "\n";
}
if (res_columns_width !== undefined) {
res_columns_width.length = 0;
res_columns_width.push(...cols_width);
}
return matrix;
}
+173 -16
View File
@@ -23,23 +23,45 @@ ShowIncidenceMatrix.prototype.show = function()
{
var handler = this;
var dialogButtons = {};
$('#IncidenceMatrixField').unbind();
$( "#IncidenceMatrixField" ).on('keyup change', function (eventObject)
let edgeNames = this.app.graph.edges.map(function(edge) { return edge.GetUpText(); });
let edgeEnumSelect = $("#incidenceEdgeEnumeration");
let edgeNamesDialog = $("#incidenceEdgeNamesDialog");
let edgeNamesList = $("#incidenceEdgeNamesList");
let currentColumns = [];
let currentColumnWidths = [];
let matrixIsValid = false;
let edgeEnumValue = this.app.currentEnumEdgesType || "";
if (edgeEnumValue === "Custom")
{
edgeEnumValue = "";
}
let selectedEdgeEnumValue = edgeEnumValue;
edgeEnumSelect.find("option:not(:first)").remove();
this.app.GetEnumVerticesList().forEach(function(item) {
if (item.value !== "Custom")
{
if (!handler.app.TestIncidenceMatrix($( "#IncidenceMatrixField" ).val(), [], []))
{
$( "#BadIncidenceMatrixFormatMessage" ).show();
}
else
{
$( "#BadIncidenceMatrixFormatMessage" ).hide();
}
});
edgeEnumSelect.append($("<option>", { value: item.value, text: item.text }));
}
});
edgeEnumSelect.val(edgeEnumValue);
$("#IncidenceMatrixField").off("keyup change input");
dialogButtons[g_save] = function() {
handler.app.PushToStack("IncidenceMatrixChanged");
handler.app.SetIncidenceMatrixSmart($( "#IncidenceMatrixField" ).val());
let matrix = ta.val();
let rows = {};
let columns = {};
let validIncidenceMatrix = handler.app.TestIncidenceMatrix(matrix, rows, columns);
handler.app.PushToStack("IncidenceMatrixChanged");
handler.app.SetIncidenceMatrixSmart(matrix);
if (validIncidenceMatrix)
{
handler.app.SetEnumEdgesType(selectedEdgeEnumValue);
handler.app.graph.edges.forEach(function(edge, edgeIndex) {
edge.SetUpText(edgeNames[edgeIndex] || "");
});
handler.app.redrawGraph();
}
$( this ).dialog( "close" );
};
dialogButtons[g_cancel] = function() {
@@ -47,13 +69,16 @@ ShowIncidenceMatrix.prototype.show = function()
};
let ta = $("#IncidenceMatrixField");
let topWrap = $("#incidenceMatrix_top_text");
let sideWrap = $("#incidenceMatrix_side_text");
let incidenceMatrix = this.app.GetIncidenceMatrix();
ta.on("scroll", function() {
topWrap.scrollLeft(ta.scrollLeft());
sideWrap.scrollTop(ta.scrollTop());
});
$( "#IncidenceMatrixField" ).val(this.app.GetIncidenceMatrix().trimEnd());
$( "#IncidenceMatrixField" ).val(incidenceMatrix.trimEnd());
ta.focus()[0].setSelectionRange(0, 0);
$( "#BadIncidenceMatrixFormatMessage" ).hide();
@@ -67,6 +92,138 @@ ShowIncidenceMatrix.prototype.show = function()
}
$("#incidenceMatrix_side_text_text").html(sideText + "\n");
let topText = $("#incidenceMatrix_top_text_text");
let renderEdgeNames = function(columns) {
topText.empty();
let columnCount = columns.length > 0 ? columns[0].length : 0;
for (let edgeIndex = 0; edgeIndex < columnCount; edgeIndex++)
{
let edgeName = (edgeNames[edgeIndex] || "").slice(0, 2);
let columnWidth = Math.max(1, edgeName.length, currentColumnWidths[edgeIndex] || 0);
for (let rowIndex = 0; rowIndex < columns.length; rowIndex++)
{
columnWidth = Math.max(columnWidth, String(columns[rowIndex][edgeIndex]).trim().length);
}
topText.append(document.createTextNode(edgeName.slice(0, columnWidth).padStart(columnWidth, " ")));
if (edgeIndex < columnCount - 1)
{
topText.append(document.createTextNode(" "));
}
}
};
let getMatrixColumnWidths = function(matrix, columnCount) {
let widths = Array(columnCount).fill(1);
let rows = matrix.split(/\r?\n/).filter(function(row) { return row.trim().length > 0; });
rows.forEach(function(row) {
let cells = row.split(",");
if (cells.length !== columnCount)
{
return;
}
cells.forEach(function(cell, columnIndex) {
let cellWidth = cell.length;
if (columnIndex > 0 && cell.startsWith(" "))
{
cellWidth--;
}
widths[columnIndex] = Math.max(widths[columnIndex], cellWidth);
});
});
return widths;
};
let getEdgeEnumType = function(value) {
return handler.app.enumVerticesTextList.find(function(enumType) {
return enumType.GetValue() === value && value !== "Custom";
});
};
let applyEdgeEnumeration = function(value) {
if (!matrixIsValid)
{
return;
}
selectedEdgeEnumValue = value;
let enumType = getEdgeEnumType(value);
for (let edgeIndex = 0; edgeIndex < edgeNames.length; edgeIndex++)
{
edgeNames[edgeIndex] = enumType ? enumType.GetVertexText(edgeIndex).toString() : "";
}
renderEdgeNames(currentColumns);
};
edgeEnumSelect.off("change").on("change", function() {
applyEdgeEnumeration($(this).val());
});
$("#editIncidenceEdgeNames").off("click").on("click", function() {
if (!matrixIsValid)
{
return;
}
edgeNamesList.val(edgeNames.join("\n"));
edgeNamesDialog.dialog("open");
});
edgeNamesDialog.dialog({
autoOpen: false,
modal: true,
resizable: false,
width: "auto",
title: $("#EdgeLabel").text().trim(),
buttons: {
[g_save]: function() {
let editedNames = edgeNamesList.val().split(/\r?\n/);
edgeNames = Array.from({ length: edgeNames.length }, function(_, index) {
return editedNames[index] || "";
});
renderEdgeNames(currentColumns);
$(this).dialog("close");
},
[g_cancel]: function() {
$(this).dialog("close");
}
},
dialogClass: 'EdgeDialog'
});
let updateMatrixState = function() {
let rows = {};
let columns = {};
let isValid = handler.app.TestIncidenceMatrix(ta.val(), rows, columns);
if (isValid)
{
let columnCount = columns.cols.length > 0 ? columns.cols[0].length : 0;
currentColumns = columns.cols;
currentColumnWidths = getMatrixColumnWidths(ta.val(), columnCount);
let enumType = getEdgeEnumType(selectedEdgeEnumValue);
if (columnCount < edgeNames.length)
{
edgeNames.length = columnCount;
}
else
{
for (let edgeIndex = edgeNames.length; edgeIndex < columnCount; edgeIndex++)
{
edgeNames.push(enumType ? enumType.GetVertexText(edgeIndex).toString() : "");
}
}
matrixIsValid = true;
edgeEnumSelect.prop("disabled", false);
$("#editIncidenceEdgeNames").prop("disabled", false);
$("#BadIncidenceMatrixFormatMessage").hide();
renderEdgeNames(columns.cols);
}
else
{
matrixIsValid = false;
edgeEnumSelect.prop("disabled", true);
$("#editIncidenceEdgeNames").prop("disabled", true);
$("#BadIncidenceMatrixFormatMessage").show();
}
};
ta.on("input", updateMatrixState);
updateMatrixState();
$( "#incidenceMatrix" ).dialog({
resizable: false,
height: "auto",
@@ -77,7 +234,7 @@ ShowIncidenceMatrix.prototype.show = function()
dialogClass: 'EdgeDialog',
open: function(event, ui) {
/* Set width for side text */
$("#incidenceMatrix_top_text").width(ta.width());
topWrap.width(ta.width());
$("#BadIncidenceMatrixFormatMessage").width(ta.width());
}
});
@@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=109","/script/shared/point.js?v=109","/script/entities/edge/api/index.js?v=109","/script/entities/edge/model/BaseEdge.js?v=109","/script/entities/edge/model/EdgeModel.js?v=109","/script/entities/vertex/api/index.js?v=109","/script/entities/vertex/model/BaseVertex.js?v=109","/script/entities/vertex/model/VertexModel.js?v=109","/script/entities/graph/model/Graph.js?v=109",]);{let modulDir="pages/create_graph_by_edge_list/";doInclude([include("entities/graph/api/index.js")]);}
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=110","/script/shared/point.js?v=110","/script/entities/edge/api/index.js?v=110","/script/entities/edge/model/BaseEdge.js?v=110","/script/entities/edge/model/EdgeModel.js?v=110","/script/entities/vertex/api/index.js?v=110","/script/entities/vertex/model/BaseVertex.js?v=110","/script/entities/vertex/model/VertexModel.js?v=110","/script/entities/graph/model/Graph.js?v=110",]);{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()
@@ -452,7 +452,7 @@ if(i==0)
if(colsObj.cols[i].length!=columnCount)
{bGoodFormat=false;break;}}
if(bGoodFormat)
{for(var i=0;i<colsObj.cols[0].length;i++)
{for(var i=0;i<columnCount;i++)
{var values=[];for(j=0;j<colsObj.cols.length;++j)
{if(colsObj.cols[j][i]!=0)
{values.push(colsObj.cols[j][i]);}}
@@ -463,7 +463,7 @@ Graph.prototype.SetIncidenceMatrix=function(matrix,viewportSize,currentEnumVerti
{var rowsObj={};var colsObj={};if(this.TestIncidenceMatrix(matrix,rowsObj,colsObj))
{rows=rowsObj.rows;cols=colsObj.cols;var clonedEdge=this.edges.slice(0);for(var i=0;i<clonedEdge.length;i++)
{this.DeleteEdge(clonedEdge[i]);}
var newVertices=[];var bWeightGraph=false;for(var i=0;i<cols[0].length;i++)
var newVertices=[];var bWeightGraph=false;var columnCount=cols.length>0?cols[0].length:0;for(var i=0;i<columnCount;i++)
{var edgeValue=[];var edgeIndex=[];for(var j=0;j<cols.length;j++)
{if(j>=this.vertices.length)
{var newPos=new Point(0,0);newVertices.push(new BaseVertex(newPos.x,newPos.y,currentEnumVerticesType));this.AddNewVertex(newVertices[newVertices.length-1]);}
@@ -479,10 +479,10 @@ var nEdgeIndex=this.AddNewEdgeSafe(this.vertices[edgeIndex[0]],this.vertices[edg
{bWeightGraph=bWeightGraph||this.edges[nEdgeIndex].weight!=1;}}}
if(!bWeightGraph)
{this.edges.forEach(function(part,index,theArray){theArray[index].useWeight=false;});}
for(var i=cols.length;i<Math.max(this.vertices.length,cols.length);i++)
var rowCount=rows.length>0?rows.length:this.vertices.length;for(var i=rowCount;i<this.vertices.length;i++)
{this.DeleteVertex(this.vertices[i]);i--;}
this.VerticesReposition(viewportSize,newVertices);}}
Graph.prototype.GetIncidenceMatrix=function()
Graph.prototype.GetIncidenceMatrix=function(res_columns_width)
{var matrix="";let cols_width=[];let get_edge_weight_str=(vertex_index,edge_index)=>{if(this.edges[edge_index].vertex1==this.vertices[vertex_index])
{return this.edges[edge_index].weight.toString();}
else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect)
@@ -491,7 +491,7 @@ else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&this.edges[
{return-this.edges[edge_index].weight.toString();}
else
{return"0";}};for(var j=0;j<this.edges.length;j++)
{let max_width=0;for(var i=0;i<this.vertices.length;i++)
{let max_width=Math.min(this.edges[j].GetUpText().toString().length,2);for(var i=0;i<this.vertices.length;i++)
{let str=""+get_edge_weight_str(i,j);max_width=Math.max(max_width,str.length);}
cols_width.push(max_width);}
for(var i=0;i<this.vertices.length;i++)
@@ -499,6 +499,7 @@ for(var i=0;i<this.vertices.length;i++)
{let weight_str=get_edge_weight_str(i,j);weight_str=" ".repeat(cols_width[j]-weight_str.length)+weight_str;matrix+=""+weight_str;if(j!=this.edges.length-1)
{matrix+=", ";}}
matrix=matrix+"\n";}
if(res_columns_width!==undefined){res_columns_width.length=0;res_columns_width.push(...cols_width);}
return matrix;}
Graph.prototype.SplitMatrixString=function(line,separator)
{if(separator===undefined)
@@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=109","/script/shared/point.js?v=109","/script/entities/edge/api/index.js?v=109","/script/entities/edge/model/BaseEdge.js?v=109","/script/entities/edge/model/EdgeModel.js?v=109","/script/entities/vertex/api/index.js?v=109","/script/entities/vertex/model/BaseVertex.js?v=109","/script/entities/vertex/model/VertexModel.js?v=109","/script/entities/graph/model/Graph.js?v=109",]);{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js")]);}
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=110","/script/shared/point.js?v=110","/script/entities/edge/api/index.js?v=110","/script/entities/edge/model/BaseEdge.js?v=110","/script/entities/edge/model/EdgeModel.js?v=110","/script/entities/vertex/api/index.js?v=110","/script/entities/vertex/model/BaseVertex.js?v=110","/script/entities/vertex/model/VertexModel.js?v=110","/script/entities/graph/model/Graph.js?v=110",]);{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()
@@ -452,7 +452,7 @@ if(i==0)
if(colsObj.cols[i].length!=columnCount)
{bGoodFormat=false;break;}}
if(bGoodFormat)
{for(var i=0;i<colsObj.cols[0].length;i++)
{for(var i=0;i<columnCount;i++)
{var values=[];for(j=0;j<colsObj.cols.length;++j)
{if(colsObj.cols[j][i]!=0)
{values.push(colsObj.cols[j][i]);}}
@@ -463,7 +463,7 @@ Graph.prototype.SetIncidenceMatrix=function(matrix,viewportSize,currentEnumVerti
{var rowsObj={};var colsObj={};if(this.TestIncidenceMatrix(matrix,rowsObj,colsObj))
{rows=rowsObj.rows;cols=colsObj.cols;var clonedEdge=this.edges.slice(0);for(var i=0;i<clonedEdge.length;i++)
{this.DeleteEdge(clonedEdge[i]);}
var newVertices=[];var bWeightGraph=false;for(var i=0;i<cols[0].length;i++)
var newVertices=[];var bWeightGraph=false;var columnCount=cols.length>0?cols[0].length:0;for(var i=0;i<columnCount;i++)
{var edgeValue=[];var edgeIndex=[];for(var j=0;j<cols.length;j++)
{if(j>=this.vertices.length)
{var newPos=new Point(0,0);newVertices.push(new BaseVertex(newPos.x,newPos.y,currentEnumVerticesType));this.AddNewVertex(newVertices[newVertices.length-1]);}
@@ -479,10 +479,10 @@ var nEdgeIndex=this.AddNewEdgeSafe(this.vertices[edgeIndex[0]],this.vertices[edg
{bWeightGraph=bWeightGraph||this.edges[nEdgeIndex].weight!=1;}}}
if(!bWeightGraph)
{this.edges.forEach(function(part,index,theArray){theArray[index].useWeight=false;});}
for(var i=cols.length;i<Math.max(this.vertices.length,cols.length);i++)
var rowCount=rows.length>0?rows.length:this.vertices.length;for(var i=rowCount;i<this.vertices.length;i++)
{this.DeleteVertex(this.vertices[i]);i--;}
this.VerticesReposition(viewportSize,newVertices);}}
Graph.prototype.GetIncidenceMatrix=function()
Graph.prototype.GetIncidenceMatrix=function(res_columns_width)
{var matrix="";let cols_width=[];let get_edge_weight_str=(vertex_index,edge_index)=>{if(this.edges[edge_index].vertex1==this.vertices[vertex_index])
{return this.edges[edge_index].weight.toString();}
else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect)
@@ -491,7 +491,7 @@ else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&this.edges[
{return-this.edges[edge_index].weight.toString();}
else
{return"0";}};for(var j=0;j<this.edges.length;j++)
{let max_width=0;for(var i=0;i<this.vertices.length;i++)
{let max_width=Math.min(this.edges[j].GetUpText().toString().length,2);for(var i=0;i<this.vertices.length;i++)
{let str=""+get_edge_weight_str(i,j);max_width=Math.max(max_width,str.length);}
cols_width.push(max_width);}
for(var i=0;i<this.vertices.length;i++)
@@ -499,6 +499,7 @@ for(var i=0;i<this.vertices.length;i++)
{let weight_str=get_edge_weight_str(i,j);weight_str=" ".repeat(cols_width[j]-weight_str.length)+weight_str;matrix+=""+weight_str;if(j!=this.edges.length-1)
{matrix+=", ";}}
matrix=matrix+"\n";}
if(res_columns_width!==undefined){res_columns_width.length=0;res_columns_width.push(...cols_width);}
return matrix;}
Graph.prototype.SplitMatrixString=function(line,separator)
{if(separator===undefined)
@@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=109","/script/shared/point.js?v=109","/script/entities/edge/api/index.js?v=109","/script/entities/edge/model/BaseEdge.js?v=109","/script/entities/edge/model/EdgeModel.js?v=109","/script/entities/vertex/api/index.js?v=109","/script/entities/vertex/model/BaseVertex.js?v=109","/script/entities/vertex/model/VertexModel.js?v=109","/script/entities/graph/model/Graph.js?v=109","/script/pages/create_graph_by_matrix/model/createByMatrixMain.js?v=109","/script/pages/create_graph_by_matrix/model/main.js?v=109",]);{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=110","/script/shared/point.js?v=110","/script/entities/edge/api/index.js?v=110","/script/entities/edge/model/BaseEdge.js?v=110","/script/entities/edge/model/EdgeModel.js?v=110","/script/entities/vertex/api/index.js?v=110","/script/entities/vertex/model/BaseVertex.js?v=110","/script/entities/vertex/model/VertexModel.js?v=110","/script/entities/graph/model/Graph.js?v=110","/script/pages/create_graph_by_matrix/model/createByMatrixMain.js?v=110","/script/pages/create_graph_by_matrix/model/main.js?v=110",]);{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()
@@ -452,7 +452,7 @@ if(i==0)
if(colsObj.cols[i].length!=columnCount)
{bGoodFormat=false;break;}}
if(bGoodFormat)
{for(var i=0;i<colsObj.cols[0].length;i++)
{for(var i=0;i<columnCount;i++)
{var values=[];for(j=0;j<colsObj.cols.length;++j)
{if(colsObj.cols[j][i]!=0)
{values.push(colsObj.cols[j][i]);}}
@@ -463,7 +463,7 @@ Graph.prototype.SetIncidenceMatrix=function(matrix,viewportSize,currentEnumVerti
{var rowsObj={};var colsObj={};if(this.TestIncidenceMatrix(matrix,rowsObj,colsObj))
{rows=rowsObj.rows;cols=colsObj.cols;var clonedEdge=this.edges.slice(0);for(var i=0;i<clonedEdge.length;i++)
{this.DeleteEdge(clonedEdge[i]);}
var newVertices=[];var bWeightGraph=false;for(var i=0;i<cols[0].length;i++)
var newVertices=[];var bWeightGraph=false;var columnCount=cols.length>0?cols[0].length:0;for(var i=0;i<columnCount;i++)
{var edgeValue=[];var edgeIndex=[];for(var j=0;j<cols.length;j++)
{if(j>=this.vertices.length)
{var newPos=new Point(0,0);newVertices.push(new BaseVertex(newPos.x,newPos.y,currentEnumVerticesType));this.AddNewVertex(newVertices[newVertices.length-1]);}
@@ -479,10 +479,10 @@ var nEdgeIndex=this.AddNewEdgeSafe(this.vertices[edgeIndex[0]],this.vertices[edg
{bWeightGraph=bWeightGraph||this.edges[nEdgeIndex].weight!=1;}}}
if(!bWeightGraph)
{this.edges.forEach(function(part,index,theArray){theArray[index].useWeight=false;});}
for(var i=cols.length;i<Math.max(this.vertices.length,cols.length);i++)
var rowCount=rows.length>0?rows.length:this.vertices.length;for(var i=rowCount;i<this.vertices.length;i++)
{this.DeleteVertex(this.vertices[i]);i--;}
this.VerticesReposition(viewportSize,newVertices);}}
Graph.prototype.GetIncidenceMatrix=function()
Graph.prototype.GetIncidenceMatrix=function(res_columns_width)
{var matrix="";let cols_width=[];let get_edge_weight_str=(vertex_index,edge_index)=>{if(this.edges[edge_index].vertex1==this.vertices[vertex_index])
{return this.edges[edge_index].weight.toString();}
else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect)
@@ -491,7 +491,7 @@ else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&this.edges[
{return-this.edges[edge_index].weight.toString();}
else
{return"0";}};for(var j=0;j<this.edges.length;j++)
{let max_width=0;for(var i=0;i<this.vertices.length;i++)
{let max_width=Math.min(this.edges[j].GetUpText().toString().length,2);for(var i=0;i<this.vertices.length;i++)
{let str=""+get_edge_weight_str(i,j);max_width=Math.max(max_width,str.length);}
cols_width.push(max_width);}
for(var i=0;i<this.vertices.length;i++)
@@ -499,6 +499,7 @@ for(var i=0;i<this.vertices.length;i++)
{let weight_str=get_edge_weight_str(i,j);weight_str=" ".repeat(cols_width[j]-weight_str.length)+weight_str;matrix+=""+weight_str;if(j!=this.edges.length-1)
{matrix+=", ";}}
matrix=matrix+"\n";}
if(res_columns_width!==undefined){res_columns_width.length=0;res_columns_width.push(...cols_width);}
return matrix;}
Graph.prototype.SplitMatrixString=function(line,separator)
{if(separator===undefined)
+16 -10
View File
@@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/shared/utils.js?v=109","/script/shared/gzip.js?v=109","/script/entities/graph/api/index.js?v=109","/script/shared/point.js?v=109","/script/entities/edge/api/index.js?v=109","/script/entities/edge/model/BaseEdge.js?v=109","/script/entities/edge/model/EdgeModel.js?v=109","/script/entities/vertex/api/index.js?v=109","/script/entities/vertex/model/BaseVertex.js?v=109","/script/entities/vertex/model/VertexModel.js?v=109","/script/entities/graph/model/Graph.js?v=109","/script/features/draw_graph/api/index.js?v=109","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=109","/script/features/draw_graph/model/BackgroundStyle.js?v=109","/script/features/draw_graph/model/EdgeStyle.js?v=109","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=109","/script/features/draw_graph/model/VertexShape.js?v=109","/script/features/draw_graph/model/VertexStyle.js?v=109","/script/features/draw_graph/model/VertexOldStyle.js?v=109","/script/features/draw_graph/model/VertexPrintStyle.js?v=109","/script/features/draw_graph/model/OldEdgeStyle.js?v=109","/script/features/draw_graph/model/PrintEdgeStyle.js?v=109","/script/features/draw_graph/model/VertexNewWhiteStyle.js?v=109","/script/features/draw_graph/model/EdgeNewWhiteStyle.js?v=109","/script/features/draw_graph/model/EdgeNewNightStyle.js?v=109","/script/features/draw_graph/model/VertexNewNightStyle.js?v=109","/script/features/draw_graph/model/EdgeContrastStyle.js?v=109","/script/features/draw_graph/model/VertexContrastStyle.js?v=109","/script/features/draw_graph/model/BaseVertexDrawer.js?v=109","/script/features/draw_graph/model/GraphFullStyle.js?v=109","/script/features/algorithms/api/index.js?v=109","/script/features/algorithms/model/Algorithms.js?v=109","/script/features/algorithms/model/BaseTraversal.js?v=109","/script/features/base_handler/index.js?v=109","/script/features/default_handler/index.js?v=109","/script/features/add_vertices_handler/index.js?v=109","/script/features/connect_vertices_handler/index.js?v=109","/script/features/delete_objects_handler/index.js?v=109","/script/features/algorithm_handler/index.js?v=109","/script/features/select_auto_save_graph_or_not/index.js?v=109","/script/features/graph_preview/index.js?v=109","/script/features/serialization/api/index.js?v=109","/script/features/serialization/model/GraphMLCreator.js?v=109","/script/features/enum_vertices/EnumVertices.js?v=109","/script/pages/editor/model/texts.js?v=109","/script/pages/editor/model/UndoStack.js?v=109","/script/pages/editor/model/DiskSaveLoad.js?v=109","/script/pages/editor/model/Application.js?v=109","/script/pages/editor/ui/ya_metrika.js?v=109","/script/pages/editor/ui/editor.js?v=109","/script/pages/editor/ui/main.js?v=109",]);{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=110","/script/shared/gzip.js?v=110","/script/entities/graph/api/index.js?v=110","/script/shared/point.js?v=110","/script/entities/edge/api/index.js?v=110","/script/entities/edge/model/BaseEdge.js?v=110","/script/entities/edge/model/EdgeModel.js?v=110","/script/entities/vertex/api/index.js?v=110","/script/entities/vertex/model/BaseVertex.js?v=110","/script/entities/vertex/model/VertexModel.js?v=110","/script/entities/graph/model/Graph.js?v=110","/script/features/draw_graph/api/index.js?v=110","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=110","/script/features/draw_graph/model/BackgroundStyle.js?v=110","/script/features/draw_graph/model/EdgeStyle.js?v=110","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=110","/script/features/draw_graph/model/VertexShape.js?v=110","/script/features/draw_graph/model/VertexStyle.js?v=110","/script/features/draw_graph/model/VertexOldStyle.js?v=110","/script/features/draw_graph/model/VertexPrintStyle.js?v=110","/script/features/draw_graph/model/OldEdgeStyle.js?v=110","/script/features/draw_graph/model/PrintEdgeStyle.js?v=110","/script/features/draw_graph/model/VertexNewWhiteStyle.js?v=110","/script/features/draw_graph/model/EdgeNewWhiteStyle.js?v=110","/script/features/draw_graph/model/EdgeNewNightStyle.js?v=110","/script/features/draw_graph/model/VertexNewNightStyle.js?v=110","/script/features/draw_graph/model/EdgeContrastStyle.js?v=110","/script/features/draw_graph/model/VertexContrastStyle.js?v=110","/script/features/draw_graph/model/BaseVertexDrawer.js?v=110","/script/features/draw_graph/model/GraphFullStyle.js?v=110","/script/features/algorithms/api/index.js?v=110","/script/features/algorithms/model/Algorithms.js?v=110","/script/features/algorithms/model/BaseTraversal.js?v=110","/script/features/base_handler/index.js?v=110","/script/features/default_handler/index.js?v=110","/script/features/add_vertices_handler/index.js?v=110","/script/features/connect_vertices_handler/index.js?v=110","/script/features/delete_objects_handler/index.js?v=110","/script/features/algorithm_handler/index.js?v=110","/script/features/select_auto_save_graph_or_not/index.js?v=110","/script/features/graph_preview/index.js?v=110","/script/features/serialization/api/index.js?v=110","/script/features/serialization/model/GraphMLCreator.js?v=110","/script/features/enum_vertices/EnumVertices.js?v=110","/script/pages/editor/model/texts.js?v=110","/script/pages/editor/model/UndoStack.js?v=110","/script/pages/editor/model/DiskSaveLoad.js?v=110","/script/pages/editor/model/Application.js?v=110","/script/pages/editor/ui/ya_metrika.js?v=110","/script/pages/editor/ui/editor.js?v=110","/script/pages/editor/ui/main.js?v=110",]);{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')
@@ -487,7 +487,7 @@ if(i==0)
if(colsObj.cols[i].length!=columnCount)
{bGoodFormat=false;break;}}
if(bGoodFormat)
{for(var i=0;i<colsObj.cols[0].length;i++)
{for(var i=0;i<columnCount;i++)
{var values=[];for(j=0;j<colsObj.cols.length;++j)
{if(colsObj.cols[j][i]!=0)
{values.push(colsObj.cols[j][i]);}}
@@ -498,7 +498,7 @@ Graph.prototype.SetIncidenceMatrix=function(matrix,viewportSize,currentEnumVerti
{var rowsObj={};var colsObj={};if(this.TestIncidenceMatrix(matrix,rowsObj,colsObj))
{rows=rowsObj.rows;cols=colsObj.cols;var clonedEdge=this.edges.slice(0);for(var i=0;i<clonedEdge.length;i++)
{this.DeleteEdge(clonedEdge[i]);}
var newVertices=[];var bWeightGraph=false;for(var i=0;i<cols[0].length;i++)
var newVertices=[];var bWeightGraph=false;var columnCount=cols.length>0?cols[0].length:0;for(var i=0;i<columnCount;i++)
{var edgeValue=[];var edgeIndex=[];for(var j=0;j<cols.length;j++)
{if(j>=this.vertices.length)
{var newPos=new Point(0,0);newVertices.push(new BaseVertex(newPos.x,newPos.y,currentEnumVerticesType));this.AddNewVertex(newVertices[newVertices.length-1]);}
@@ -514,10 +514,10 @@ var nEdgeIndex=this.AddNewEdgeSafe(this.vertices[edgeIndex[0]],this.vertices[edg
{bWeightGraph=bWeightGraph||this.edges[nEdgeIndex].weight!=1;}}}
if(!bWeightGraph)
{this.edges.forEach(function(part,index,theArray){theArray[index].useWeight=false;});}
for(var i=cols.length;i<Math.max(this.vertices.length,cols.length);i++)
var rowCount=rows.length>0?rows.length:this.vertices.length;for(var i=rowCount;i<this.vertices.length;i++)
{this.DeleteVertex(this.vertices[i]);i--;}
this.VerticesReposition(viewportSize,newVertices);}}
Graph.prototype.GetIncidenceMatrix=function()
Graph.prototype.GetIncidenceMatrix=function(res_columns_width)
{var matrix="";let cols_width=[];let get_edge_weight_str=(vertex_index,edge_index)=>{if(this.edges[edge_index].vertex1==this.vertices[vertex_index])
{return this.edges[edge_index].weight.toString();}
else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect)
@@ -526,7 +526,7 @@ else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&this.edges[
{return-this.edges[edge_index].weight.toString();}
else
{return"0";}};for(var j=0;j<this.edges.length;j++)
{let max_width=0;for(var i=0;i<this.vertices.length;i++)
{let max_width=Math.min(this.edges[j].GetUpText().toString().length,2);for(var i=0;i<this.vertices.length;i++)
{let str=""+get_edge_weight_str(i,j);max_width=Math.max(max_width,str.length);}
cols_width.push(max_width);}
for(var i=0;i<this.vertices.length;i++)
@@ -534,6 +534,7 @@ for(var i=0;i<this.vertices.length;i++)
{let weight_str=get_edge_weight_str(i,j);weight_str=" ".repeat(cols_width[j]-weight_str.length)+weight_str;matrix+=""+weight_str;if(j!=this.edges.length-1)
{matrix+=", ";}}
matrix=matrix+"\n";}
if(res_columns_width!==undefined){res_columns_width.length=0;res_columns_width.push(...cols_width);}
return matrix;}
Graph.prototype.SplitMatrixString=function(line,separator)
{if(separator===undefined)
@@ -1638,7 +1639,7 @@ DiskSaveLoad.LoadAutoSaveGraphFromDisk=function(graphName,callback)
DiskSaveLoad.RemoveAutoSaveGraphFromDisk=function(graphName,callback)
{$.ajax({type:"GET",url:"/"+SiteDir+"backend/removeGraph.php?name=autosave_"+graphName}).done(callback);}
var globalApplication=null;function Application(document,window,listener)
{this.document=document;this.listener=listener;this.initCanvas();this.handler=new DefaultHandler(this);this.savedGraphName="";this.currentEnumVerticesType=new BaseEnumVertices(this,1);this.findPathReport=1;this.isTimerRender=false;globalApplication=this;this.renderPath=[];this.renderTimer=0;this.renderPathLength=0;this.renderPathCounter=0;this.renderPathLoops=0;this.enumVerticesTextList=[new BaseEnumVertices(this,1),new BaseEnumVertices(this,0),new TextEnumVertices(this),new TextEnumVerticesCyr(this),new TextEnumVerticesGreek(this),new TextEnumVerticesCustom(this)];this.algorithmsValues={};this.undoStack=new UndoStack(this.maxUndoStackSize);this.style=new GraphFullStyle(function()
{this.document=document;this.listener=listener;this.initCanvas();this.handler=new DefaultHandler(this);this.savedGraphName="";this.currentEnumVerticesType=new BaseEnumVertices(this,1);this.currentEnumEdgesType="";this.findPathReport=1;this.isTimerRender=false;globalApplication=this;this.renderPath=[];this.renderTimer=0;this.renderPathLength=0;this.renderPathCounter=0;this.renderPathLoops=0;this.enumVerticesTextList=[new BaseEnumVertices(this,1),new BaseEnumVertices(this,0),new TextEnumVertices(this),new TextEnumVerticesCyr(this),new TextEnumVerticesGreek(this),new TextEnumVerticesCustom(this)];this.algorithmsValues={};this.undoStack=new UndoStack(this.maxUndoStackSize);this.style=new GraphFullStyle(function()
{this.redrawGraph();}.bind(this));this.edgePrintCommonStyle=DefaultCommonPrintEdgeStyle();this.edgePrintSelectedStyles=FullArrayCopy(DefaultPrintSelectedEdgeStyles);this.vertexPrintCommonStyle=DefaultCommonPrintVertexStyle();this.vertexPrintSelectedVertexStyles=FullArrayCopy(DefaultPrintSelectedGraphStyles);this.backgroundPrintStyle=DefaultPrintBackgroundStyle();this.renderPathWithEdges=false;this.edgePresets=[1,3,5,7,11,42];this.maxEdgePresets=6;this.selectionRect=null;this.processEmscriptenFunction=null;this.defaultEdge=null;this.useDefaultEdge=false;this.lastSavedAutoSave="";this.lastGraphName="";this.lastUsedGraphs=[];};Application.prototype.graph=new Graph();Application.prototype.dragObject=-1;Application.prototype.handler=null;Application.prototype.status={};Application.prototype.graphNameLength=16;Application.prototype.maxUndoStackSize=8;Application.prototype.maxAutosaveSizeForCookie=2000;Application.prototype.autosaveTimeInterval=1000*60;Application.prototype.styliedGraphNamePostfix="ZZcst";Application.prototype.maxLastUsedGraphCount=5;Application.prototype.initCanvas=function()
{this.canvas=this.document.getElementById('canvas');console.log(this.canvas.width,this.canvas.height);console.log(this.canvas.getBoundingClientRect());console.log(window.devicePixelRatio);this.SetDefaultTransformations();}
Application.prototype.getMousePos=function(canvas,e)
@@ -1807,7 +1808,7 @@ Application.prototype.ToDefaultStateAndRedraw=function()
Application.prototype.getParameterByName=function(name)
{name=name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var regex=new RegExp("[\\?&]"+name+"=([^&#]*)"),results=regex.exec(location.search);return results===null?"":decodeURIComponent(results[1].replace(/\+/g," "));}
Application.prototype.onPostLoadEvent=function()
{this.SetEnumVerticesType(document.cookie.replace(/(?:(?:^|.*;\s*)enumType\s*\=\s*([^;]*).*$)|^.*$/,"$1"));var wasLoad=false;let startAutoSave=true;var matrix=document.getElementById("inputMatrix").innerHTML;var separator=document.getElementById("separator").innerHTML=="space"?" ":",";console.log(matrix);console.log("separator: \""+separator+"\"");matrix=(matrix.length<=0)?this.getParameterByName("matrix"):matrix;if(matrix.length>0)
{this.SetEnumVerticesType(document.cookie.replace(/(?:(?:^|.*;\s*)enumType\s*\=\s*([^;]*).*$)|^.*$/,"$1"));var edgeEnumCookie=/(?:^|;\s*)edgeEnumType\s*=\s*([^;]*)/.exec(document.cookie);this.SetEnumEdgesType(edgeEnumCookie?edgeEnumCookie[1]:"");var wasLoad=false;let startAutoSave=true;var matrix=document.getElementById("inputMatrix").innerHTML;var separator=document.getElementById("separator").innerHTML=="space"?" ":",";console.log(matrix);console.log("separator: \""+separator+"\"");matrix=(matrix.length<=0)?this.getParameterByName("matrix"):matrix;if(matrix.length>0)
{if(!this.SetAdjacencyMatrixSmart(matrix,separator))
{userAction("AdjacencyMatrix.Failed");this.listener.ShowAdjacencyMatrixErrorDialog(matrix);}
else
@@ -1863,8 +1864,8 @@ Application.prototype.SetPair=function(pair)
{var res=true;var r={};var c={};if(!this.TestPair(pair))
{$.get("/"+SiteDir+"backend/addFailedMatrix.php?text=pair&matrix="+encodeURIComponent(pair),function(data){;});res=false;}
this.graph.SetPair(pair,new Point(this.GetRealWidth(),this.GetRealHeight()),this.currentEnumVerticesType);this.AutoAdjustViewport();this.redrawGraph();return res;}
Application.prototype.GetIncidenceMatrix=function()
{return this.graph.GetIncidenceMatrix();}
Application.prototype.GetIncidenceMatrix=function(res_columns_width)
{return this.graph.GetIncidenceMatrix(res_columns_width);}
Application.prototype.TestIncidenceMatrix=function(matrix,rowsObj,colsObj)
{return this.graph.TestIncidenceMatrix(matrix,rowsObj,colsObj);}
Application.prototype.TestPair=function(pair)
@@ -1944,6 +1945,11 @@ Application.prototype.SetEnumVerticesType=function(value)
{for(var i=0;i<this.enumVerticesTextList.length;i++)
{if(this.enumVerticesTextList[i].GetValue()==value)
{this.currentEnumVerticesType=this.enumVerticesTextList[i];document.cookie="enumType="+value;break;}}}
Application.prototype.SetEnumEdgesType=function(value)
{if(value==="Custom")
{value="";}
var isValidValue=value===""||this.enumVerticesTextList.some(function(enumType){return enumType.GetValue()===value&&value!=="Custom";});if(isValidValue)
{this.currentEnumEdgesType=value;document.cookie="edgeEnumType="+value;}}
Application.prototype.SetFindPathReport=function(value)
{this.findPathReport=value;}
Application.prototype.GetFindPathReport=function()
+22 -2
View File
@@ -14,6 +14,7 @@ function Application(document, window, listener)
this.handler = new DefaultHandler(this);
this.savedGraphName = "";
this.currentEnumVerticesType = new BaseEnumVertices(this, 1);//this.enumVerticesTextList[0];
this.currentEnumEdgesType = "";
this.findPathReport = 1;
this.isTimerRender = false;
globalApplication = this;
@@ -728,6 +729,8 @@ Application.prototype.getParameterByName = function (name)
Application.prototype.onPostLoadEvent = function()
{
this.SetEnumVerticesType(document.cookie.replace(/(?:(?:^|.*;\s*)enumType\s*\=\s*([^;]*).*$)|^.*$/, "$1"));
var edgeEnumCookie = /(?:^|;\s*)edgeEnumType\s*=\s*([^;]*)/.exec(document.cookie);
this.SetEnumEdgesType(edgeEnumCookie ? edgeEnumCookie[1] : "");
var wasLoad = false;
let startAutoSave = true;
@@ -927,9 +930,9 @@ Application.prototype.SetPair = function (pair)
return res;
}
Application.prototype.GetIncidenceMatrix = function ()
Application.prototype.GetIncidenceMatrix = function (res_columns_width)
{
return this.graph.GetIncidenceMatrix();
return this.graph.GetIncidenceMatrix(res_columns_width);
}
Application.prototype.TestIncidenceMatrix = function (matrix, rowsObj, colsObj)
@@ -1218,6 +1221,23 @@ Application.prototype.SetEnumVerticesType = function(value)
}
}
Application.prototype.SetEnumEdgesType = function(value)
{
if (value === "Custom")
{
value = "";
}
var isValidValue = value === "" || this.enumVerticesTextList.some(function(enumType) {
return enumType.GetValue() === value && value !== "Custom";
});
if (isValidValue)
{
this.currentEnumEdgesType = value;
document.cookie = "edgeEnumType=" + value;
}
}
Application.prototype.SetFindPathReport = function (value)
{