Skip to content

Commit 3ce551d

Browse files
committed
Nodes in dot format have now rounded box shape and
1 parent d616d4f commit 3ce551d

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

src/model/Node.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ export class Node {
5757
const id = this.id.replace(regex, '_');
5858
const attributes: string[] = [];
5959
const label = this.config.maximumNodeLabelLength !== -1 && this.name.length > this.config.maximumNodeLabelLength ? this.name.substr(0, this.config.maximumNodeLabelLength) + '...' : this.name;
60-
attributes.push(`label="${label}"`);
60+
attributes.push(`label=<${label}>`);
61+
attributes.push('shape="box"');
62+
attributes.push(`style="filled,rounded"`);
6163
const color = this.getNodeTypeColor(this.nodeType);
6264
if (color) {
6365
attributes.push(`color="${color}"`);
64-
attributes.push(`style="filled"`);
6566
}
6667
if (this.position !== undefined) {
6768
const x = this.position.x;

templates/showHierarchy_Template.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@
261261
nodes.forEach(node => {
262262
nodeExport[node.id] = {
263263
id: node.id,
264-
label: cleanLabel(node.label),
264+
label: command==='saveAsDgml' ? cleanLabelDgml(node.label) : cleanLabelDot(node.label),
265265
position: network.getPosition(node.id),
266266
boundingBox: network.getBoundingBox(node.id)
267267
};
@@ -276,11 +276,27 @@
276276
});
277277
}
278278

279-
function cleanLabel(label) {
280-
let regex = /(<([^>]+)>)/ig;
281-
let cleanedLabel = label.replace(regex, '');
282-
regex = /\s+/g;
283-
cleanedLabel = cleanedLabel.replace(regex, ' ');
279+
function cleanLabelDgml(label) {
280+
let cleanedLabel = removeHtmlTags(label);
281+
cleanedLabel = removeNewlines(cleanedLabel);
282+
return cleanedLabel;
283+
}
284+
285+
function cleanLabelDot(label) {
286+
let cleanedLabel = convertNewlinesToDotNewlines(label) + '<br align="left"/>';
287+
return cleanedLabel;
288+
}
289+
290+
function removeHtmlTags(label) {
291+
let cleanedLabel = label.replace(/(<([^>]+)>)/ig, '');
292+
return cleanedLabel;
293+
}
294+
function removeNewlines(label) {
295+
let cleanedLabel = label.replace(/\s+/g, '');
296+
return cleanedLabel;
297+
}
298+
function convertNewlinesToDotNewlines(label) {
299+
let cleanedLabel = label.replace(/\n/g, '<br align="left"/>');
284300
return cleanedLabel;
285301
}
286302

0 commit comments

Comments
 (0)