Skip to content

Commit 1f7e514

Browse files
committed
Various minor adjustments.
1 parent 3ba5b82 commit 1f7e514

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

templates/dgmlViewer_Template.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
mouseX = parseInt(event.clientX - selectionCanvas.offsetLeft);
106106
mouseY = parseInt(event.clientY - selectionCanvas.offsetTop);
107107
showGuideLines();
108-
if (selectionCanvasContext != undefined) {
108+
if (selectionCanvasContext !== undefined) {
109109
selectionCanvasContext.beginPath();
110110
selectionCanvasContext.setLineDash([]);
111111
const width = mouseX - lastMouseX;
@@ -180,7 +180,6 @@
180180
}
181181
}
182182

183-
184183
function storeCoordinates(cy) {
185184
cy.elements().forEach(ele => {
186185
if (ele.isNode()) {
@@ -206,7 +205,7 @@
206205
if (node.data.label && node.data.label.length > 0) {
207206
let labelText = node.data.label;
208207
let metrics = txtCtx.measureText(labelText);
209-
if (labelText.indexOf('\n') > -1){
208+
if (labelText.indexOf('\n') > -1){ // If the label text contains newlines, then we should find the longest line of them in order to find the width of the node.
210209
let longestStringLength = 0;
211210
const lines = node.data.label.split('\n');
212211
lines.forEach(s => {
@@ -218,7 +217,7 @@
218217
metrics = txtCtx.measureText(labelText);
219218
node.data.height = (metrics.fontBoundingBoxAscent + metrics.fontBoundingBoxDescent) * (lines.length + 2);
220219
}
221-
node.data.width = metrics.width * 1.75; // Don't know why, but the width of node has to be about 75% bigger than the width of the label text.
220+
node.data.width = metrics.width * 1.5; // Don't know why, but the width of node has to be about 50% bigger than the width of the label text.
222221
}
223222
});
224223
}

0 commit comments

Comments
 (0)