diff --git a/docs/graph.html b/docs/graph.html
index 23d49b6a..791c8d51 100644
--- a/docs/graph.html
+++ b/docs/graph.html
@@ -2149,16 +2149,36 @@ var options: {
+
+ selectNodes(selection, [highlightEdges]) |
+ none |
+ Select nodes.
+ selection is an array with ids of nodes to be selected.
+ The array selection can contain zero or multiple ids.
+ Example usage: graph.selectNodes([3, 5]); will select
+ nodes with id 3 and 5. The highlisghEdges boolean can be used to automatically select the edges connected to the node.
+ |
+
+
+ selectEdges(selection) |
+ none |
+ Select Edges.
+ selection is an array with ids of edges to be selected.
+ The array selection can contain zero or multiple ids.
+ Example usage: graph.selectEdges([3, 5]); will select
+ edges with id 3 and 5.
+ |
+
setSelection(selection) |
none |
- Select nodes.
- selection is an array with ids of nodes to be selected.
- The array selection can contain zero or multiple ids.
- Example usage: graph.setSelection([3, 5]); will select
- nodes with id 3 and 5.
+ | Select nodes [deprecated].
+ selection is an array with ids of nodes to be selected.
+ The array selection can contain zero or multiple ids.
+ Example usage: graph.setSelection([3, 5]); will select
+ nodes with id 3 and 5.
|
-
+
setSize(width, height) |
diff --git a/src/graph/graphMixins/SelectionMixin.js b/src/graph/graphMixins/SelectionMixin.js
index f663a332..8acb29c6 100644
--- a/src/graph/graphMixins/SelectionMixin.js
+++ b/src/graph/graphMixins/SelectionMixin.js
@@ -402,10 +402,13 @@ var SelectionMixin = {
* @param {Boolean} [doNotTrigger] | ignore trigger
* @private
*/
- _selectObject : function(object, append, doNotTrigger) {
+ _selectObject : function(object, append, doNotTrigger, highlightEdges) {
if (doNotTrigger === undefined) {
doNotTrigger = false;
}
+ if (highlightEdges === undefined) {
+ highlightEdges = true;
+ }
if (this._selectionIsEmpty() == false && append == false && this.forceAppendSelection == false) {
this._unselectAll(true);
@@ -414,7 +417,7 @@ var SelectionMixin = {
if (object.selected == false) {
object.select();
this._addToSelection(object);
- if (object instanceof Node && this.blockConnectingEdgeSelection == false) {
+ if (object instanceof Node && this.blockConnectingEdgeSelection == false && highlightEdges == true) {
this._selectConnectedEdges(object);
}
}
@@ -619,10 +622,67 @@ var SelectionMixin = {
}
this._selectObject(node,true,true);
}
+
+ console.log("setSelection is deprecated. Please use selectNodes instead.")
+
this.redraw();
},
+ /**
+ * select zero or more nodes with the option to highlight edges
+ * @param {Number[] | String[]} selection An array with the ids of the
+ * selected nodes.
+ * @param {boolean} [highlightEdges]
+ */
+ selectNodes : function(selection, highlightEdges) {
+ var i, iMax, id;
+
+ if (!selection || (selection.length == undefined))
+ throw 'Selection must be an array with ids';
+
+ // first unselect any selected node
+ this._unselectAll(true);
+
+ for (i = 0, iMax = selection.length; i < iMax; i++) {
+ id = selection[i];
+
+ var node = this.nodes[id];
+ if (!node) {
+ throw new RangeError('Node with id "' + id + '" not found');
+ }
+ this._selectObject(node,true,true,highlightEdges);
+ }
+ this.redraw();
+ },
+
+
+ /**
+ * select zero or more edges
+ * @param {Number[] | String[]} selection An array with the ids of the
+ * selected nodes.
+ */
+ selectEdges : function(selection) {
+ var i, iMax, id;
+
+ if (!selection || (selection.length == undefined))
+ throw 'Selection must be an array with ids';
+
+ // first unselect any selected node
+ this._unselectAll(true);
+
+ for (i = 0, iMax = selection.length; i < iMax; i++) {
+ id = selection[i];
+
+ var edge = this.edges[id];
+ if (!edge) {
+ throw new RangeError('Edge with id "' + id + '" not found');
+ }
+ this._selectObject(edge,true,true,highlightEdges);
+ }
+ this.redraw();
+ },
+
/**
* Validate the selection: remove ids of nodes which no longer exist
* @private