add a few small fixes and improvements

This commit is contained in:
Dylan Vorster
2021-03-20 22:20:24 +02:00
parent 53eee3f518
commit 8173b70834
8 changed files with 125 additions and 51 deletions

View File

@ -22,15 +22,14 @@ export class DagreEngine {
redistribute(model: DiagramModel) {
// Create a new directed graph
var g = new dagre.graphlib.Graph({
multigraph: true
multigraph: true,
compound: true
});
g.setGraph(this.options.graph || {});
g.setDefaultEdgeLabel(function () {
return {};
});
const processedlinks: { [id: string]: boolean } = {};
// set nodes
_.forEach(model.getNodes(), (node) => {
g.setNode(node.getID(), { width: node.width, height: node.height });
@ -39,7 +38,6 @@ export class DagreEngine {
_.forEach(model.getLinks(), (link) => {
// set edges
if (link.getSourcePort() && link.getTargetPort()) {
processedlinks[link.getID()] = true;
g.setEdge({
v: link.getSourcePort().getNode().getID(),
w: link.getTargetPort().getNode().getID(),
@ -63,7 +61,7 @@ export class DagreEngine {
const link = model.getLink(e.name);
const points = [link.getFirstPoint()];
for (let i = 1; i < edge.points.length - 2; i++) {
for (let i = 1; i < edge.points.length - 1; i++) {
points.push(new PointModel({ link: link, position: new Point(edge.points[i].x, edge.points[i].y) }));
}
link.setPoints(points.concat(link.getLastPoint()));