diff --git a/Layout.js b/Layout.js index dfd1a52..a9b3526 100644 --- a/Layout.js +++ b/Layout.js @@ -13,6 +13,7 @@ class Layout { this.resolveAffinity(); this.resolveGroups(); while (this.iterate()); + this.addGroupPos(); this.drawLinks(); this.fixOrigin(); } @@ -194,6 +195,20 @@ class Layout { ]; } + addGroupPos() { + for (let group of this.groups_) { + if (!group.hasGraphGroup()) { + continue; + } + let [min, max] = group.getMinMax(); + for (let x = min[0]; x <= max[0]; ++x) { + for (let y = min[1]; y <= max[1]; ++y) { + getOrSet(this.nodesByPos_, [x, y], group); + } + } + } + } + drawLinks() { let links = []; for (let from of this.nodes_) { diff --git a/LayoutGroup.js b/LayoutGroup.js index b5fadca..8bd0b97 100644 --- a/LayoutGroup.js +++ b/LayoutGroup.js @@ -81,4 +81,8 @@ class LayoutGroup { label: this.graphGroup_.label, }; } + + hasGraphGroup() { + return this.graphGroup_ != null; + } }