Enhance matrix display functionality and formatting.

This commit is contained in:
Oleg Sh
2025-12-24 16:17:38 +01:00
parent 50d590fa98
commit ea61466fe0
14 changed files with 510 additions and 137 deletions

View File

@@ -46,8 +46,40 @@ ShowAdjacencyMatrix.prototype.show = function()
$( this ).dialog( "close" );
};
$( "#AdjacencyMatrixField" ).val(this.app.GetAdjacencyMatrix());
let ta = $("#AdjacencyMatrixField");
let topWrap = $("#adjacencyMatrix_top_text");
let sideWrap = $("#adjacencyMatrix_side_text");
ta.on("scroll", function() {
topWrap.scrollLeft(ta.scrollLeft());
sideWrap.scrollTop(ta.scrollTop());
});
let res_columns_width = [];
ta.val(this.app.GetAdjacencyMatrix(res_columns_width).trimEnd());
ta.focus()[0].setSelectionRange(0, 0);
$( "#BadMatrixFormatMessage" ).hide();
/* Make side and top text */
let sideText = "";
let topText = "";
for (let i = 0; i < this.app.graph.vertices.length; i++)
{
/* Each vertex name max 3 symbols */
sideText += this.app.graph.vertices[i].mainText.toString().slice(0, 3) + "\n";
let col_width = res_columns_width[i];
let col_text = this.app.graph.vertices[i].mainText.toString();
if (col_width < col_text.length)
{
col_text = col_text.slice(0, col_width);
}
col_text = col_text.padStart(col_width, " ");
topText += col_text + " ";
}
$("#adjacencyMatrix_top_text_text").html(topText);
$("#adjacencyMatrix_side_text_text").html(sideText + "\n");
if (this.app.graph.isMulti())
$( "#AdjacencyMatrixMultiGraphDesc").show();
@@ -61,6 +93,11 @@ ShowAdjacencyMatrix.prototype.show = function()
modal: true,
title: g_adjacencyMatrixText,
buttons: dialogButtons,
dialogClass: 'EdgeDialog'
dialogClass: 'EdgeDialog',
open: function(event, ui) {
/* Set width for side text */
$("#adjacencyMatrix_top_text").width(ta.width());
$("#BadMatrixFormatMessage").width(ta.width());
}
});
}