From 5e61c5529acf81c5c4a3524f6c1b82341c692e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hasan=20Balc=C4=B1?= Date: Mon, 30 Mar 2020 13:45:56 +0300 Subject: [PATCH 1/6] Update demo file --- demo.html | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/demo.html b/demo.html index 3385461..11e8ba7 100644 --- a/demo.html +++ b/demo.html @@ -104,37 +104,6 @@ background: white; } - /*/* creating color boxes of highlighting colors*/ - /*.topnav input[type="color"] { - float: left; - width: 50px; - height: 30px; - margin: 5px; - border: 2px solid white; - border-style: solid; - cursor: pointer; - } -*/ - /*.topnav input[type="color"]:hover - { - border: 2px solid black; - }*/ - - .topnav button { - display: inline-block; - background-color: #7b38d8; - border-radius: 10px; - border: 4px double #cccccc; - color: #eeeeee; - text-align: center; - font-size: 28px; - padding: 20px; - width: 200px; - transition: all 0.5s; - cursor: pointer; - margin-left: 10px; - } - .topnav c { float: left; width: 30px; From f1bd372cd600a25ba453e5e7328772d90420a1ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hasan=20Balc=C4=B1?= Date: Mon, 30 Mar 2020 13:49:23 +0300 Subject: [PATCH 2/6] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1b6a425..7ac535f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cytoscape-view-utilities", - "version": "3.0.0", + "version": "4.0.0", "description": "Package of view utilities for cytoscape.js", "main": "src/index.js", "spm": { From 5a0d771a07b0a749ae8897f583c4d2cf31e696c4 Mon Sep 17 00:00:00 2001 From: canbax Date: Tue, 7 Apr 2020 17:29:42 +0300 Subject: [PATCH 3/6] use batch for faster hightlight/removeHighlights --- src/view-utilities.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/view-utilities.js b/src/view-utilities.js index 2ea1b4f..da1a480 100644 --- a/src/view-utilities.js +++ b/src/view-utilities.js @@ -34,13 +34,15 @@ var viewUtilities = function (cy, options) { // Helper functions for internal usage (not to be exposed) function highlight(eles, idx) { - for (var i = 0; i < options.highlightStyles.length; i++) { - var className = getCyClassName4Idx(i); - eles.removeClass(className); - } - var className = getCyClassName4Idx(idx); - eles.addClass(className); - eles.unselect(); + cy.batch(() => { + for (var i = 0; i < options.highlightStyles.length; i++) { + var className = getCyClassName4Idx(i); + eles.removeClass(className); + } + var className = getCyClassName4Idx(idx); + eles.addClass(className); + eles.unselect(); + }); } function getWithNeighbors(eles) { @@ -123,14 +125,13 @@ var viewUtilities = function (cy, options) { if (eles == null || eles.length == null) { eles = cy.elements(); } - - for (var i = 0; i < options.highlightStyles.length; i++) { - var className = getCyClassName4Idx(i); - eles.removeClass(className); - eles.removeData(className); - } + cy.batch(() => { + for (var i = 0; i < options.highlightStyles.length; i++) { + var className = getCyClassName4Idx(i); + eles.removeClass(className); + } + }); return eles; - // TODO check if remove data is needed here }; // Indicates if the ele is highlighted From 7650b26dcbc87a790e070d059044f82862e8fc92 Mon Sep 17 00:00:00 2001 From: canbax Date: Mon, 13 Apr 2020 15:06:27 +0300 Subject: [PATCH 4/6] functionality to remove highlight style --- README.md | 4 +++ cytoscape-view-utilities.js | 48 +++++++++++++++++-------------- src/view-utilities.js | 57 ++++++++++++++++++++----------------- 3 files changed, 62 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index a60ef24..541e715 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,10 @@ Changes the style specified with `idx`. @param edgeStyle — [cytoscape style](https://js.cytoscape.org/#style) for edges
Adds a new style to the `highlightStyles` array. +`instance.removeHighlightStyle(styleIdx): void`
+@param styleIdx — index of the style to delete (0 based)
+Removes the style from `highlightStyles` array. + ## Default Options ``` highlightStyles: [], diff --git a/cytoscape-view-utilities.js b/cytoscape-view-utilities.js index 4bcab50..e614ad0 100644 --- a/cytoscape-view-utilities.js +++ b/cytoscape-view-utilities.js @@ -246,10 +246,12 @@ module.exports = function (cy, ur, viewUtilities) { },{}],3:[function(_dereq_,module,exports){ var viewUtilities = function (cy, options) { + var classNames4Styles = []; init(); function init() { // add provided styles for (var i = 0; i < options.highlightStyles.length; i++) { + classNames4Styles.push('__highligtighted__' + i); updateCyStyle(i); } @@ -267,26 +269,22 @@ var viewUtilities = function (cy, options) { } function updateCyStyle(classIdx) { - var className = getCyClassName4Idx(classIdx); + var className = classNames4Styles[classIdx]; var cssNode = options.highlightStyles[classIdx].node; var cssEdge = options.highlightStyles[classIdx].edge; cy.style().selector('node.' + className).css(cssNode).update(); cy.style().selector('edge.' + className).css(cssEdge).update(); } - function getCyClassName4Idx(i) { - return '__highligtighted__' + i; - } - // Helper functions for internal usage (not to be exposed) function highlight(eles, idx) { + cy.startBatch(); for (var i = 0; i < options.highlightStyles.length; i++) { - var className = getCyClassName4Idx(i); - eles.removeClass(className); + eles.removeClass(classNames4Styles[i]); } - var className = getCyClassName4Idx(idx); - eles.addClass(className); + eles.addClass(classNames4Styles[idx]); eles.unselect(); + cy.endBatch(); } function getWithNeighbors(eles) { @@ -353,7 +351,7 @@ var viewUtilities = function (cy, options) { highlight(eles, idx); // Use the helper here return eles; }; - + instance.getHighlightStyles = function () { return options.highlightStyles; }; @@ -366,25 +364,22 @@ var viewUtilities = function (cy, options) { // Remove highlights from eles. // If eles is not defined considers cy.elements() instance.removeHighlights = function (eles) { + cy.startBatch(); if (eles == null || eles.length == null) { eles = cy.elements(); } - for (var i = 0; i < options.highlightStyles.length; i++) { - var className = getCyClassName4Idx(i); - eles.removeClass(className); - eles.removeData(className); + eles.removeClass(classNames4Styles[i]); } + cy.endBatch(); return eles; - // TODO check if remove data is needed here }; // Indicates if the ele is highlighted instance.isHighlighted = function (ele) { var isHigh = false; for (var i = 0; i < options.highlightStyles.length; i++) { - var className = getCyClassName4Idx(i); - if (ele.is('.' + className + ':visible')) { + if (ele.is('.' + classNames4Styles[i] + ':visible')) { isHigh = true; } } @@ -401,16 +396,27 @@ var viewUtilities = function (cy, options) { instance.addHighlightStyle = function (nodeStyle, edgeStyle) { var o = { node: nodeStyle, edge: edgeStyle }; options.highlightStyles.push(o); + var s = '__highligtighted__' + (options.highlightStyles.length - 1); + classNames4Styles.push(s); updateCyStyle(options.highlightStyles.length - 1); addSelectionStyles(); }; - instance.getAllHighlightClasses = function() { + instance.removeHighlightStyle = function (styleIdx) { + if (styleIdx < 0 || styleIdx > options.highlightStyles.length - 1) { + return; + } + cy.elements().removeClass(classNames4Styles[styleIdx]); + options.highlightStyles.splice(styleIdx, 1); + classNames4Styles.splice(styleIdx, 1); + }; + + instance.getAllHighlightClasses = function () { var a = []; for (var i = 0; i < options.highlightStyles.length; i++) { - a.push(getCyClassName4Idx(i)); + a.push(classNames4Styles[i]); } - return a; + return classNames4Styles; }; //Zoom selected Nodes @@ -553,4 +559,4 @@ module.exports = viewUtilities; },{}]},{},[1])(1) }); -//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJzcmMvaW5kZXguanMiLCJzcmMvdW5kby1yZWRvLmpzIiwic3JjL3ZpZXctdXRpbGl0aWVzLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBO0FDQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNB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ICAqIFVzYWdlOk9iamVjdC5leHRlbmQoe30sIG9iakEsIG9iakIpXHJcbiAgICAgICovXHJcbiAgICAgIGZ1bmN0aW9uIGV4dGVuZE9wdGlvbnMob3V0KSB7XHJcbiAgICAgICAgb3V0ID0gb3V0IHx8IHt9O1xyXG5cclxuICAgICAgICBmb3IgKHZhciBpID0gMTsgaSA8IGFyZ3VtZW50cy5sZW5ndGg7IGkrKykge1xyXG4gICAgICAgICAgdmFyIG9iaiA9IGFyZ3VtZW50c1tpXTtcclxuXHJcbiAgICAgICAgICBpZiAoIW9iailcclxuICAgICAgICAgICAgY29udGludWU7XHJcblxyXG4gICAgICAgICAgZm9yICh2YXIga2V5IGluIG9iaikge1xyXG4gICAgICAgICAgICBpZiAob2JqLmhhc093blByb3BlcnR5KGtleSkpIHtcclxuICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShvYmpba2V5XSkpIHtcclxuICAgICAgICAgICAgICAgIG91dFtrZXldID0gb2JqW2tleV0uc2xpY2UoKTtcclxuICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBvYmpba2V5XSA9PT0gJ29iamVjdCcpIHtcclxuICAgICAgICAgICAgICAgIG91dFtrZXldID0gZXh0ZW5kT3B0aW9ucyhvdXRba2V5XSwgb2JqW2tleV0pO1xyXG4gICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBvdXRba2V5XSA9IG9ialtrZXldO1xyXG4gICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgcmV0dXJuIG91dDtcclxuICAgICAgfTtcclxuXHJcbiAgICAgIG9wdGlvbnMgPSBleHRlbmRPcHRpb25zKHt9LCBvcHRpb25zLCBvcHRzKTtcclxuXHJcbiAgICAgIC8vIGNyZWF0ZSBhIHZpZXcgdXRpbGl0aWVzIGluc3RhbmNlXHJcbiAgICAgIHZhciBpbnN0YW5j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csICdub2RlJywgZnVuY3Rpb24oZXZlbnQpe1xyXG4gICAgICAgICAgdmFyIHRhcmdldCA9IGV2ZW50LnRhcmdldCB8fCBldmVudC5jeVRhcmdldDtcclxuICAgICAgICAgIHZhciB0YXBoZWxkID0gZmFsc2U7XHJcbiAgICAgICAgICB2YXIgbmVpZ2hib3Job29kO1xyXG4gICAgICAgICAgdmFyIHRpbWVvdXQgPSBzZXRUaW1lb3V0KGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgICAgIGlmKHNoaWZ0S2V5RG93bil7XHJcbiAgICAgICAgICAgICAgY3kuZWxlbWVudHMoKS51bnNlbGVjdCgpO1xyXG4gICAgICAgICAgICAgIG5laWdoYm9yaG9vZCA9IG9wdGlvbnMubmVpZ2hib3IodGFyZ2V0KTtcclxuICAgICAgICAgICAgICBpZihuZWlnaGJvcmhvb2QpXHJcbiAgICAgICAgICAgICAgICBuZWlnaGJvcmhvb2Quc2VsZWN0KCk7XHJcbiAgICAgICAgICAgICAgdGFyZ2V0LmxvY2soKTtcclxuICAgICAgICAgICAgICB0YXBoZWxkID0gdHJ1ZTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgfSwgb3B0aW9ucy5uZWlnaGJvclNlbGVjdFRpbWUgLSA1MDApO1xyXG4gICAgICAgICAgY3kub24oJ2ZyZWUnLCAnbm9kZScsIGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgICAgIHZhciB0YXJnZXRUYXBoZWxkID0gZXZlbnQudGFyZ2V0IHx8IGV2ZW50LmN5VGFyZ2V0O1xyXG4gICAgICAgICAgICBpZih0YXJnZXQgPT0gdGFyZ2V0VGFwaGVsZCAmJiB0YXBoZWxkID09PSB0cnVlKXtcclxuICAgICAgICAgICAgICB0YXBoZWxkID0gZmFsc2U7XHJcbiAgICAgICAgICAgICAgaWYobmVpZ2hib3Job29kKVxyXG4gICAgICAgICAgICAgICAgbmVpZ2hib3Job29kLnNlbGVjdCgpO1xyXG4gICAgICAgICAgICAgIHR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GZ1bmN0aW9uIGV4dGVuZE9wdGlvbnMob3V0KSB7XHJcbiAgICAgICAgb3V0ID0gb3V0IHx8IHt9O1xyXG5cclxuICAgICAgICBmb3IgKHZhciBpID0gMTsgaSA8IGFyZ3VtZW50cy5sZW5ndGg7IGkrKykge1xyXG4gICAgICAgICAgdmFyIG9iaiA9IGFyZ3VtZW50c1tpXTtcclxuXHJcbiAgICAgICAgICBpZiAoIW9iailcclxuICAgICAgICAgICAgY29udGludWU7XHJcblxyXG4gICAgICAgICAgZm9yICh2YXIga2V5IGluIG9iaikge1xyXG4gICAgICAgICAgICBpZiAob2JqLmhhc093blByb3BlcnR5KGtleSkpIHtcclxuICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShvYmpba2V5XSkpIHtcclxuICAgICAgICAgICAgICAgIG91dFtrZXldID0gb2JqW2tleV0uc2xpY2UoKTtcclxuICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBvYmpba2V5XSA9PT0gJ29iamVjdCcpIHtcclxuICAgICAgICAgICAgICAgIG91dFtrZXldID0gZXh0ZW5kT3B0aW9ucyhvdXRba2V5XSwgb2JqW2tleV0pO1xyXG4gICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBvdXRba2V5XSA9IG9ialtrZXldO1xyXG4gICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgcmV0dXJuIG91dDtcclxuICAgICAgfTtcclxuXHJcbiAgICAgIG9wdGlvbnMgPSBleHRlbmRPcHRpb25zKHt9LCBvcHRpb25zLCBvcHRzKTtcclxuXHJcbiAgICAgIC8vIGNyZWF0ZSBhIHZpZXcgdXRpbGl0aWVzIGluc3RhbmNlXHJcbiAgICAgIHZhciBpbnN0YW5jZSA9IHZpZXdVdGlsaXRpZXMoY3ksIG9wdGlvbnMpO1xyXG5cclxuICAgICAgaWYgKGN5LnVuZG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LnRhcmdldCB8fCBldmVudC5jeVRhcmdldDtcclxuICAgICAgICAgIHZhciB0YXBoZWxkID0gZmFsc2U7XHJcbiAgICAgICAgICB2YXIgbmVpZ2hib3Job29kO1xyXG4gICAgICAgICAgdmFyIHRpbWVvdXQgPSBzZXRUaW1lb3V0KGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgICAgIGlmKHNoaWZ0S2V5RG93bil7XHJcbiAgICAgICAgICAgICAgY3kuZWxlbWVudHMoKS51bnNlbGVjdCgpO1xyXG4gICAgICAgICAgICAgIG5laWdoYm9yaG9vZCA9IG9wdGlvbnMubmVpZ2hib3IodGFyZ2V0KTtcclxuICAgICAgICAgICAgICBpZihuZWlnaGJvcmhvb2QpXHJcbiAgICAgICAgICAgICAgICBuZWlnaGJvcmhvb2Quc2VsZWN0KCk7XHJcbiAgICAgICAgICAgICAgdGFyZ2V0LmxvY2soKTtcclxuICAgICAgICAgICAgICB0YXBoZWxkID0gdHJ1ZTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgfSwgb3B0aW9ucy5uZWlnaGJvclNlbGVjdFRpbWUgLSA1MDApO1xyXG4gICAgICAgICAgY3kub24oJ2ZyZWUnLCAnbm9kZScsIGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgICAgIHZhciB0YXJnZXRUYXBoZWxkID0gZXZlbnQudGFyZ2V0IHx8IGV2ZW50LmN5VGFyZ2V0O1xyXG4gICAgICAgICAgICBpZih0YXJnZXQgPT0gdGFyZ2V0VGFwaGVsZCAmJiB0YXBoZWxkID09PSB0cnVlKXtcclxuICAgICAgICAgICAgICB0YXBoZWxkID0gZmFsc2U7XHJcbiAgICAgICAgICAgICAgaWYobmVpZ2hib3Job29kKVxyXG4gICAgICAgICAgICAgICAgbmVpZ2hib3Job29kLnNlbGVjdCgpO1xyXG4gICAgICAgICAgICAgIHRhcmdldC51bmxvY2soKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBlbHNle1xyXG4gICAgICAgIC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3B0aW9ucy56b29tQW5pbWF0aW9uRHVyYXRpb24sXHJcbiAgICAgICAgY29tcGxldGU6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgIGlmIChjYWxsYmFjaykge1xyXG4gICAgICAgICAgICBjYWxsYmFjaygpO1xyXG4gICAgICAgICAgfVxyXG4gICAgICAgICAgY3kuYXV0b3Vuc2VsZWN0aWZ5KGZhbHNlKTtcclxuICAgICAgICB9XHJcbiAgICAgIH0pO1xyXG4gICAgfSk7XHJcbiAgfTtcclxuXHJcbiAgaW5zdGFuY2UuZGlzYWJsZU1hcnF1ZWVab29tID0gZnVuY3Rpb24gKCkge1xyXG4gICAgY3kub2ZmKCd0YXBzdGFydCcsIHRhYlN0YXJ0SGFuZGxlcik7XHJcbiAgICBjeS5vZmYoJ3RhcGVuZCcsIHRhYkVuZEhhbmRsZXIpO1xyXG4gICAgY3kuYXV0b3Vuc2VsZWN0aWZ5KGZhbHNlKTtcclxuICB9O1xyXG5cclxuICAvLyByZXR1cm4gdGhlIGluc3RhbmNlXHJcbiAgcmV0dXJuIGluc3RhbmNlO1xyXG59O1xyXG5cclxubW9kdWxlLmV4cG9ydHMgPSB2aWV3VXRpbGl0aWVzO1xyXG4iXX0= diff --git a/src/view-utilities.js b/src/view-utilities.js index da1a480..9e25215 100644 --- a/src/view-utilities.js +++ b/src/view-utilities.js @@ -1,9 +1,11 @@ var viewUtilities = function (cy, options) { + var classNames4Styles = []; init(); function init() { // add provided styles for (var i = 0; i < options.highlightStyles.length; i++) { + classNames4Styles.push('__highligtighted__' + i); updateCyStyle(i); } @@ -21,28 +23,22 @@ var viewUtilities = function (cy, options) { } function updateCyStyle(classIdx) { - var className = getCyClassName4Idx(classIdx); + var className = classNames4Styles[classIdx]; var cssNode = options.highlightStyles[classIdx].node; var cssEdge = options.highlightStyles[classIdx].edge; cy.style().selector('node.' + className).css(cssNode).update(); cy.style().selector('edge.' + className).css(cssEdge).update(); } - function getCyClassName4Idx(i) { - return '__highligtighted__' + i; - } - // Helper functions for internal usage (not to be exposed) function highlight(eles, idx) { - cy.batch(() => { - for (var i = 0; i < options.highlightStyles.length; i++) { - var className = getCyClassName4Idx(i); - eles.removeClass(className); - } - var className = getCyClassName4Idx(idx); - eles.addClass(className); - eles.unselect(); - }); + cy.startBatch(); + for (var i = 0; i < options.highlightStyles.length; i++) { + eles.removeClass(classNames4Styles[i]); + } + eles.addClass(classNames4Styles[idx]); + eles.unselect(); + cy.endBatch(); } function getWithNeighbors(eles) { @@ -109,7 +105,7 @@ var viewUtilities = function (cy, options) { highlight(eles, idx); // Use the helper here return eles; }; - + instance.getHighlightStyles = function () { return options.highlightStyles; }; @@ -122,15 +118,14 @@ var viewUtilities = function (cy, options) { // Remove highlights from eles. // If eles is not defined considers cy.elements() instance.removeHighlights = function (eles) { + cy.startBatch(); if (eles == null || eles.length == null) { eles = cy.elements(); } - cy.batch(() => { - for (var i = 0; i < options.highlightStyles.length; i++) { - var className = getCyClassName4Idx(i); - eles.removeClass(className); - } - }); + for (var i = 0; i < options.highlightStyles.length; i++) { + eles.removeClass(classNames4Styles[i]); + } + cy.endBatch(); return eles; }; @@ -138,8 +133,7 @@ var viewUtilities = function (cy, options) { instance.isHighlighted = function (ele) { var isHigh = false; for (var i = 0; i < options.highlightStyles.length; i++) { - var className = getCyClassName4Idx(i); - if (ele.is('.' + className + ':visible')) { + if (ele.is('.' + classNames4Styles[i] + ':visible')) { isHigh = true; } } @@ -156,16 +150,27 @@ var viewUtilities = function (cy, options) { instance.addHighlightStyle = function (nodeStyle, edgeStyle) { var o = { node: nodeStyle, edge: edgeStyle }; options.highlightStyles.push(o); + var s = '__highligtighted__' + (options.highlightStyles.length - 1); + classNames4Styles.push(s); updateCyStyle(options.highlightStyles.length - 1); addSelectionStyles(); }; - instance.getAllHighlightClasses = function() { + instance.removeHighlightStyle = function (styleIdx) { + if (styleIdx < 0 || styleIdx > options.highlightStyles.length - 1) { + return; + } + cy.elements().removeClass(classNames4Styles[styleIdx]); + options.highlightStyles.splice(styleIdx, 1); + classNames4Styles.splice(styleIdx, 1); + }; + + instance.getAllHighlightClasses = function () { var a = []; for (var i = 0; i < options.highlightStyles.length; i++) { - a.push(getCyClassName4Idx(i)); + a.push(classNames4Styles[i]); } - return a; + return classNames4Styles; }; //Zoom selected Nodes From fbe37da27d411f86b29b3ef68cce5d777e15ba47 Mon Sep 17 00:00:00 2001 From: canbax Date: Tue, 21 Apr 2020 13:05:51 +0300 Subject: [PATCH 5/6] ugurdogrusoz/visuall#202 fix --- cytoscape-view-utilities.js | 11 ++++++++--- src/view-utilities.js | 9 +++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/cytoscape-view-utilities.js b/cytoscape-view-utilities.js index e614ad0..ae740cf 100644 --- a/cytoscape-view-utilities.js +++ b/cytoscape-view-utilities.js @@ -247,11 +247,15 @@ module.exports = function (cy, ur, viewUtilities) { var viewUtilities = function (cy, options) { var classNames4Styles = []; + // give a unique name for each unique style EVER added + var totStyleCnt = 0; init(); function init() { // add provided styles for (var i = 0; i < options.highlightStyles.length; i++) { - classNames4Styles.push('__highligtighted__' + i); + var s = '__highligtighted__' + totStyleCnt; + classNames4Styles.push(s); + totStyleCnt++; updateCyStyle(i); } @@ -396,8 +400,9 @@ var viewUtilities = function (cy, options) { instance.addHighlightStyle = function (nodeStyle, edgeStyle) { var o = { node: nodeStyle, edge: edgeStyle }; options.highlightStyles.push(o); - var s = '__highligtighted__' + (options.highlightStyles.length - 1); + var s = '__highligtighted__' + totStyleCnt; classNames4Styles.push(s); + totStyleCnt++; updateCyStyle(options.highlightStyles.length - 1); addSelectionStyles(); }; @@ -559,4 +564,4 @@ module.exports = viewUtilities; },{}]},{},[1])(1) }); -//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJzcmMvaW5kZXguanMiLCJzcmMvdW5kby1yZWRv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aXMgZ2l2ZW4gYXMgdGhlIHBhcmFtIHRoZW4gcmV0dXJuIHRoZSBleHRlbnNpb24gaW5zdGFuY2VcclxuICAgICAgaWYgKG9wdHMgPT09ICdnZXQnKSB7XHJcbiAgICAgICAgcmV0dXJuIGdldFNjcmF0Y2goY3kpLmluc3RhbmNlO1xyXG4gICAgICB9XHJcbiAgICAgIFxyXG4gICAgICAvKipcclxuICAgICAgKiBEZWVwIGNvcHkgb3IgbWVyZ2Ugb2JqZWN0cyAtIHJlcGxhY2VtZW50IGZvciBqUXVlcnkgZGVlcCBleHRlbmRcclxuICAgICAgKiBUYWtlbiBmcm9tIGh0dHA6Ly95b3VtaWdodG5vdG5lZWRqcXVlcnkuY29tLyNkZWVwX2V4dGVuZFxyXG4gICAgICAqIGFuZCBidWcgcmVsYXRlZCB0byBkZWVwIGNvcHkgb2YgQXJyYXlzIGlzIGZpeGVkLlxyXG4gICAgICAqIFVzYWdlOk9iamVjdC5leHRlbmQoe30sIG9iakEsIG9iakIpXHJcbiAgICAgICovXHJcbiAgICAgIGZ1bmN0aW9uIGV4dGVuZE9wdGlvbnMob3V0KSB7XHJcbiAgICAgICAgb3V0ID0gb3V0IHx8IHt9O1xyXG5cclxuICAgICAgICBmb3IgKHZhciBpID0gMTsgaSA8IGFyZ3VtZW50cy5sZW5ndGg7IGkrKykge1xyXG4gICAgICAgICAgdmFyIG9iaiA9IGFyZ3VtZW50c1tpXTtcclxuXHJcbiAgICAgICAgICBpZiAoIW9iailcclxuICAgICAgICAgICAgY29udGludWU7XHJcblxyXG4gICAgICAgICAgZm9yICh2YXIga2V5IGluIG9iaikge1xyXG4gICAgICAgICAgICBpZiAob2JqLmhhc093blByb3BlcnR5KGtleSkpIHtcclxuICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShvYmpba2V5XSkpIHtcclxuICAgICAgICAgICAgICAgIG91dFtrZXldID0gb2JqW2tleV0uc2xpY2UoKTtcclxuICAgICAgICAgICAgICB9IGVsc2UgaW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IGZ1bmN0aW9uKGV2ZW50KXtcclxuICAgICAgICAgIGlmKGV2ZW50LmtleSA9PSBcIlNoaWZ0XCIpIHtcclxuICAgICAgICAgICAgc2hpZnRLZXlEb3duID0gdHJ1ZTtcclxuICAgICAgICAgIH1cclxuICAgICAgICB9KTtcclxuICAgICAgICBkb2N1bWVudC5hZGRFdmVudExpc3RlbmVyKCdrZXl1cCcsIGZ1bmN0aW9uKGV2ZW50KXtcclxuICAgICAgICAgIGlmKGV2ZW50LmtleSA9PSBcIlNoaWZ0XCIpIHtcclxuICAgICAgICAgICAgc2hpZnRLZXlEb3duID0gZmFsc2U7XHJcbiAgICAgICAgICB9XHJcbiAgICAgICAgfSk7XHJcbiAgICAgICAgLy9TZWxlY3QgdGhlIGRlc2lyZWQgbmVpZ2hib3JzIGFmdGVyIHRhcGhvbGQtYW5kLWZyZWVcclxuICAgICAgICBjeS5vbigndGFwaG9sZCcsICdub2RlJywgZnVuY3Rpb24oZXZlbnQpe1xyXG4gICAgICAgICAgdmFyIHRhcmdldCA9IGV2ZW50LnRhcmdldCB8fCBldmVudC5jeVRhcmdldDtcclxuICAgICAgICAgIHZhciB0YXBoZWxkID0gZmFsc2U7XHJcbiAgICAgICAgICB2YXIgbmVpZ2hib3Job29kO1xyXG4gICAgICAgICAgdmFyIHRpbWVvdXQgPSBzZXRUaW1lb3V0KGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgICAgIGlmKHNoaWZ0S2V5RG93bil7XHJcbiAgICAgICAgICAgICAgY3kuZWxlbWVudHMoKS51bnNlbGVjdCgpO1xyXG4gICAgICAgICAgICAgIG5laWdoYm9yaG9vZCA9IG9wdGlvbnMubmVpZ2hib3IodGFyZ2V0KTtcclxuICAgICAgICAgICAgICBpZihuZWlnaGJvcmhvb2QpXHJcbiAgICAgICAgICAgICAgICBuZWlnaGJvcmhvb2Quc2VsZWN0KCk7XHJcbiAgICAgICAgICAgICAgdGFyZ2V0LmxvY2soKTtcclxuICAgICAgICAgICAgICB0YXBoZWxkID0gdHJ1ZTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgfSwgb3B0aW9ucy5uZWlnaGJvclNlbGVjdFRpbWUgLSA1MDApO1xyXG4gICAgICAgICAgY3kub24oJ2ZyZWUnLCAnbm9kZScsIGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgICAgIHZhciB0YXJnZXRUYXBoZWxkID0gZXZlbnQudGFyZ2V0IHx8IGV2ZW50LmN5VGFyZ2V0O1xyXG4gICAgICAgICAgICBpZih0YXJnZXQgPT0gdGFyZ2V0VGFwaGVsZCAmJiB0YXBoZWxkID09PSB0cnVlKXtcclxuICAgICAgICAgICAgICB0YXBoZWxkID0gZmFsc2U7XHJcbiAgICAgICAgICAgICAgaWYobmVpZ2hib3Job29kKVxyXG4gICAgICAgICAgICAgICAgbmVpZ2hib3Job29kLnNlbGVjdCgpO1xyXG4gICAgICAgICAgICAgIHRhcmdldC51bmxvY2soKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBlbHNle1xyXG4gICAgICAgICAgICAgIGNsZWFyVGltZW91dCh0aW1lb3V0KTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgfSk7XHJcbiAgICAgICAgICBjeS5vbignZHJhZycsICdub2RlJywgZnVuY3Rpb24oKXtcclxuICAgICAgICAgICAgdmFyIHRhcmdldERyYWdnZWQgPSBldmVudC50YXJnZXQgfHwgZXZlbnQuY3lUYXJnZXQ7XHJcbiAgICAgICAgICAgIGlmKHRhcmdldCA9PSB0YXJnZXREcmFnZ2VkICYmIHRhcGhlbGQgPT09IGZhbHNlKXtcclxuICAgICAgICAgICAgICBjbGVhclRpbWVvdXQodGltZW91dCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgIH0pXHJcbiAgICAgICAgfSk7XHJcbiAgICAgIH1cclxuXHJcbiAgICAgIC8vIHJldHVybiB0aGUgaW5zdGFuY2Ugb2YgZXh0ZW5zaW9uXHJcbiAgICAgIHJldHVybiB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pKyspIHtcclxuICAgICAgICAgIHZhciBvYmogPSBhcmd1bWVudHNbaV07XHJcblxyXG4gICAgICAgICAgaWYgKCFvYmopXHJcbiAgICAgICAgICAgIGNvbnRpbnVlO1xyXG5cclxuICAgICAgICAgIGZvciAodmFyIGtleSBpbiBvYmopIHtcclxuICAgICAgICAgICAgaWYgKG9iai5oYXNPd25Qcm9wZXJ0eShrZXkpKSB7XHJcbiAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkob2JqW2tleV0pKSB7XHJcbiAgICAgICAgICAgICAgICBvdXRba2V5XSA9IG9ialtrZXldLnNsaWNlKCk7XHJcbiAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2Ygb2JqW2tleV0gPT09ICdvYmplY3QnKSB7XHJcbiAgICAgICAgICAgICAgICBvdXRba2V5XSA9IGV4dGVuZE9wdGlvbnMob3V0W2tleV0sIG9ialtrZXldKTtcclxuICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgb3V0W2tleV0gPSBvYmpba2V5XTtcclxuICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiBvdXQ7XHJcbiAgICAgIH07XHJcblxyXG4gICAgICBvcHRpb25zID0gZXh0ZW5kT3B0aW9ucyh7fSwgb3B0aW9ucywgb3B0cyk7XHJcblxyXG4gICAgICAvLyBjcmVhdGUgYSB2aWV3IHV0aWxpdGllcyBpbnN0YW5jZVxyXG4gICAgICB2YXIgaW5zdGFuY2UgPSB2aWV3VXRpbGl0aWVzKGN5LCBvcHRpb25zKTtcclxuXHJcbiAgICAgIGlmIChjeS51bmRvUmVkbykge1xyXG4gICAgICAgIHZhciB1ciA9IGN5LnVuZG9SZWRvKG51bGwsIHRydWUpO1xyXG4gICAgICAgIHVuZG9SZWRvKGN5LCB1ciwgaW5zdGFuY2UpO1xyXG4gICAgICB9XHJcblxyXG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ID0gc2V0VGltZW91dChmdW5jdGlvbigpe1xyXG4gICAgICAgICAgICBpZihzaGlmdEtleURvd24pe1xyXG4gICAgICAgICAgICAgIGN5LmVsZW1lbnRzKCkudW5zZWxlY3QoKTtcclxuICAgICAgICAgICAgICBuZWlnaGJvcmhvb2QgPSBvcHRpb25zLm5laWdoYm9yKHRhcmdldCk7XHJcbiAgICAgICAgICAgICAgaWYobmVpZ2hib3Job29kKVxyXG4gICAgICAgICAgICAgICAgbmVpZ2hib3Job29kLnNlbGVjdCgpO1xyXG4gICAgICAgICAgICAgIHRhcmdldC5sb2NrKCk7XHJcbiAgICAgICAgICAgICAgdGFwaGVsZCA9IHRydWU7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgIH0sIG9wdGlvbnMubmVpZ2hib3JTZWxlY3RUaW1lIC0gNTAwKTtcclxuICAgICAgICAgIGN5Lm9uKCdmcmVlJywgJ25vZGUnLCBmdW5jdGlvbigpe1xyXG4gICAgICAgICAgICB2YXIgdGFyZ2V0VGFwaGVsZCA9IGV2ZW50LnRhcmdldCB8fCBldmVudC5jeVRhcmdldDtcclxuICAgICAgICAgICAgaWYodGFyZ2V0ID09IHRhcmdldFRhcGhlbGQgJiYgdGFwaGVsZCA9PT0gdHJ1ZSl7XHJcbiAgICAgICAgICAgICAgdGFwaGVsZCA9IGZhbHNlO1xyXG4gICAgICAgICAgICAgIGlmKG5laWdoYm9yaG9vZClcclxuICAgICAgICAgICAgICAgIG5laWdoYm9yaG9vZC5zZWxlY3QoKTtcclxuICAgICAgICAgICAgICB0YXJnZXQudW5sb2NrKCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgZWxzZXtcclxuICAgICAgICAgICAgICBjbGVhclRpbWVvdXQodGltZW91dCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgY3kub24oJ2RyYWcnLCAnbm9kZScsIGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgICAgIHZh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4gICAgICAgIHpvb206IHpvb21MZXZlbCxcclxuICAgICAgICBkdXJhdGlvbjogb3B0aW9ucy56b29tQW5pbWF0aW9uRHVyYXRpb24sXHJcbiAgICAgICAgY29tcGxldGU6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgIGlmIChjYWxsYmFjaykge1xyXG4gICAgICAgICAgICBjYWxsYmFjaygpO1xyXG4gICAgICAgICAgfVxyXG4gICAgICAgICAgY3kuYXV0b3Vuc2VsZWN0aWZ5KGZhbHNlKTtcclxuICAgICAgICB9XHJcbiAgICAgIH0pO1xyXG4gICAgfSk7XHJcbiAgfTtcclxuXHJcbiAgaW5zdGFuY2UuZGlzYWJsZU1hcnF1ZWVab29tID0gZnVuY3Rpb24gKCkge1xyXG4gICAgY3kub2ZmKCd0YXBzdGFydCcsIHRhYlN0YXJ0SGFuZGxlcik7XHJcbiAgICBjeS5vZmYoJ3RhcGVuZCcsIHRhYkVuZEhhbmRsZXIpO1xyXG4gICAgY3kuYXV0b3Vuc2VsZWN0aWZ5KGZhbHNlKTtcclxuICB9O1xyXG5cclxuICAvLyByZXR1cm4gdGhlIGluc3RhbmNlXHJcbiAgcmV0dXJuIGluc3RhbmNlO1xyXG59O1xyXG5cclxubW9kdWxlLmV4cG9ydHMgPSB2aWV3VXRpbGl0aWVzO1xyXG4iXX0= diff --git a/src/view-utilities.js b/src/view-utilities.js index 9e25215..47eb771 100644 --- a/src/view-utilities.js +++ b/src/view-utilities.js @@ -1,11 +1,15 @@ var viewUtilities = function (cy, options) { var classNames4Styles = []; + // give a unique name for each unique style EVER added + var totStyleCnt = 0; init(); function init() { // add provided styles for (var i = 0; i < options.highlightStyles.length; i++) { - classNames4Styles.push('__highligtighted__' + i); + var s = '__highligtighted__' + totStyleCnt; + classNames4Styles.push(s); + totStyleCnt++; updateCyStyle(i); } @@ -150,8 +154,9 @@ var viewUtilities = function (cy, options) { instance.addHighlightStyle = function (nodeStyle, edgeStyle) { var o = { node: nodeStyle, edge: edgeStyle }; options.highlightStyles.push(o); - var s = '__highligtighted__' + (options.highlightStyles.length - 1); + var s = '__highligtighted__' + totStyleCnt; classNames4Styles.push(s); + totStyleCnt++; updateCyStyle(options.highlightStyles.length - 1); addSelectionStyles(); }; From 7ff113c5c6d8de479905e93019d79f5a17f3fac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hasan=20Balc=C4=B1?= Date: Tue, 19 May 2020 16:44:40 +0300 Subject: [PATCH 6/6] Update LICENCE --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 5d0faf1..0512bf5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 iVis@Bilkent +Copyright (c) 2017 - present, iVis@Bilkent. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal