|
@ -1,12 +1,11 @@ |
|
|
var Node = require("./components/Node"); |
|
|
|
|
|
var util = require('../../util'); |
|
|
|
|
|
|
|
|
let Node = require("./components/Node"); |
|
|
|
|
|
let util = require('../../util'); |
|
|
|
|
|
|
|
|
class SelectionHandler { |
|
|
class SelectionHandler { |
|
|
constructor(body, canvas) { |
|
|
constructor(body, canvas) { |
|
|
this.body = body; |
|
|
this.body = body; |
|
|
this.canvas = canvas; |
|
|
this.canvas = canvas; |
|
|
this.selectionObj = {nodes: [], edges: []}; |
|
|
this.selectionObj = {nodes: [], edges: []}; |
|
|
this.forceSelectEdges = false; |
|
|
|
|
|
|
|
|
|
|
|
this.options = {}; |
|
|
this.options = {}; |
|
|
this.defaultOptions = { |
|
|
this.defaultOptions = { |
|
@ -35,10 +34,10 @@ class SelectionHandler { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
selectOnPoint(pointer) { |
|
|
selectOnPoint(pointer) { |
|
|
var selected = false; |
|
|
|
|
|
|
|
|
let selected = false; |
|
|
if (this.options.select === true) { |
|
|
if (this.options.select === true) { |
|
|
this.unselectAll(); |
|
|
this.unselectAll(); |
|
|
var obj = this.getNodeAt(pointer) || this.getEdgeAt(pointer);; |
|
|
|
|
|
|
|
|
let obj = this.getNodeAt(pointer) || this.getEdgeAt(pointer);; |
|
|
if (obj !== undefined) { |
|
|
if (obj !== undefined) { |
|
|
selected = this.selectObject(obj); |
|
|
selected = this.selectObject(obj); |
|
|
} |
|
|
} |
|
@ -48,9 +47,9 @@ class SelectionHandler { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
selectAdditionalOnPoint(pointer) { |
|
|
selectAdditionalOnPoint(pointer) { |
|
|
var selectionChanged = false; |
|
|
|
|
|
|
|
|
let selectionChanged = false; |
|
|
if (this.options.select === true) { |
|
|
if (this.options.select === true) { |
|
|
var obj = this.getNodeAt(pointer) || this.getEdgeAt(pointer);; |
|
|
|
|
|
|
|
|
let obj = this.getNodeAt(pointer) || this.getEdgeAt(pointer);; |
|
|
|
|
|
|
|
|
if (obj !== undefined) { |
|
|
if (obj !== undefined) { |
|
|
selectionChanged = true; |
|
|
selectionChanged = true; |
|
@ -67,19 +66,23 @@ class SelectionHandler { |
|
|
return selectionChanged; |
|
|
return selectionChanged; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
_generateClickEvent(eventType,pointer) { |
|
|
|
|
|
var properties = this.getSelection(); |
|
|
|
|
|
|
|
|
_generateClickEvent(eventType, pointer, oldSelection) { |
|
|
|
|
|
let properties = this.getSelection(); |
|
|
properties['pointer'] = { |
|
|
properties['pointer'] = { |
|
|
DOM: {x: pointer.x, y: pointer.y}, |
|
|
DOM: {x: pointer.x, y: pointer.y}, |
|
|
canvas: this.canvas.DOMtoCanvas(pointer) |
|
|
canvas: this.canvas.DOMtoCanvas(pointer) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (oldSelection !== undefined) { |
|
|
|
|
|
properties['previousSelection'] = oldSelection; |
|
|
|
|
|
} |
|
|
this.body.emitter.emit(eventType, properties); |
|
|
this.body.emitter.emit(eventType, properties); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
selectObject(obj) { |
|
|
|
|
|
|
|
|
selectObject(obj, highlightEdges = this.options.selectConnectedEdges) { |
|
|
if (obj !== undefined) { |
|
|
if (obj !== undefined) { |
|
|
if (obj instanceof Node) { |
|
|
if (obj instanceof Node) { |
|
|
if (this.options.selectConnectedEdges === true || this.forceSelectEdges === true) { |
|
|
|
|
|
|
|
|
if (highlightEdges === true) { |
|
|
this._selectConnectedEdges(obj); |
|
|
this._selectConnectedEdges(obj); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -106,8 +109,8 @@ class SelectionHandler { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
_getAllNodesOverlappingWith(object) { |
|
|
_getAllNodesOverlappingWith(object) { |
|
|
var overlappingNodes = []; |
|
|
|
|
|
var nodes = this.body.nodes; |
|
|
|
|
|
|
|
|
let overlappingNodes = []; |
|
|
|
|
|
let nodes = this.body.nodes; |
|
|
for (let i = 0; i < this.body.nodeIndices.length; i++) { |
|
|
for (let i = 0; i < this.body.nodeIndices.length; i++) { |
|
|
let nodeId = this.body.nodeIndices[i]; |
|
|
let nodeId = this.body.nodeIndices[i]; |
|
|
if (nodes[nodeId].isOverlappingWith(object)) { |
|
|
if (nodes[nodeId].isOverlappingWith(object)) { |
|
@ -126,7 +129,7 @@ class SelectionHandler { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
_pointerToPositionObject(pointer) { |
|
|
_pointerToPositionObject(pointer) { |
|
|
var canvasPos = this.canvas.DOMtoCanvas(pointer); |
|
|
|
|
|
|
|
|
let canvasPos = this.canvas.DOMtoCanvas(pointer); |
|
|
return { |
|
|
return { |
|
|
left: canvasPos.x - 1, |
|
|
left: canvasPos.x - 1, |
|
|
top: canvasPos.y + 1, |
|
|
top: canvasPos.y + 1, |
|
@ -145,8 +148,8 @@ class SelectionHandler { |
|
|
*/ |
|
|
*/ |
|
|
getNodeAt(pointer) { |
|
|
getNodeAt(pointer) { |
|
|
// we first check if this is an navigation controls element
|
|
|
// we first check if this is an navigation controls element
|
|
|
var positionObject = this._pointerToPositionObject(pointer); |
|
|
|
|
|
var overlappingNodes = this._getAllNodesOverlappingWith(positionObject); |
|
|
|
|
|
|
|
|
let positionObject = this._pointerToPositionObject(pointer); |
|
|
|
|
|
let overlappingNodes = this._getAllNodesOverlappingWith(positionObject); |
|
|
|
|
|
|
|
|
// if there are overlapping nodes, select the last one, this is the
|
|
|
// if there are overlapping nodes, select the last one, this is the
|
|
|
// one which is drawn on top of the others
|
|
|
// one which is drawn on top of the others
|
|
@ -166,7 +169,7 @@ class SelectionHandler { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
_getEdgesOverlappingWith(object, overlappingEdges) { |
|
|
_getEdgesOverlappingWith(object, overlappingEdges) { |
|
|
var edges = this.body.edges; |
|
|
|
|
|
|
|
|
let edges = this.body.edges; |
|
|
for (let i = 0; i < this.body.edgeIndices.length; i++) { |
|
|
for (let i = 0; i < this.body.edgeIndices.length; i++) { |
|
|
let edgeId = this.body.edgeIndices[i]; |
|
|
let edgeId = this.body.edgeIndices[i]; |
|
|
if (edges[edgeId].isOverlappingWith(object)) { |
|
|
if (edges[edgeId].isOverlappingWith(object)) { |
|
@ -183,7 +186,7 @@ class SelectionHandler { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
_getAllEdgesOverlappingWith(object) { |
|
|
_getAllEdgesOverlappingWith(object) { |
|
|
var overlappingEdges = []; |
|
|
|
|
|
|
|
|
let overlappingEdges = []; |
|
|
this._getEdgesOverlappingWith(object,overlappingEdges); |
|
|
this._getEdgesOverlappingWith(object,overlappingEdges); |
|
|
return overlappingEdges; |
|
|
return overlappingEdges; |
|
|
} |
|
|
} |
|
@ -198,8 +201,8 @@ class SelectionHandler { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
getEdgeAt(pointer) { |
|
|
getEdgeAt(pointer) { |
|
|
var positionObject = this._pointerToPositionObject(pointer); |
|
|
|
|
|
var overlappingEdges = this._getAllEdgesOverlappingWith(positionObject); |
|
|
|
|
|
|
|
|
let positionObject = this._pointerToPositionObject(pointer); |
|
|
|
|
|
let overlappingEdges = this._getAllEdgesOverlappingWith(positionObject); |
|
|
|
|
|
|
|
|
if (overlappingEdges.length > 0) { |
|
|
if (overlappingEdges.length > 0) { |
|
|
return this.body.edges[overlappingEdges[overlappingEdges.length - 1]]; |
|
|
return this.body.edges[overlappingEdges[overlappingEdges.length - 1]]; |
|
@ -262,12 +265,12 @@ class SelectionHandler { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
unselectAll() { |
|
|
unselectAll() { |
|
|
for(var nodeId in this.selectionObj.nodes) { |
|
|
|
|
|
|
|
|
for(let nodeId in this.selectionObj.nodes) { |
|
|
if(this.selectionObj.nodes.hasOwnProperty(nodeId)) { |
|
|
if(this.selectionObj.nodes.hasOwnProperty(nodeId)) { |
|
|
this.selectionObj.nodes[nodeId].unselect(); |
|
|
this.selectionObj.nodes[nodeId].unselect(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
for(var edgeId in this.selectionObj.edges) { |
|
|
|
|
|
|
|
|
for(let edgeId in this.selectionObj.edges) { |
|
|
if(this.selectionObj.edges.hasOwnProperty(edgeId)) { |
|
|
if(this.selectionObj.edges.hasOwnProperty(edgeId)) { |
|
|
this.selectionObj.edges[edgeId].unselect(); |
|
|
this.selectionObj.edges[edgeId].unselect(); |
|
|
} |
|
|
} |
|
@ -284,8 +287,8 @@ class SelectionHandler { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
_getSelectedNodeCount() { |
|
|
_getSelectedNodeCount() { |
|
|
var count = 0; |
|
|
|
|
|
for (var nodeId in this.selectionObj.nodes) { |
|
|
|
|
|
|
|
|
let count = 0; |
|
|
|
|
|
for (let nodeId in this.selectionObj.nodes) { |
|
|
if (this.selectionObj.nodes.hasOwnProperty(nodeId)) { |
|
|
if (this.selectionObj.nodes.hasOwnProperty(nodeId)) { |
|
|
count += 1; |
|
|
count += 1; |
|
|
} |
|
|
} |
|
@ -300,7 +303,7 @@ class SelectionHandler { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
_getSelectedNode() { |
|
|
_getSelectedNode() { |
|
|
for (var nodeId in this.selectionObj.nodes) { |
|
|
|
|
|
|
|
|
for (let nodeId in this.selectionObj.nodes) { |
|
|
if (this.selectionObj.nodes.hasOwnProperty(nodeId)) { |
|
|
if (this.selectionObj.nodes.hasOwnProperty(nodeId)) { |
|
|
return this.selectionObj.nodes[nodeId]; |
|
|
return this.selectionObj.nodes[nodeId]; |
|
|
} |
|
|
} |
|
@ -315,7 +318,7 @@ class SelectionHandler { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
_getSelectedEdge() { |
|
|
_getSelectedEdge() { |
|
|
for (var edgeId in this.selectionObj.edges) { |
|
|
|
|
|
|
|
|
for (let edgeId in this.selectionObj.edges) { |
|
|
if (this.selectionObj.edges.hasOwnProperty(edgeId)) { |
|
|
if (this.selectionObj.edges.hasOwnProperty(edgeId)) { |
|
|
return this.selectionObj.edges[edgeId]; |
|
|
return this.selectionObj.edges[edgeId]; |
|
|
} |
|
|
} |
|
@ -331,8 +334,8 @@ class SelectionHandler { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
_getSelectedEdgeCount() { |
|
|
_getSelectedEdgeCount() { |
|
|
var count = 0; |
|
|
|
|
|
for (var edgeId in this.selectionObj.edges) { |
|
|
|
|
|
|
|
|
let count = 0; |
|
|
|
|
|
for (let edgeId in this.selectionObj.edges) { |
|
|
if (this.selectionObj.edges.hasOwnProperty(edgeId)) { |
|
|
if (this.selectionObj.edges.hasOwnProperty(edgeId)) { |
|
|
count += 1; |
|
|
count += 1; |
|
|
} |
|
|
} |
|
@ -348,13 +351,13 @@ class SelectionHandler { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
_getSelectedObjectCount() { |
|
|
_getSelectedObjectCount() { |
|
|
var count = 0; |
|
|
|
|
|
for(var nodeId in this.selectionObj.nodes) { |
|
|
|
|
|
|
|
|
let count = 0; |
|
|
|
|
|
for(let nodeId in this.selectionObj.nodes) { |
|
|
if(this.selectionObj.nodes.hasOwnProperty(nodeId)) { |
|
|
if(this.selectionObj.nodes.hasOwnProperty(nodeId)) { |
|
|
count += 1; |
|
|
count += 1; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
for(var edgeId in this.selectionObj.edges) { |
|
|
|
|
|
|
|
|
for(let edgeId in this.selectionObj.edges) { |
|
|
if(this.selectionObj.edges.hasOwnProperty(edgeId)) { |
|
|
if(this.selectionObj.edges.hasOwnProperty(edgeId)) { |
|
|
count += 1; |
|
|
count += 1; |
|
|
} |
|
|
} |
|
@ -369,12 +372,12 @@ class SelectionHandler { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
_selectionIsEmpty() { |
|
|
_selectionIsEmpty() { |
|
|
for(var nodeId in this.selectionObj.nodes) { |
|
|
|
|
|
|
|
|
for(let nodeId in this.selectionObj.nodes) { |
|
|
if(this.selectionObj.nodes.hasOwnProperty(nodeId)) { |
|
|
if(this.selectionObj.nodes.hasOwnProperty(nodeId)) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
for(var edgeId in this.selectionObj.edges) { |
|
|
|
|
|
|
|
|
for(let edgeId in this.selectionObj.edges) { |
|
|
if(this.selectionObj.edges.hasOwnProperty(edgeId)) { |
|
|
if(this.selectionObj.edges.hasOwnProperty(edgeId)) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
@ -390,7 +393,7 @@ class SelectionHandler { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
_clusterInSelection() { |
|
|
_clusterInSelection() { |
|
|
for(var nodeId in this.selectionObj.nodes) { |
|
|
|
|
|
|
|
|
for(let nodeId in this.selectionObj.nodes) { |
|
|
if(this.selectionObj.nodes.hasOwnProperty(nodeId)) { |
|
|
if(this.selectionObj.nodes.hasOwnProperty(nodeId)) { |
|
|
if (this.selectionObj.nodes[nodeId].clusterSize > 1) { |
|
|
if (this.selectionObj.nodes[nodeId].clusterSize > 1) { |
|
|
return true; |
|
|
return true; |
|
@ -407,8 +410,8 @@ class SelectionHandler { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
_selectConnectedEdges(node) { |
|
|
_selectConnectedEdges(node) { |
|
|
for (var i = 0; i < node.edges.length; i++) { |
|
|
|
|
|
var edge = node.edges[i]; |
|
|
|
|
|
|
|
|
for (let i = 0; i < node.edges.length; i++) { |
|
|
|
|
|
let edge = node.edges[i]; |
|
|
edge.select(); |
|
|
edge.select(); |
|
|
this._addToSelection(edge); |
|
|
this._addToSelection(edge); |
|
|
} |
|
|
} |
|
@ -421,8 +424,8 @@ class SelectionHandler { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
_hoverConnectedEdges(node) { |
|
|
_hoverConnectedEdges(node) { |
|
|
for (var i = 0; i < node.edges.length; i++) { |
|
|
|
|
|
var edge = node.edges[i]; |
|
|
|
|
|
|
|
|
for (let i = 0; i < node.edges.length; i++) { |
|
|
|
|
|
let edge = node.edges[i]; |
|
|
edge.hover = true; |
|
|
edge.hover = true; |
|
|
this._addToHover(edge); |
|
|
this._addToHover(edge); |
|
|
} |
|
|
} |
|
@ -436,8 +439,8 @@ class SelectionHandler { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
_unselectConnectedEdges(node) { |
|
|
_unselectConnectedEdges(node) { |
|
|
for (var i = 0; i < node.edges.length; i++) { |
|
|
|
|
|
var edge = node.edges[i]; |
|
|
|
|
|
|
|
|
for (let i = 0; i < node.edges.length; i++) { |
|
|
|
|
|
let edge = node.edges[i]; |
|
|
edge.unselect(); |
|
|
edge.unselect(); |
|
|
this._removeFromSelection(edge); |
|
|
this._removeFromSelection(edge); |
|
|
} |
|
|
} |
|
@ -491,8 +494,8 @@ class SelectionHandler { |
|
|
* @return {{nodes: Array.<String>, edges: Array.<String>}} selection |
|
|
* @return {{nodes: Array.<String>, edges: Array.<String>}} selection |
|
|
*/ |
|
|
*/ |
|
|
getSelection() { |
|
|
getSelection() { |
|
|
var nodeIds = this.getSelectedNodes(); |
|
|
|
|
|
var edgeIds = this.getSelectedEdges(); |
|
|
|
|
|
|
|
|
let nodeIds = this.getSelectedNodes(); |
|
|
|
|
|
let edgeIds = this.getSelectedEdges(); |
|
|
return {nodes:nodeIds, edges:edgeIds}; |
|
|
return {nodes:nodeIds, edges:edgeIds}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -503,9 +506,9 @@ class SelectionHandler { |
|
|
* selected nodes. |
|
|
* selected nodes. |
|
|
*/ |
|
|
*/ |
|
|
getSelectedNodes() { |
|
|
getSelectedNodes() { |
|
|
var idArray = []; |
|
|
|
|
|
|
|
|
let idArray = []; |
|
|
if (this.options.select === true) { |
|
|
if (this.options.select === true) { |
|
|
for (var nodeId in this.selectionObj.nodes) { |
|
|
|
|
|
|
|
|
for (let nodeId in this.selectionObj.nodes) { |
|
|
if (this.selectionObj.nodes.hasOwnProperty(nodeId)) { |
|
|
if (this.selectionObj.nodes.hasOwnProperty(nodeId)) { |
|
|
idArray.push(nodeId); |
|
|
idArray.push(nodeId); |
|
|
} |
|
|
} |
|
@ -521,9 +524,9 @@ class SelectionHandler { |
|
|
* selected nodes. |
|
|
* selected nodes. |
|
|
*/ |
|
|
*/ |
|
|
getSelectedEdges() { |
|
|
getSelectedEdges() { |
|
|
var idArray = []; |
|
|
|
|
|
|
|
|
let idArray = []; |
|
|
if (this.options.select === true) { |
|
|
if (this.options.select === true) { |
|
|
for (var edgeId in this.selectionObj.edges) { |
|
|
|
|
|
|
|
|
for (let edgeId in this.selectionObj.edges) { |
|
|
if (this.selectionObj.edges.hasOwnProperty(edgeId)) { |
|
|
if (this.selectionObj.edges.hasOwnProperty(edgeId)) { |
|
|
idArray.push(edgeId); |
|
|
idArray.push(edgeId); |
|
|
} |
|
|
} |
|
@ -539,25 +542,25 @@ class SelectionHandler { |
|
|
* selected nodes. |
|
|
* selected nodes. |
|
|
* @param {boolean} [highlightEdges] |
|
|
* @param {boolean} [highlightEdges] |
|
|
*/ |
|
|
*/ |
|
|
selectNodes(selection, highlightEdges) { |
|
|
|
|
|
var i, iMax, id; |
|
|
|
|
|
|
|
|
selectNodes(selection, highlightEdges = true) { |
|
|
|
|
|
let i, id; |
|
|
|
|
|
|
|
|
if (!selection || (selection.length === undefined)) |
|
|
if (!selection || (selection.length === undefined)) |
|
|
throw 'Selection must be an array with ids'; |
|
|
throw 'Selection must be an array with ids'; |
|
|
|
|
|
|
|
|
// first unselect any selected node
|
|
|
// first unselect any selected node
|
|
|
this.unselectAll(true); |
|
|
|
|
|
|
|
|
this.unselectAll(); |
|
|
|
|
|
|
|
|
for (i = 0, iMax = selection.length; i < iMax; i++) { |
|
|
|
|
|
|
|
|
for (i = 0; i < selection.length; i++) { |
|
|
id = selection[i]; |
|
|
id = selection[i]; |
|
|
|
|
|
|
|
|
var node = this.body.nodes[id]; |
|
|
|
|
|
|
|
|
let node = this.body.nodes[id]; |
|
|
if (!node) { |
|
|
if (!node) { |
|
|
throw new RangeError('Node with id "' + id + '" not found'); |
|
|
throw new RangeError('Node with id "' + id + '" not found'); |
|
|
} |
|
|
} |
|
|
this._selectObject(node,true,true,highlightEdges,true); |
|
|
|
|
|
|
|
|
this.selectObject(node,highlightEdges); |
|
|
} |
|
|
} |
|
|
this.redraw(); |
|
|
|
|
|
|
|
|
this.body.emitter.emit('_requestRedraw'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -567,24 +570,24 @@ class SelectionHandler { |
|
|
* selected nodes. |
|
|
* selected nodes. |
|
|
*/ |
|
|
*/ |
|
|
selectEdges(selection) { |
|
|
selectEdges(selection) { |
|
|
var i, iMax, id; |
|
|
|
|
|
|
|
|
let i, id; |
|
|
|
|
|
|
|
|
if (!selection || (selection.length === undefined)) |
|
|
if (!selection || (selection.length === undefined)) |
|
|
throw 'Selection must be an array with ids'; |
|
|
throw 'Selection must be an array with ids'; |
|
|
|
|
|
|
|
|
// first unselect any selected node
|
|
|
|
|
|
this.unselectAll(true); |
|
|
|
|
|
|
|
|
// first unselect any selected objects
|
|
|
|
|
|
this.unselectAll(); |
|
|
|
|
|
|
|
|
for (i = 0, iMax = selection.length; i < iMax; i++) { |
|
|
|
|
|
|
|
|
for (i = 0; i < selection.length; i++) { |
|
|
id = selection[i]; |
|
|
id = selection[i]; |
|
|
|
|
|
|
|
|
var edge = this.body.edges[id]; |
|
|
|
|
|
|
|
|
let edge = this.body.edges[id]; |
|
|
if (!edge) { |
|
|
if (!edge) { |
|
|
throw new RangeError('Edge with id "' + id + '" not found'); |
|
|
throw new RangeError('Edge with id "' + id + '" not found'); |
|
|
} |
|
|
} |
|
|
this._selectObject(edge,true,true,false,true); |
|
|
|
|
|
|
|
|
this.selectObject(edge); |
|
|
} |
|
|
} |
|
|
this.redraw(); |
|
|
|
|
|
|
|
|
this.body.emitter.emit('_requestRedraw'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -592,14 +595,14 @@ class SelectionHandler { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
updateSelection() { |
|
|
updateSelection() { |
|
|
for (var nodeId in this.selectionObj.nodes) { |
|
|
|
|
|
|
|
|
for (let nodeId in this.selectionObj.nodes) { |
|
|
if (this.selectionObj.nodes.hasOwnProperty(nodeId)) { |
|
|
if (this.selectionObj.nodes.hasOwnProperty(nodeId)) { |
|
|
if (!this.body.nodes.hasOwnProperty(nodeId)) { |
|
|
if (!this.body.nodes.hasOwnProperty(nodeId)) { |
|
|
delete this.selectionObj.nodes[nodeId]; |
|
|
delete this.selectionObj.nodes[nodeId]; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
for (var edgeId in this.selectionObj.edges) { |
|
|
|
|
|
|
|
|
for (let edgeId in this.selectionObj.edges) { |
|
|
if (this.selectionObj.edges.hasOwnProperty(edgeId)) { |
|
|
if (this.selectionObj.edges.hasOwnProperty(edgeId)) { |
|
|
if (!this.body.edges.hasOwnProperty(edgeId)) { |
|
|
if (!this.body.edges.hasOwnProperty(edgeId)) { |
|
|
delete this.selectionObj.edges[edgeId]; |
|
|
delete this.selectionObj.edges[edgeId]; |
|
|