Fix bug in LayoutGroup.restorePos() and reduce group count

This commit is contained in:
Ian Gulliver
2019-07-16 18:31:28 +00:00
parent 0ddefeeaef
commit c9cc43126d
2 changed files with 13 additions and 0 deletions

View File

@@ -56,15 +56,24 @@ class Layout {
resolveGroups() {
this.groups_ = [];
for (let group of this.graph_.groups) {
if (group.length < 2) {
continue;
}
let nodes = this.nodesFromGraphNodes(group.nodes);
this.groups_.push(new LayoutGroup(group, this.nodesByPos_, nodes, 'group'));
}
for (let subgraph of this.graph_.nodesBySubgraph.values()) {
if (subgraph.length < 2) {
continue;
}
let nodes = this.nodesFromGraphNodes(subgraph);
this.groups_.push(new LayoutGroup(null, this.nodesByPos_, nodes,
'subgraph'));
}
for (let labelGroup of this.graph_.nodesByLabel.values()) {
if (labelGroup.length < 2) {
continue;
}
let nodes = this.nodesFromGraphNodes(labelGroup);
this.groups_.push(new LayoutGroup(null, this.nodesByPos_, nodes,
'labelgroup'));

View File

@@ -40,6 +40,10 @@ class LayoutGroup {
restorePos() {
this.vec = this.savedVec_;
// Fix up nodesByPos, as intra-group collisions may have corrupted it
for (let node of this.nodes) {
this.nodesByPos_.set(node.pos, node);
}
}
moveBy(offset) {