|
@ -148,7 +148,7 @@ class LayoutEngine { |
|
|
// force all edges into static smooth curves. Only applies to edges that do not use the global options for smooth.
|
|
|
// force all edges into static smooth curves. Only applies to edges that do not use the global options for smooth.
|
|
|
this.body.emitter.emit('_forceDisableDynamicCurves', type); |
|
|
this.body.emitter.emit('_forceDisableDynamicCurves', type); |
|
|
} |
|
|
} |
|
|
console.log(JSON.stringify(allOptions), JSON.stringify(this.optionsBackup)); |
|
|
|
|
|
|
|
|
|
|
|
return allOptions; |
|
|
return allOptions; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -339,6 +339,15 @@ class LayoutEngine { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// fallback for cases where there are nodes but no edges
|
|
|
|
|
|
for (let nodeId in this.body.nodes) { |
|
|
|
|
|
if (this.body.nodes.hasOwnProperty(nodeId)) { |
|
|
|
|
|
if (this.hierarchicalLevels[nodeId] === undefined) { |
|
|
|
|
|
this.hierarchicalLevels[nodeId] = 0; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
// check the distribution of the nodes per level.
|
|
|
// check the distribution of the nodes per level.
|
|
|
let distribution = this._getDistribution(); |
|
|
let distribution = this._getDistribution(); |
|
|
|
|
|
|
|
@ -400,7 +409,7 @@ class LayoutEngine { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return [min, max]; |
|
|
|
|
|
|
|
|
return {min:min, max:max}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// get the width of all trees
|
|
|
// get the width of all trees
|
|
@ -751,27 +760,32 @@ class LayoutEngine { |
|
|
useMap = false; |
|
|
useMap = false; |
|
|
} |
|
|
} |
|
|
let level = this.hierarchicalLevels[node.id]; |
|
|
let level = this.hierarchicalLevels[node.id]; |
|
|
let index = this.distributionIndex[node.id]; |
|
|
|
|
|
let position = this._getPositionForHierarchy(node); |
|
|
|
|
|
let minSpace = 1e9; |
|
|
|
|
|
let maxSpace = 1e9; |
|
|
|
|
|
if (index !== 0) { |
|
|
|
|
|
let prevNode = this.distributionOrdering[level][index - 1]; |
|
|
|
|
|
if ((useMap === true && map[prevNode.id] === undefined) || useMap === false) { |
|
|
|
|
|
let prevPos = this._getPositionForHierarchy(prevNode); |
|
|
|
|
|
minSpace = position - prevPos; |
|
|
|
|
|
|
|
|
if (level !== undefined) { |
|
|
|
|
|
let index = this.distributionIndex[node.id]; |
|
|
|
|
|
let position = this._getPositionForHierarchy(node); |
|
|
|
|
|
let minSpace = 1e9; |
|
|
|
|
|
let maxSpace = 1e9; |
|
|
|
|
|
if (index !== 0) { |
|
|
|
|
|
let prevNode = this.distributionOrdering[level][index - 1]; |
|
|
|
|
|
if ((useMap === true && map[prevNode.id] === undefined) || useMap === false) { |
|
|
|
|
|
let prevPos = this._getPositionForHierarchy(prevNode); |
|
|
|
|
|
minSpace = position - prevPos; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (index != this.distributionOrdering[level].length - 1) { |
|
|
|
|
|
let nextNode = this.distributionOrdering[level][index + 1]; |
|
|
|
|
|
if ((useMap === true && map[nextNode.id] === undefined) || useMap === false) { |
|
|
|
|
|
let nextPos = this._getPositionForHierarchy(nextNode); |
|
|
|
|
|
maxSpace = Math.min(maxSpace, nextPos - position); |
|
|
|
|
|
|
|
|
if (index != this.distributionOrdering[level].length - 1) { |
|
|
|
|
|
let nextNode = this.distributionOrdering[level][index + 1]; |
|
|
|
|
|
if ((useMap === true && map[nextNode.id] === undefined) || useMap === false) { |
|
|
|
|
|
let nextPos = this._getPositionForHierarchy(nextNode); |
|
|
|
|
|
maxSpace = Math.min(maxSpace, nextPos - position); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return [minSpace, maxSpace]; |
|
|
|
|
|
|
|
|
return [minSpace, maxSpace]; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
return [0, 0]; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -1007,14 +1021,18 @@ class LayoutEngine { |
|
|
// get the minimum level
|
|
|
// get the minimum level
|
|
|
for (let nodeId in this.body.nodes) { |
|
|
for (let nodeId in this.body.nodes) { |
|
|
if (this.body.nodes.hasOwnProperty(nodeId)) { |
|
|
if (this.body.nodes.hasOwnProperty(nodeId)) { |
|
|
minLevel = Math.min(this.hierarchicalLevels[nodeId], minLevel); |
|
|
|
|
|
|
|
|
if (this.hierarchicalLevels[nodeId] !== undefined) { |
|
|
|
|
|
minLevel = Math.min(this.hierarchicalLevels[nodeId], minLevel); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// subtract the minimum from the set so we have a range starting from 0
|
|
|
// subtract the minimum from the set so we have a range starting from 0
|
|
|
for (let nodeId in this.body.nodes) { |
|
|
for (let nodeId in this.body.nodes) { |
|
|
if (this.body.nodes.hasOwnProperty(nodeId)) { |
|
|
if (this.body.nodes.hasOwnProperty(nodeId)) { |
|
|
this.hierarchicalLevels[nodeId] -= minLevel; |
|
|
|
|
|
|
|
|
if (this.hierarchicalLevels[nodeId] !== undefined) { |
|
|
|
|
|
this.hierarchicalLevels[nodeId] -= minLevel; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -1057,12 +1075,18 @@ class LayoutEngine { |
|
|
progress[node.id] = true; |
|
|
progress[node.id] = true; |
|
|
let childNode; |
|
|
let childNode; |
|
|
for (let i = 0; i < node.edges.length; i++) { |
|
|
for (let i = 0; i < node.edges.length; i++) { |
|
|
if (node.edges[i].toId === node.id) {childNode = node.edges[i].from;} |
|
|
|
|
|
else {childNode = node.edges[i].to;} |
|
|
|
|
|
|
|
|
if (node.edges[i].connected === true) { |
|
|
|
|
|
if (node.edges[i].toId === node.id) { |
|
|
|
|
|
childNode = node.edges[i].from; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
childNode = node.edges[i].to; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (node.id !== childNode.id) { |
|
|
|
|
|
callback(node, childNode, node.edges[i]); |
|
|
|
|
|
crawler(childNode); |
|
|
|
|
|
|
|
|
if (node.id !== childNode.id) { |
|
|
|
|
|
callback(node, childNode, node.edges[i]); |
|
|
|
|
|
crawler(childNode); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -1259,6 +1283,7 @@ class LayoutEngine { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (this.options.hierarchical.direction === 'UD' || this.options.hierarchical.direction === 'DU') { |
|
|
if (this.options.hierarchical.direction === 'UD' || this.options.hierarchical.direction === 'DU') { |
|
|
node.x = position; |
|
|
node.x = position; |
|
|
} |
|
|
} |
|
|