|
@ -275,7 +275,7 @@ class ClusterEngine { |
|
|
clonedOptions.from = fromId; |
|
|
clonedOptions.from = fromId; |
|
|
clonedOptions.to = toId; |
|
|
clonedOptions.to = toId; |
|
|
clonedOptions.id = 'clusterEdge:' + util.randomUUID(); |
|
|
clonedOptions.id = 'clusterEdge:' + util.randomUUID(); |
|
|
newEdges.push(this.body.functions.createEdge(clonedOptions)) |
|
|
|
|
|
|
|
|
newEdges.push(this.body.functions.createEdge(clonedOptions)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -321,8 +321,11 @@ class ClusterEngine { |
|
|
// get clusterproperties based on childNodes
|
|
|
// get clusterproperties based on childNodes
|
|
|
let childEdgesOptions = []; |
|
|
let childEdgesOptions = []; |
|
|
for (let edgeId in childEdgesObj) { |
|
|
for (let edgeId in childEdgesObj) { |
|
|
let clonedOptions = this._cloneOptions(childEdgesObj[edgeId], 'edge'); |
|
|
|
|
|
childEdgesOptions.push(clonedOptions); |
|
|
|
|
|
|
|
|
// these cluster edges will be removed on creation of the cluster.
|
|
|
|
|
|
if (edgeId.substr(0,12) !== "clusterEdge:") { |
|
|
|
|
|
let clonedOptions = this._cloneOptions(childEdgesObj[edgeId], 'edge'); |
|
|
|
|
|
childEdgesOptions.push(clonedOptions); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
clusterNodeProperties = options.processProperties(clusterNodeProperties, childNodesOptions, childEdgesOptions); |
|
|
clusterNodeProperties = options.processProperties(clusterNodeProperties, childNodesOptions, childEdgesOptions); |
|
@ -376,8 +379,18 @@ class ClusterEngine { |
|
|
if (childEdgesObj.hasOwnProperty(edgeId)) { |
|
|
if (childEdgesObj.hasOwnProperty(edgeId)) { |
|
|
if (this.body.edges[edgeId] !== undefined) { |
|
|
if (this.body.edges[edgeId] !== undefined) { |
|
|
let edge = this.body.edges[edgeId]; |
|
|
let edge = this.body.edges[edgeId]; |
|
|
edge.togglePhysics(false); |
|
|
|
|
|
edge.options.hidden = true; |
|
|
|
|
|
|
|
|
// if the edge is a clusterEdge, we delete it. The opening of the clusters will restore these edges when required.
|
|
|
|
|
|
if (edgeId.substr(0,12) === "clusterEdge:") { |
|
|
|
|
|
edge.edgeType.cleanup(); |
|
|
|
|
|
// this removes the edge from node.edges, which is why edgeIds is formed
|
|
|
|
|
|
edge.disconnect(); |
|
|
|
|
|
delete childEdgesObj[edgeId]; |
|
|
|
|
|
delete this.body.edges[edgeId]; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
edge.togglePhysics(false); |
|
|
|
|
|
edge.options.hidden = true; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -522,7 +535,7 @@ class ClusterEngine { |
|
|
if (containedEdges.hasOwnProperty(edgeId)) { |
|
|
if (containedEdges.hasOwnProperty(edgeId)) { |
|
|
let edge = containedEdges[edgeId]; |
|
|
let edge = containedEdges[edgeId]; |
|
|
// if this edge was a temporary edge and it's connected nodes do not exist anymore, we remove it from the data
|
|
|
// if this edge was a temporary edge and it's connected nodes do not exist anymore, we remove it from the data
|
|
|
if (this.body.nodes[edge.fromId] === undefined || this.body.nodes[edge.toId] === undefined) { |
|
|
|
|
|
|
|
|
if (this.body.nodes[edge.fromId] === undefined || this.body.nodes[edge.toId] === undefined || edge.toId == clusterNodeId || edge.fromId == clusterNodeId) { |
|
|
edge.edgeType.cleanup(); |
|
|
edge.edgeType.cleanup(); |
|
|
// this removes the edge from node.edges, which is why edgeIds is formed
|
|
|
// this removes the edge from node.edges, which is why edgeIds is formed
|
|
|
edge.disconnect(); |
|
|
edge.disconnect(); |
|
@ -566,9 +579,16 @@ class ClusterEngine { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// remove all temporary edges
|
|
|
|
|
|
|
|
|
// remove all temporary edges, make an array of ids so we don't remove from the list we're iterating over.
|
|
|
|
|
|
let removeIds = []; |
|
|
for (let i = 0; i < clusterNode.edges.length; i++) { |
|
|
for (let i = 0; i < clusterNode.edges.length; i++) { |
|
|
let edgeId = clusterNode.edges[i].id; |
|
|
let edgeId = clusterNode.edges[i].id; |
|
|
|
|
|
removeIds.push(edgeId); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// actually removing the edges
|
|
|
|
|
|
for (let i = 0; i < removeIds.length; i++) { |
|
|
|
|
|
let edgeId = removeIds[i]; |
|
|
this.body.edges[edgeId].edgeType.cleanup(); |
|
|
this.body.edges[edgeId].edgeType.cleanup(); |
|
|
// this removes the edge from node.edges, which is why edgeIds is formed
|
|
|
// this removes the edge from node.edges, which is why edgeIds is formed
|
|
|
this.body.edges[edgeId].disconnect(); |
|
|
this.body.edges[edgeId].disconnect(); |
|
|