Browse Source

Removes redundant .eslintrc from graph3d, lints the rest of the code … (#3363)

* Removes redundant .eslintrc from graph3d, lints the rest of the code base, and enables valid-jsdoc lint rule

* Corrects lint violations
revert-3409-performance
macleodbroad-wf 7 years ago
committed by Yotam Berkowitz
parent
commit
d4e4e9fa07
50 changed files with 743 additions and 486 deletions
  1. +7
    -7
      .eslintrc
  2. +27
    -22
      lib/DOMutil.js
  3. +5
    -3
      lib/DataSet.js
  4. +2
    -1
      lib/DataView.js
  5. +0
    -1
      lib/Queue.js
  6. +0
    -40
      lib/graph3d/.eslintrc
  7. +1
    -0
      lib/hammerUtil.js
  8. +2
    -0
      lib/module/hammer.js
  9. +7
    -2
      lib/network/CachedImage.js
  10. +17
    -15
      lib/network/Images.js
  11. +1
    -1
      lib/network/Network.js
  12. +10
    -2
      lib/network/NetworkUtil.js
  13. +4
    -0
      lib/network/modules/Canvas.js
  14. +9
    -3
      lib/network/modules/CanvasRenderer.js
  15. +60
    -43
      lib/network/modules/Clustering.js
  16. +3
    -1
      lib/network/modules/EdgesHandler.js
  17. +1
    -1
      lib/network/modules/Groups.js
  18. +15
    -8
      lib/network/modules/InteractionHandler.js
  19. +13
    -11
      lib/network/modules/KamadaKawai.js
  20. +58
    -25
      lib/network/modules/LayoutEngine.js
  21. +29
    -16
      lib/network/modules/ManipulationSystem.js
  22. +15
    -11
      lib/network/modules/NodesHandler.js
  23. +12
    -5
      lib/network/modules/PhysicsEngine.js
  24. +22
    -18
      lib/network/modules/SelectionHandler.js
  25. +3
    -4
      lib/network/modules/View.js
  26. +7
    -5
      lib/network/modules/components/Edge.js
  27. +16
    -12
      lib/network/modules/components/Node.js
  28. +23
    -2
      lib/network/modules/components/edges/BezierEdgeDynamic.js
  29. +24
    -2
      lib/network/modules/components/edges/BezierEdgeStatic.js
  30. +5
    -2
      lib/network/modules/components/edges/CubicBezierEdge.js
  31. +3
    -2
      lib/network/modules/components/edges/StraightEdge.js
  32. +7
    -9
      lib/network/modules/components/edges/util/BezierEdgeBase.js
  33. +3
    -0
      lib/network/modules/components/edges/util/CubicBezierEdgeBase.js
  34. +28
    -13
      lib/network/modules/components/edges/util/EdgeBase.js
  35. +1
    -1
      lib/network/modules/components/nodes/util/CircleImageBase.js
  36. +16
    -1
      lib/network/modules/components/nodes/util/NodeBase.js
  37. +26
    -27
      lib/network/modules/components/physics/BarnesHutSolver.js
  38. +5
    -0
      lib/network/modules/components/physics/CentralGravitySolver.js
  39. +6
    -0
      lib/network/modules/components/physics/FA2BasedCentralGravitySolver.js
  40. +5
    -5
      lib/network/modules/components/physics/FA2BasedRepulsionSolver.js
  41. +1
    -0
      lib/network/modules/components/physics/RepulsionSolver.js
  42. +3
    -3
      lib/network/modules/components/physics/SpringSolver.js
  43. +85
    -49
      lib/network/modules/components/shared/Label.js
  44. +36
    -0
      lib/network/shapes.js
  45. +1
    -1
      lib/shared/Activator.js
  46. +12
    -12
      lib/shared/ColorPicker.js
  47. +41
    -40
      lib/shared/Configurator.js
  48. +15
    -14
      lib/shared/Validator.js
  49. +1
    -1
      lib/timeline/component/Group.js
  50. +50
    -45
      lib/util.js

+ 7
- 7
.eslintrc View File

@ -26,13 +26,13 @@
"ClassDeclaration": false, "ClassDeclaration": false,
"ArrowFunctionExpression": false "ArrowFunctionExpression": false
} }
}]
// "valid-jsdoc": [2, {
// "requireReturnDescription": false,
// "requireReturn": false,
// "requireParamDescription": false,
// "requireReturnType": false
// }],
}],
"valid-jsdoc": [2, {
"requireReturnDescription": false,
"requireReturn": false,
"requireParamDescription": false,
"requireReturnType": false
}],
} }
// To flag presence of console.log without breaking linting: // To flag presence of console.log without breaking linting:
//"no-console": ["warn", { allow: ["warn", "error"] }], //"no-console": ["warn", { allow: ["warn", "error"] }],

+ 27
- 22
lib/DOMutil.js View File

@ -2,7 +2,7 @@
/** /**
* this prepares the JSON container for allocating SVG elements * this prepares the JSON container for allocating SVG elements
* @param JSONcontainer
* @param {Object} JSONcontainer
* @private * @private
*/ */
exports.prepareElements = function(JSONcontainer) { exports.prepareElements = function(JSONcontainer) {
@ -19,7 +19,7 @@ exports.prepareElements = function(JSONcontainer) {
* this cleans up all the unused SVG elements. By asking for the parentNode, we only need to supply the JSON container from * this cleans up all the unused SVG elements. By asking for the parentNode, we only need to supply the JSON container from
* which to remove the redundant elements. * which to remove the redundant elements.
* *
* @param JSONcontainer
* @param {Object} JSONcontainer
* @private * @private
*/ */
exports.cleanupElements = function(JSONcontainer) { exports.cleanupElements = function(JSONcontainer) {
@ -38,22 +38,22 @@ exports.cleanupElements = function(JSONcontainer) {
/** /**
* Ensures that all elements are removed first up so they can be recreated cleanly * Ensures that all elements are removed first up so they can be recreated cleanly
* @param JSONcontainer
* @param {Object} JSONcontainer
*/ */
exports.resetElements = function(JSONcontainer) { exports.resetElements = function(JSONcontainer) {
exports.prepareElements(JSONcontainer); exports.prepareElements(JSONcontainer);
exports.cleanupElements(JSONcontainer); exports.cleanupElements(JSONcontainer);
exports.prepareElements(JSONcontainer); exports.prepareElements(JSONcontainer);
}
};
/** /**
* Allocate or generate an SVG element if needed. Store a reference to it in the JSON container and draw it in the svgContainer * Allocate or generate an SVG element if needed. Store a reference to it in the JSON container and draw it in the svgContainer
* the JSON container and the SVG container have to be supplied so other svg containers (like the legend) can use this. * the JSON container and the SVG container have to be supplied so other svg containers (like the legend) can use this.
* *
* @param elementType
* @param JSONcontainer
* @param svgContainer
* @returns {*}
* @param {String} elementType
* @param {Object} JSONcontainer
* @param {Object} svgContainer
* @returns {Element}
* @private * @private
*/ */
exports.getSVGElement = function (elementType, JSONcontainer, svgContainer) { exports.getSVGElement = function (elementType, JSONcontainer, svgContainer) {
@ -86,11 +86,11 @@ exports.getSVGElement = function (elementType, JSONcontainer, svgContainer) {
* Allocate or generate an SVG element if needed. Store a reference to it in the JSON container and draw it in the svgContainer * Allocate or generate an SVG element if needed. Store a reference to it in the JSON container and draw it in the svgContainer
* the JSON container and the SVG container have to be supplied so other svg containers (like the legend) can use this. * the JSON container and the SVG container have to be supplied so other svg containers (like the legend) can use this.
* *
* @param elementType
* @param JSONcontainer
* @param DOMContainer
* @param {String} elementType
* @param {Object} JSONcontainer
* @param {Element} DOMContainer
* @param {Element} insertBefore
* @returns {*} * @returns {*}
* @private
*/ */
exports.getDOMElement = function (elementType, JSONcontainer, DOMContainer, insertBefore) { exports.getDOMElement = function (elementType, JSONcontainer, DOMContainer, insertBefore) {
var element; var element;
@ -135,13 +135,13 @@ exports.getDOMElement = function (elementType, JSONcontainer, DOMContainer, inse
* The reason the JSONcontainer and the target SVG svgContainer have to be supplied is so the legend can use these functions * The reason the JSONcontainer and the target SVG svgContainer have to be supplied is so the legend can use these functions
* as well. * as well.
* *
* @param x
* @param y
* @param groupTemplate: A template containing the necessary information to draw the datapoint e.g., {style: 'circle', size: 5, className: 'className' }
* @param JSONcontainer
* @param svgContainer
* @param labelObj
* @returns {*}
* @param {Number} x
* @param {Number} y
* @param {Object} groupTemplate: A template containing the necessary information to draw the datapoint e.g., {style: 'circle', size: 5, className: 'className' }
* @param {Object} JSONcontainer
* @param {Object} svgContainer
* @param {Object} labelObj
* @returns {vis.PointItem}
*/ */
exports.drawPoint = function(x, y, groupTemplate, JSONcontainer, svgContainer, labelObj) { exports.drawPoint = function(x, y, groupTemplate, JSONcontainer, svgContainer, labelObj) {
var point; var point;
@ -192,9 +192,14 @@ exports.drawPoint = function(x, y, groupTemplate, JSONcontainer, svgContainer, l
/** /**
* draw a bar SVG element centered on the X coordinate * draw a bar SVG element centered on the X coordinate
* *
* @param x
* @param y
* @param className
* @param {Number} x
* @param {Number} y
* @param {Number} width
* @param {Number} height
* @param {String} className
* @param {Object} JSONcontainer
* @param {Object} svgContainer
* @param {string} style
*/ */
exports.drawBar = function (x, y, width, height, className, JSONcontainer, svgContainer, style) { exports.drawBar = function (x, y, width, height, className, JSONcontainer, svgContainer, style) {
if (height != 0) { if (height != 0) {

+ 5
- 3
lib/DataSet.js View File

@ -3,6 +3,7 @@ var Queue = require('./Queue');
/** /**
* DataSet * DataSet
* // TODO: add a DataSet constructor DataSet(data, options)
* *
* Usage: * Usage:
* var dataSet = new DataSet({ * var dataSet = new DataSet({
@ -42,7 +43,6 @@ var Queue = require('./Queue');
* - {number} delay Delay in ms, null by default * - {number} delay Delay in ms, null by default
* - {number} max Maximum number of entries in the queue, Infinity by default * - {number} max Maximum number of entries in the queue, Infinity by default
* @constructor DataSet * @constructor DataSet
* // TODO: add a DataSet constructor DataSet(data, options)
*/ */
function DataSet (data, options) { function DataSet (data, options) {
// correctly read optional arguments // correctly read optional arguments
@ -89,13 +89,12 @@ function DataSet (data, options) {
} }
/** /**
* @param {Object} [options] Available options:
* @param {Object} options Available options:
* {Object} queue Queue changes to the DataSet, * {Object} queue Queue changes to the DataSet,
* flush them all at once. * flush them all at once.
* Queue options: * Queue options:
* - {number} delay Delay in ms, null by default * - {number} delay Delay in ms, null by default
* - {number} max Maximum number of entries in the queue, Infinity by default * - {number} max Maximum number of entries in the queue, Infinity by default
* @param options
*/ */
DataSet.prototype.setOptions = function(options) { DataSet.prototype.setOptions = function(options) {
if (options && options.queue !== undefined) { if (options && options.queue !== undefined) {
@ -319,6 +318,8 @@ DataSet.prototype.update = function (data, senderId) {
* {String[]} [fields] field names to be returned * {String[]} [fields] field names to be returned
* {function} [filter] filter items * {function} [filter] filter items
* {String | function} [order] Order the items by a field name or custom sort function. * {String | function} [order] Order the items by a field name or custom sort function.
* @param {Array} args
* @returns {DataSet}
* @throws Error * @throws Error
*/ */
DataSet.prototype.get = function (args) { // eslint-disable-line no-unused-vars DataSet.prototype.get = function (args) { // eslint-disable-line no-unused-vars
@ -509,6 +510,7 @@ DataSet.prototype.getIds = function (options) {
/** /**
* Returns the DataSet itself. Is overwritten for example by the DataView, * Returns the DataSet itself. Is overwritten for example by the DataView,
* which returns the DataSet it is connected to instead. * which returns the DataSet it is connected to instead.
* @returns {DataSet}
*/ */
DataSet.prototype.getDataSet = function () { DataSet.prototype.getDataSet = function () {
return this; return this;

+ 2
- 1
lib/DataView.js View File

@ -156,7 +156,8 @@ DataView.prototype.refresh = function () {
* {Array | DataTable} [data] If provided, items will be appended to this * {Array | DataTable} [data] If provided, items will be appended to this
* array or table. Required in case of Google * array or table. Required in case of Google
* DataTable. * DataTable.
* @param args
* @param {Array} args
* @return {DataSet|DataView}
*/ */
DataView.prototype.get = function (args) { // eslint-disable-line no-unused-vars DataView.prototype.get = function (args) { // eslint-disable-line no-unused-vars
var me = this; var me = this;

+ 0
- 1
lib/Queue.js View File

@ -35,7 +35,6 @@ function Queue(options) {
* - max: number When the queue exceeds the given maximum number * - max: number When the queue exceeds the given maximum number
* of entries, the queue is flushed automatically. * of entries, the queue is flushed automatically.
* Default value of max is Infinity. * Default value of max is Infinity.
* @param options
*/ */
Queue.prototype.setOptions = function (options) { Queue.prototype.setOptions = function (options) {
if (options && typeof options.delay !== 'undefined') { if (options && typeof options.delay !== 'undefined') {

+ 0
- 40
lib/graph3d/.eslintrc View File

@ -1,40 +0,0 @@
{
"env": {
"browser": true,
"es6": true,
"node": true,
"mocha": true
},
"parserOptions": {
"sourceType": "module",
},
"extends": "eslint:recommended",
// For the full list of rules, see: http://eslint.org/docs/rules/
"rules": {
"complexity": [2, 55],
"max-statements": [2, 115],
"no-unreachable": 1,
"no-useless-escape": 0,
"no-console": 0,
"require-jsdoc": ["error", {
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true,
"ArrowFunctionExpression": true
}
}],
"valid-jsdoc": [2, {
"requireReturnDescription": false,
"requireReturn": false,
"requireParamDescription": false,
"requireReturnType": true
}],
}
// To flag presence of console.log without breaking linting:
//"no-console": ["warn", { allow: ["warn", "error"] }],
}

+ 1
- 0
lib/hammerUtil.js View File

@ -17,6 +17,7 @@ exports.onTouch = function (hammer, callback) {
* Register a release event, taking place after a gesture * Register a release event, taking place after a gesture
* @param {Hammer} hammer A hammer instance * @param {Hammer} hammer A hammer instance
* @param {function} callback Callback, called as callback(event) * @param {function} callback Callback, called as callback(event)
* @returns {*}
*/ */
exports.onRelease = function (hammer, callback) { exports.onRelease = function (hammer, callback) {
callback.inputHandler = function (event) { callback.inputHandler = function (event) {

+ 2
- 0
lib/module/hammer.js View File

@ -2,6 +2,8 @@
* Setup a mock hammer.js object, for unit testing. * Setup a mock hammer.js object, for unit testing.
* *
* Inspiration: https://github.com/uber/deck.gl/pull/658 * Inspiration: https://github.com/uber/deck.gl/pull/658
*
* @returns {{on: noop, off: noop, destroy: noop, emit: noop, get: get}}
*/ */
function hammerMock() { function hammerMock() {
const noop = () => {}; const noop = () => {};

+ 7
- 2
lib/network/CachedImage.js View File

@ -102,8 +102,12 @@ class CachedImage {
* *
* Credits to 'Alex de Mulder' for original implementation. * Credits to 'Alex de Mulder' for original implementation.
* *
* ctx {Context} context on which to draw zoomed image
* factor {Float} scale factor at which to draw
* @param {CanvasRenderingContext2D} ctx context on which to draw zoomed image
* @param {Float} factor scale factor at which to draw
* @param {Number} left
* @param {Number} top
* @param {Number} width
* @param {Number} height
*/ */
drawImageAtPosition(ctx, factor, left, top, width, height) { drawImageAtPosition(ctx, factor, left, top, width, height) {
if (factor > 2 && this.initialized()) { if (factor > 2 && this.initialized()) {
@ -137,6 +141,7 @@ class CachedImage {
* *
* Source: http://stackoverflow.com/a/1977898/1223531 * Source: http://stackoverflow.com/a/1977898/1223531
* *
* @returns {boolean}
* @private * @private
*/ */
_isImageOk() { _isImageOk() {

+ 17
- 15
lib/network/Images.js View File

@ -2,8 +2,8 @@ import CachedImage from './CachedImage';
/** /**
* @class Images
* This class loads images and keeps them stored. * This class loads images and keeps them stored.
* @class Images
*/ */
class Images { class Images {
constructor(callback){ constructor(callback){
@ -16,7 +16,7 @@ class Images {
/** /**
* @param {string} url The original Url that failed to load, if the broken image is successfully loaded it will be added to the cache using this Url as the key so that subsequent requests for this Url will return the broken image * @param {string} url The original Url that failed to load, if the broken image is successfully loaded it will be added to the cache using this Url as the key so that subsequent requests for this Url will return the broken image
* @param {string} brokenUrl Url the broken image to try and load * @param {string} brokenUrl Url the broken image to try and load
* @return {Image} imageToLoadBrokenUrlOn The image object
* @param {Image} imageToLoadBrokenUrlOn The image object
*/ */
_tryloadBrokenUrl (url, brokenUrl, imageToLoadBrokenUrlOn) { _tryloadBrokenUrl (url, brokenUrl, imageToLoadBrokenUrlOn) {
//If these parameters aren't specified then exit the function because nothing constructive can be done //If these parameters aren't specified then exit the function because nothing constructive can be done
@ -36,10 +36,12 @@ class Images {
imageToLoadBrokenUrlOn.image.src = brokenUrl; imageToLoadBrokenUrlOn.image.src = brokenUrl;
} }
/**
* @return {Image} imageToRedrawWith The images that will be passed to the callback when it is invoked
*/
_redrawWithImage (imageToRedrawWith) {
/**
*
* @param {vis.Image} imageToRedrawWith
* @private
*/
_redrawWithImage (imageToRedrawWith) {
if (this.callback) { if (this.callback) {
this.callback(imageToRedrawWith); this.callback(imageToRedrawWith);
} }
@ -50,7 +52,7 @@ class Images {
* @param {string} brokenUrl Url of an image to use if the url image is not found * @param {string} brokenUrl Url of an image to use if the url image is not found
* @return {Image} img The image object * @return {Image} img The image object
*/ */
load (url, brokenUrl, id) { // eslint-disable-line no-unused-vars
load (url, brokenUrl) {
//Try and get the image from the cache, if successful then return the cached image //Try and get the image from the cache, if successful then return the cached image
var cachedImage = this.images[url]; var cachedImage = this.images[url];
if (cachedImage) return cachedImage; if (cachedImage) return cachedImage;
@ -75,7 +77,7 @@ class Images {
console.error("Could not load image:", url); console.error("Could not load image:", url);
//Try and load the image specified by the brokenUrl using //Try and load the image specified by the brokenUrl using
this._tryloadBrokenUrl(url, brokenUrl, img); this._tryloadBrokenUrl(url, brokenUrl, img);
}
};
//Set the source of the image to the url, this is what actually kicks off the loading of the image //Set the source of the image to the url, this is what actually kicks off the loading of the image
img.image.src = url; img.image.src = url;
@ -85,13 +87,13 @@ class Images {
} }
/**
* IE11 fix -- thanks dponch!
*
* Local helper function
*
* @private
*/
/**
* IE11 fix -- thanks dponch!
*
* Local helper function
* @param {vis.Image} imageToCache
* @private
*/
_fixImageCoordinates(imageToCache) { _fixImageCoordinates(imageToCache) {
if (imageToCache.width === 0) { if (imageToCache.width === 0) {
document.body.appendChild(imageToCache); document.body.appendChild(imageToCache);

+ 1
- 1
lib/network/Network.js View File

@ -29,7 +29,6 @@ var KamadaKawai = require("./modules/KamadaKawai.js").default;
/** /**
* @constructor Network
* Create a network visualization, displaying nodes and edges. * Create a network visualization, displaying nodes and edges.
* *
* @param {Element} container The DOM element in which the Network will * @param {Element} container The DOM element in which the Network will
@ -38,6 +37,7 @@ var KamadaKawai = require("./modules/KamadaKawai.js").default;
* {Array} nodes * {Array} nodes
* {Array} edges * {Array} edges
* @param {Object} options Options * @param {Object} options Options
* @constructor Network
*/ */
function Network(container, data, options) { function Network(container, data, options) {
if (!(this instanceof Network)) { if (!(this instanceof Network)) {

+ 10
- 2
lib/network/NetworkUtil.js View File

@ -4,6 +4,10 @@ class NetworkUtil {
/** /**
* Find the center position of the network considering the bounding boxes * Find the center position of the network considering the bounding boxes
*
* @param {Array<vis.Node>} allNodes
* @param {Array<vis.Node>} [specificNodes=[]]
* @returns {{minX: number, maxX: number, minY: number, maxY: number}}
*/ */
static getRange(allNodes, specificNodes = []) { static getRange(allNodes, specificNodes = []) {
var minY = 1e9, maxY = -1e9, minX = 1e9, maxX = -1e9, node; var minY = 1e9, maxY = -1e9, minX = 1e9, maxX = -1e9, node;
@ -33,6 +37,10 @@ class NetworkUtil {
/** /**
* Find the center position of the network * Find the center position of the network
*
* @param {Array<vis.Node>} allNodes
* @param {Array<vis.Node>} [specificNodes=[]]
* @returns {{minX: number, maxX: number, minY: number, maxY: number}}
*/ */
static getRangeCore(allNodes, specificNodes = []) { static getRangeCore(allNodes, specificNodes = []) {
var minY = 1e9, maxY = -1e9, minX = 1e9, maxX = -1e9, node; var minY = 1e9, maxY = -1e9, minX = 1e9, maxX = -1e9, node;
@ -73,8 +81,8 @@ class NetworkUtil {
/** /**
* This returns a clone of the options or options of the edge or node to be used for construction of new edges or check functions for new nodes. * This returns a clone of the options or options of the edge or node to be used for construction of new edges or check functions for new nodes.
* @param item
* @param type
* @param {vis.Item} item
* @param {'node'|undefined} type
* @returns {{}} * @returns {{}}
*/ */
static cloneOptions(item, type) { static cloneOptions(item, type) {

+ 4
- 0
lib/network/modules/Canvas.js View File

@ -87,6 +87,8 @@ class Canvas {
/** /**
* Get and store the cameraState * Get and store the cameraState
*
* @param {Number} [pixelRatio=this.pixelRatio]
* @private * @private
*/ */
_getCameraState(pixelRatio = this.pixelRatio) { _getCameraState(pixelRatio = this.pixelRatio) {
@ -246,6 +248,7 @@ class Canvas {
* or '50%') * or '50%')
* @param {string} height Height in pixels or percentage (for example '400px' * @param {string} height Height in pixels or percentage (for example '400px'
* or '30%') * or '30%')
* @returns {boolean}
*/ */
setSize(width = this.options.width, height = this.options.height) { setSize(width = this.options.width, height = this.options.height) {
width = this._prepareValue(width); width = this._prepareValue(width);
@ -341,6 +344,7 @@ class Canvas {
/** /**
* Determine the pixel ratio for various browsers. * Determine the pixel ratio for various browsers.
* *
* @returns {number}
* @private * @private
*/ */
_determinePixelRatio() { _determinePixelRatio() {

+ 9
- 3
lib/network/modules/CanvasRenderer.js View File

@ -119,7 +119,9 @@ class CanvasRenderer {
* *
* Calls the callback when the next frame can or will be drawn. * Calls the callback when the next frame can or will be drawn.
* *
* @param delay {number} - timeout case only, wait this number of milliseconds
* @param {function} callback
* @param {number} delay - timeout case only, wait this number of milliseconds
* @returns {function|undefined}
* @private * @private
*/ */
_requestNextFrame(callback, delay) { _requestNextFrame(callback, delay) {
@ -189,8 +191,6 @@ class CanvasRenderer {
/** /**
* Redraw the network with the current data * Redraw the network with the current data
* @param hidden | Used to get the first estimate of the node sizes.
* Only the nodes are drawn after which they are quickly drawn over.
* @private * @private
*/ */
_requestRedraw() { _requestRedraw() {
@ -200,6 +200,12 @@ class CanvasRenderer {
} }
} }
/**
* Redraw the network with the current data
* @param {boolean} [hidden=false] | Used to get the first estimate of the node sizes.
* Only the nodes are drawn after which they are quickly drawn over.
* @private
*/
_redraw(hidden = false) { _redraw(hidden = false) {
if (this.allowRedraw === true) { if (this.allowRedraw === true) {
this.body.emitter.emit("initRedraw"); this.body.emitter.emit("initRedraw");

+ 60
- 43
lib/network/modules/Clustering.js View File

@ -113,8 +113,8 @@ class ClusterEngine {
/** /**
* *
* @param hubsize
* @param options
* @param {Number} hubsize
* @param {Object} options
*/ */
clusterByHubsize(hubsize, options) { clusterByHubsize(hubsize, options) {
if (hubsize === undefined) { if (hubsize === undefined) {
@ -142,10 +142,10 @@ class ClusterEngine {
/** /**
* loop over all nodes, check if they adhere to the condition and cluster if needed.
* @param options
* @param refreshData
*/
* loop over all nodes, check if they adhere to the condition and cluster if needed.
* @param {Object} options
* @param {Boolean} [refreshData=true]
*/
cluster(options = {}, refreshData = true) { cluster(options = {}, refreshData = true) {
if (options.joinCondition === undefined) {throw new Error("Cannot call clusterByNodeData without a joinCondition function in the options.");} if (options.joinCondition === undefined) {throw new Error("Cannot call clusterByNodeData without a joinCondition function in the options.");}
@ -180,9 +180,9 @@ class ClusterEngine {
/** /**
* Cluster all nodes in the network that have only X edges * Cluster all nodes in the network that have only X edges
* @param edgeCount
* @param options
* @param refreshData
* @param {Number} edgeCount
* @param {Object} options
* @param {Boolean} [refreshData=true]
*/ */
clusterByEdgeCount(edgeCount, options, refreshData = true) { clusterByEdgeCount(edgeCount, options, refreshData = true) {
options = this._checkOptions(options); options = this._checkOptions(options);
@ -256,18 +256,18 @@ class ClusterEngine {
} }
/** /**
* Cluster all nodes in the network that have only 1 edge
* @param options
* @param refreshData
*/
* Cluster all nodes in the network that have only 1 edge
* @param {Object} options
* @param {Boolean} [refreshData=true]
*/
clusterOutliers(options, refreshData = true) { clusterOutliers(options, refreshData = true) {
this.clusterByEdgeCount(1,options,refreshData); this.clusterByEdgeCount(1,options,refreshData);
} }
/** /**
* Cluster all nodes in the network that have only 2 edge * Cluster all nodes in the network that have only 2 edge
* @param options
* @param refreshData
* @param {Object} options
* @param {Boolean} [refreshData=true]
*/ */
clusterBridges(options, refreshData = true) { clusterBridges(options, refreshData = true) {
this.clusterByEdgeCount(2,options,refreshData); this.clusterByEdgeCount(2,options,refreshData);
@ -277,9 +277,9 @@ class ClusterEngine {
/** /**
* suck all connected nodes of a node into the node. * suck all connected nodes of a node into the node.
* @param nodeId
* @param options
* @param refreshData
* @param {vis.Node.id} nodeId
* @param {Object} options
* @param {Boolean} [refreshData=true]
*/ */
clusterByConnection(nodeId, options, refreshData = true) { clusterByConnection(nodeId, options, refreshData = true) {
// kill conditions // kill conditions
@ -353,10 +353,10 @@ class ClusterEngine {
* This function creates the edges that will be attached to the cluster * This function creates the edges that will be attached to the cluster
* It looks for edges that are connected to the nodes from the "outside' of the cluster. * It looks for edges that are connected to the nodes from the "outside' of the cluster.
* *
* @param childNodesObj
* @param childEdgesObj
* @param clusterNodeProperties
* @param clusterEdgeProperties
* @param {{vis.Node.id: vis.Node}} childNodesObj
* @param {{vis.Edge.id: vis.Edge}} childEdgesObj
* @param {Object} clusterNodeProperties
* @param {Object} clusterEdgeProperties
* @private * @private
*/ */
_createClusterEdges (childNodesObj, childEdgesObj, clusterNodeProperties, clusterEdgeProperties) { _createClusterEdges (childNodesObj, childEdgesObj, clusterNodeProperties, clusterEdgeProperties) {
@ -414,6 +414,8 @@ class ClusterEngine {
/** /**
* Find a cluster edge which matches the given created edge. * Find a cluster edge which matches the given created edge.
* @param {vis.Edge} createdEdge
* @returns {vis.Edge}
*/ */
var getNewEdge = function(createdEdge) { var getNewEdge = function(createdEdge) {
for (let j = 0; j < newEdges.length; j++) { for (let j = 0; j < newEdges.length; j++) {
@ -462,7 +464,7 @@ class ClusterEngine {
/** /**
* This function checks the options that can be supplied to the different cluster functions * This function checks the options that can be supplied to the different cluster functions
* for certain fields and inserts defaults if needed * for certain fields and inserts defaults if needed
* @param options
* @param {Object} options
* @returns {*} * @returns {*}
* @private * @private
*/ */
@ -590,7 +592,7 @@ class ClusterEngine {
/** /**
* Check if a node is a cluster. * Check if a node is a cluster.
* @param nodeId
* @param {vis.Node.id} nodeId
* @returns {*} * @returns {*}
*/ */
isCluster(nodeId) { isCluster(nodeId) {
@ -631,10 +633,11 @@ class ClusterEngine {
/** /**
* Open a cluster by calling this function.
* @param {String} clusterNodeId | the ID of the cluster node
* @param {Boolean} refreshData | wrap up afterwards if not true
*/
* Open a cluster by calling this function.
* @param {vis.Edge.id} clusterNodeId | the ID of the cluster node
* @param {Object} options
* @param {Boolean} refreshData | wrap up afterwards if not true
*/
openCluster(clusterNodeId, options, refreshData = true) { openCluster(clusterNodeId, options, refreshData = true) {
// kill conditions // kill conditions
if (clusterNodeId === undefined) {throw new Error("No clusterNodeId supplied to openCluster.");} if (clusterNodeId === undefined) {throw new Error("No clusterNodeId supplied to openCluster.");}
@ -811,7 +814,7 @@ class ClusterEngine {
/** /**
* Using a clustered nodeId, update with the new options * Using a clustered nodeId, update with the new options
* @param clusteredNodeId
* @param {vis.Edge.id} clusteredNodeId
* @param {object} newOptions * @param {object} newOptions
*/ */
updateClusteredNode(clusteredNodeId, newOptions) { updateClusteredNode(clusteredNodeId, newOptions) {
@ -825,7 +828,7 @@ class ClusterEngine {
/** /**
* Using a base edgeId, update all related clustered edges with the new options * Using a base edgeId, update all related clustered edges with the new options
* @param startEdgeId
* @param {vis.Edge.id} startEdgeId
* @param {object} newOptions * @param {object} newOptions
*/ */
updateEdge(startEdgeId, newOptions) { updateEdge(startEdgeId, newOptions) {
@ -843,8 +846,8 @@ class ClusterEngine {
/** /**
* Get a stack of clusterEdgeId's (+base edgeid) that a base edge is the same as. cluster edge C -> cluster edge B -> cluster edge A -> base edge(edgeId) * Get a stack of clusterEdgeId's (+base edgeid) that a base edge is the same as. cluster edge C -> cluster edge B -> cluster edge A -> base edge(edgeId)
* @param edgeId
* @returns {Array}
* @param {vis.Edge.id} edgeId
* @returns {Array<vis.Edge.id>}
*/ */
getClusteredEdges(edgeId) { getClusteredEdges(edgeId) {
let stack = []; let stack = [];
@ -862,8 +865,8 @@ class ClusterEngine {
/** /**
* Get the base edge id of clusterEdgeId. cluster edge (clusteredEdgeId) -> cluster edge B -> cluster edge C -> base edge * Get the base edge id of clusterEdgeId. cluster edge (clusteredEdgeId) -> cluster edge B -> cluster edge C -> base edge
* @param clusteredEdgeId
* @returns baseEdgeId
* @param {vis.Edge.id} clusteredEdgeId
* @returns {vis.Edge.id} baseEdgeId
* *
* TODO: deprecate in 5.0.0. Method getBaseEdges() is the correct one to use. * TODO: deprecate in 5.0.0. Method getBaseEdges() is the correct one to use.
*/ */
@ -876,8 +879,8 @@ class ClusterEngine {
/** /**
* Get all regular edges for this clustered edge id. * Get all regular edges for this clustered edge id.
* *
* @param {Number} clusteredEdgeId
* @returns {Array[Number} all baseEdgeId's under this clustered edge
* @param {vis.Edge.id} clusteredEdgeId
* @returns {Array<vis.Edge.id>} all baseEdgeId's under this clustered edge
*/ */
getBaseEdges(clusteredEdgeId) { getBaseEdges(clusteredEdgeId) {
let IdsToHandle = [clusteredEdgeId]; let IdsToHandle = [clusteredEdgeId];
@ -921,8 +924,8 @@ class ClusterEngine {
/** /**
* Get the Id the node is connected to * Get the Id the node is connected to
* @param edge
* @param nodeId
* @param {vis.Edge} edge
* @param {vis.Node.id} nodeId
* @returns {*} * @returns {*}
* @private * @private
*/ */
@ -942,6 +945,7 @@ class ClusterEngine {
* We determine how many connections denote an important hub. * We determine how many connections denote an important hub.
* We take the mean + 2*std as the important hub size. (Assuming a normal distribution of data, ~2.2%) * We take the mean + 2*std as the important hub size. (Assuming a normal distribution of data, ~2.2%)
* *
* @returns {Number}
* @private * @private
*/ */
_getHubSize() { _getHubSize() {
@ -979,7 +983,12 @@ class ClusterEngine {
/** /**
* Create an edge for the cluster representation. * Create an edge for the cluster representation.
* *
* @return {Edge} newly created clustered edge
* @param {vis.Node.id} fromId
* @param {vis.Node.id} toId
* @param {vis.Edge} baseEdge
* @param {Object} clusterEdgeProperties
* @param {Object} extraOptions
* @returns {Edge} newly created clustered edge
* @private * @private
*/ */
_createClusteredEdge(fromId, toId, baseEdge, clusterEdgeProperties, extraOptions) { _createClusteredEdge(fromId, toId, baseEdge, clusterEdgeProperties, extraOptions) {
@ -1012,9 +1021,10 @@ class ClusterEngine {
/** /**
* Add the passed child nodes and edges to the given cluster node. * Add the passed child nodes and edges to the given cluster node.
* *
* @param childNodes {Object|Node} hash of nodes or single node to add in cluster
* @param childEdges {Object|Edge} hash of edges or single edge to take into account when clustering
* @param clusterNode {Node} cluster node to add nodes and edges to
* @param {Object|Node} childNodes hash of nodes or single node to add in cluster
* @param {Object|Edge} childEdges hash of edges or single edge to take into account when clustering
* @param {Node} clusterNode cluster node to add nodes and edges to
* @param {Object} [clusterEdgeProperties]
* @private * @private
*/ */
_clusterEdges(childNodes, childEdges, clusterNode, clusterEdgeProperties) { _clusterEdges(childNodes, childEdges, clusterNode, clusterEdgeProperties) {
@ -1075,7 +1085,8 @@ class ClusterEngine {
* *
* NOTE: If you know a cleaner way to do this, please enlighten me (wimrijnders). * NOTE: If you know a cleaner way to do this, please enlighten me (wimrijnders).
* *
* @return {Node|undefined} Node instance for cluster, if present
* @param {vis.Node.id} nodeId
* @returns {Node|undefined} Node instance for cluster, if present
* @private * @private
*/ */
_getClusterNodeForNode(nodeId) { _getClusterNodeForNode(nodeId) {
@ -1095,6 +1106,10 @@ class ClusterEngine {
* Internal helper function for conditionally removing items in array * Internal helper function for conditionally removing items in array
* *
* Done like this because Array.filter() is not fully supported by all IE's. * Done like this because Array.filter() is not fully supported by all IE's.
*
* @param {Array} arr
* @param {function} callback
* @returns {Array}
* @private * @private
*/ */
_filter(arr, callback) { _filter(arr, callback) {
@ -1276,6 +1291,7 @@ class ClusterEngine {
/** /**
* Determine if node with given id is part of a cluster. * Determine if node with given id is part of a cluster.
* *
* @param {vis.Node.id} nodeId
* @return {boolean} true if part of a cluster. * @return {boolean} true if part of a cluster.
*/ */
_isClusteredNode(nodeId) { _isClusteredNode(nodeId) {
@ -1290,6 +1306,7 @@ class ClusterEngine {
* - it is directly replaced by a clustering edge * - it is directly replaced by a clustering edge
* - any of its connecting nodes is in a cluster * - any of its connecting nodes is in a cluster
* *
* @param {vis.Edge.id} edgeId
* @return {boolean} true if part of a cluster. * @return {boolean} true if part of a cluster.
*/ */
_isClusteredEdge(edgeId) { _isClusteredEdge(edgeId) {

+ 3
- 1
lib/network/modules/EdgesHandler.js View File

@ -215,7 +215,7 @@ class EdgesHandler {
/** /**
* Load edges by reading the data table * Load edges by reading the data table
* @param {Array | DataSet | DataView} edges The data containing the edges. * @param {Array | DataSet | DataView} edges The data containing the edges.
* @private
* @param {boolean} [doNotEmit=false]
* @private * @private
*/ */
setData(edges, doNotEmit = false) { setData(edges, doNotEmit = false) {
@ -264,6 +264,7 @@ class EdgesHandler {
/** /**
* Add edges * Add edges
* @param {Number[] | String[]} ids * @param {Number[] | String[]} ids
* @param {boolean} [doNotEmit=false]
* @private * @private
*/ */
add(ids, doNotEmit = false) { add(ids, doNotEmit = false) {
@ -330,6 +331,7 @@ class EdgesHandler {
/** /**
* Remove existing edges. Non existing ids will be ignored * Remove existing edges. Non existing ids will be ignored
* @param {Number[] | String[]} ids * @param {Number[] | String[]} ids
* @param {boolean} [emit=true]
* @private * @private
*/ */
remove(ids, emit = true) { remove(ids, emit = true) {

+ 1
- 1
lib/network/modules/Groups.js View File

@ -1,8 +1,8 @@
let util = require('../../util'); let util = require('../../util');
/** /**
* @class Groups
* This class can store groups and options specific for groups. * This class can store groups and options specific for groups.
* @class Groups
*/ */
class Groups { class Groups {
constructor() { constructor() {

+ 15
- 8
lib/network/modules/InteractionHandler.js View File

@ -96,7 +96,7 @@ class InteractionHandler {
/** /**
* On start of a touch gesture, store the pointer * On start of a touch gesture, store the pointer
* @param event
* @param {Event} event The event
* @private * @private
*/ */
onTouch(event) { onTouch(event) {
@ -111,6 +111,7 @@ class InteractionHandler {
/** /**
* handle tap/click event: select/unselect a node * handle tap/click event: select/unselect a node
* @param {Event} event
* @private * @private
*/ */
onTap(event) { onTap(event) {
@ -125,6 +126,7 @@ class InteractionHandler {
/** /**
* handle doubletap event * handle doubletap event
* @param {Event} event
* @private * @private
*/ */
onDoubleTap(event) { onDoubleTap(event) {
@ -136,6 +138,7 @@ class InteractionHandler {
/** /**
* handle long tap event: multi select nodes * handle long tap event: multi select nodes
* @param {Event} event
* @private * @private
*/ */
onHold(event) { onHold(event) {
@ -152,6 +155,7 @@ class InteractionHandler {
/** /**
* handle the release of the screen * handle the release of the screen
* *
* @param {Event} event
* @private * @private
*/ */
onRelease(event) { onRelease(event) {
@ -180,8 +184,9 @@ class InteractionHandler {
* *
* TODO: This is all SelectionHandler calls; the method should be moved to there. * TODO: This is all SelectionHandler calls; the method should be moved to there.
* *
* @param pointer
* @param add
* @param {{x: Number, y: Number}} pointer
* @param {Event} event
* @param {boolean} [add=false]
*/ */
checkSelectionChanges(pointer, event, add = false) { checkSelectionChanges(pointer, event, add = false) {
let previousSelection = this.selectionHandler.getSelection(); let previousSelection = this.selectionHandler.getSelection();
@ -228,9 +233,9 @@ class InteractionHandler {
/** /**
* Remove all node and edge id's from the first set that are present in the second one. * Remove all node and edge id's from the first set that are present in the second one.
* *
* @param firstSet
* @param secondSet
* @returns {{nodes: array, edges: array}}
* @param {{nodes: Array<vis.Node>, edges: Array<vis.Edge>}} firstSet
* @param {{nodes: Array<vis.Node>, edges: Array<vis.Edge>}} secondSet
* @returns {{nodes: Array<vis.Node>, edges: Array<vis.Edge>}}
* @private * @private
*/ */
_determineDifference(firstSet, secondSet) { _determineDifference(firstSet, secondSet) {
@ -258,6 +263,7 @@ class InteractionHandler {
* This function is called by onDragStart. * This function is called by onDragStart.
* It is separated out because we can then overload it for the datamanipulation system. * It is separated out because we can then overload it for the datamanipulation system.
* *
* @param {Event} event
* @private * @private
*/ */
onDragStart(event) { onDragStart(event) {
@ -317,6 +323,7 @@ class InteractionHandler {
/** /**
* handle drag event * handle drag event
* @param {Event} event
* @private * @private
*/ */
onDrag(event) { onDrag(event) {
@ -375,6 +382,7 @@ class InteractionHandler {
/** /**
* handle drag start event * handle drag start event
* @param {Event} event
* @private * @private
*/ */
onDragEnd(event) { onDragEnd(event) {
@ -399,7 +407,7 @@ class InteractionHandler {
/** /**
* Handle pinch event * Handle pinch event
* @param event
* @param {Event} event The event
* @private * @private
*/ */
onPinch(event) { onPinch(event) {
@ -420,7 +428,6 @@ class InteractionHandler {
* Zoom the network in or out * Zoom the network in or out
* @param {Number} scale a number around 1, and between 0.01 and 10 * @param {Number} scale a number around 1, and between 0.01 and 10
* @param {{x: Number, y: Number}} pointer Position on screen * @param {{x: Number, y: Number}} pointer Position on screen
* @return {Number} appliedScale scale is limited within the boundaries
* @private * @private
*/ */
zoom(scale, pointer) { zoom(scale, pointer) {

+ 13
- 11
lib/network/modules/KamadaKawai.js View File

@ -20,7 +20,7 @@ class KamadaKawai {
/** /**
* Not sure if needed but can be used to update the spring length and spring constant * Not sure if needed but can be used to update the spring length and spring constant
* @param options
* @param {Object} options
*/ */
setOptions(options) { setOptions(options) {
if (options) { if (options) {
@ -36,8 +36,9 @@ class KamadaKawai {
/** /**
* Position the system * Position the system
* @param nodesArray
* @param edgesArray
* @param {Array<vis.Node>} nodesArray
* @param {Array<vis.Edge>} edgesArray
* @param {boolean} [ignoreClusters=false]
*/ */
solve(nodesArray, edgesArray, ignoreClusters = false) { solve(nodesArray, edgesArray, ignoreClusters = false) {
// get distance matrix // get distance matrix
@ -77,7 +78,8 @@ class KamadaKawai {
/** /**
* get the node with the highest energy * get the node with the highest energy
* @returns {*[]}
* @param {boolean} ignoreClusters
* @returns {Number[]}
* @private * @private
*/ */
_getHighestEnergyNode(ignoreClusters) { _getHighestEnergyNode(ignoreClusters) {
@ -106,8 +108,8 @@ class KamadaKawai {
/** /**
* calculate the energy of a single node * calculate the energy of a single node
* @param m
* @returns {*[]}
* @param {vis.Node.id} m
* @returns {Number[]}
* @private * @private
*/ */
_getEnergy(m) { _getEnergy(m) {
@ -119,9 +121,9 @@ class KamadaKawai {
/** /**
* move the node based on it's energy * move the node based on it's energy
* the dx and dy are calculated from the linear system proposed by Kamada and Kawai * the dx and dy are calculated from the linear system proposed by Kamada and Kawai
* @param m
* @param dE_dx
* @param dE_dy
* @param {vis.Node.id} m
* @param {Number} dE_dx
* @param {Number} dE_dy
* @private * @private
*/ */
_moveNode(m, dE_dx, dE_dy) { _moveNode(m, dE_dx, dE_dy) {
@ -167,7 +169,7 @@ class KamadaKawai {
/** /**
* Create the L matrix: edge length times shortest path * Create the L matrix: edge length times shortest path
* @param D_matrix
* @param {Object} D_matrix
* @private * @private
*/ */
_createL_matrix(D_matrix) { _createL_matrix(D_matrix) {
@ -186,7 +188,7 @@ class KamadaKawai {
/** /**
* Create the K matrix: spring constants times shortest path * Create the K matrix: spring constants times shortest path
* @param D_matrix
* @param {Object} D_matrix
* @private * @private
*/ */
_createK_matrix(D_matrix) { _createK_matrix(D_matrix) {

+ 58
- 25
lib/network/modules/LayoutEngine.js View File

@ -57,6 +57,9 @@ class HierarchicalStatus {
/** /**
* Add the relation between given nodes to the current state. * Add the relation between given nodes to the current state.
*
* @param {vis.Node.id} parentNodeId
* @param {vis.Node.id} childNodeId
*/ */
addRelation(parentNodeId, childNodeId) { addRelation(parentNodeId, childNodeId) {
if (this.childrenReference[parentNodeId] === undefined) { if (this.childrenReference[parentNodeId] === undefined) {
@ -92,6 +95,7 @@ class HierarchicalStatus {
/** /**
* Return the number of separate trees in the current network. * Return the number of separate trees in the current network.
* @returns {Number}
*/ */
numTrees() { numTrees() {
return (this.treeIndex + 1); // This assumes the indexes are assigned consecitively return (this.treeIndex + 1); // This assumes the indexes are assigned consecitively
@ -100,6 +104,8 @@ class HierarchicalStatus {
/** /**
* Assign a tree id to a node * Assign a tree id to a node
* @param {vis.Node} node
* @param {String|Number} treeId
*/ */
setTreeIndex(node, treeId) { setTreeIndex(node, treeId) {
if (this.trees[node.id] === undefined) { if (this.trees[node.id] === undefined) {
@ -113,6 +119,8 @@ class HierarchicalStatus {
* Ensure level for given id is defined. * Ensure level for given id is defined.
* *
* Sets level to zero for given node id if not already present * Sets level to zero for given node id if not already present
*
* @param {vis.Node.id} nodeId
*/ */
ensureLevel(nodeId) { ensureLevel(nodeId) {
if (this.levels[nodeId] === undefined) { if (this.levels[nodeId] === undefined) {
@ -125,6 +133,8 @@ class HierarchicalStatus {
* get the maximum level of a branch. * get the maximum level of a branch.
* *
* TODO: Never entered; find a test case to test this! * TODO: Never entered; find a test case to test this!
* @param {vis.Node.id} nodeId
* @returns {Number}
*/ */
getMaxLevel(nodeId) { getMaxLevel(nodeId) {
let accumulator = {}; let accumulator = {};
@ -164,6 +174,8 @@ class HierarchicalStatus {
/** /**
* Small util method to set the minimum levels of the nodes to zero. * Small util method to set the minimum levels of the nodes to zero.
*
* @param {Array<vis.Node>} nodes
*/ */
setMinLevelToZero(nodes) { setMinLevelToZero(nodes) {
let minLevel = 1e9; let minLevel = 1e9;
@ -189,6 +201,10 @@ class HierarchicalStatus {
/** /**
* Get the min and max xy-coordinates of a given tree * Get the min and max xy-coordinates of a given tree
*
* @param {Array<vis.Node>} nodes
* @param {Number} index
* @returns {{min_x: number, max_x: number, min_y: number, max_y: number}}
*/ */
getTreeSize(nodes, index) { getTreeSize(nodes, index) {
let min_x = 1e9; let min_x = 1e9;
@ -220,6 +236,8 @@ class HierarchicalStatus {
/** /**
* Check if two nodes have the same parent(s) * Check if two nodes have the same parent(s)
* *
* @param {vis.Node} node1
* @param {vis.Node} node2
* @return true if the two nodes have a same ancestor node, false otherwise * @return true if the two nodes have a same ancestor node, false otherwise
*/ */
hasSameParent(node1, node2) { hasSameParent(node1, node2) {
@ -243,6 +261,8 @@ class HierarchicalStatus {
/** /**
* Check if two nodes are in the same tree. * Check if two nodes are in the same tree.
* *
* @param {vis.Node} node1
* @param {vis.Node} node2
* @return true if this is so, false otherwise * @return true if this is so, false otherwise
*/ */
inSameSubNetwork(node1, node2) { inSameSubNetwork(node1, node2) {
@ -252,6 +272,8 @@ class HierarchicalStatus {
/** /**
* Get a list of the distinct levels in the current network * Get a list of the distinct levels in the current network
*
* @returns {Array}
*/ */
getLevels() { getLevels() {
return Object.keys(this.distributionOrdering); return Object.keys(this.distributionOrdering);
@ -260,6 +282,9 @@ class HierarchicalStatus {
/** /**
* Add a node to the ordering per level * Add a node to the ordering per level
*
* @param {vis.Node} node
* @param {Number} level
*/ */
addToOrdering(node, level) { addToOrdering(node, level) {
if (this.distributionOrdering[level] === undefined) { if (this.distributionOrdering[level] === undefined) {
@ -788,6 +813,10 @@ class LayoutEngine {
/** /**
* Condense elements. These can be nodes or branches depending on the callback. * Condense elements. These can be nodes or branches depending on the callback.
*
* @param {function} callback
* @param {Array<Number>} levels
* @param {*} centerParents
*/ */
let shiftElementsCloser = (callback, levels, centerParents) => { let shiftElementsCloser = (callback, levels, centerParents) => {
let hier = this.hierarchical; let hier = this.hierarchical;
@ -1063,9 +1092,9 @@ class LayoutEngine {
/** /**
* This gives the space around the node. IF a map is supplied, it will only check against nodes NOT in the map. * This gives the space around the node. IF a map is supplied, it will only check against nodes NOT in the map.
* This is used to only get the distances to nodes outside of a branch. * This is used to only get the distances to nodes outside of a branch.
* @param node
* @param map
* @returns {*[]}
* @param {vis.Node} node
* @param {{vis.Node.id: vis.Node}} map
* @returns {Number[]}
* @private * @private
*/ */
_getSpaceAroundNode(node, map) { _getSpaceAroundNode(node, map) {
@ -1106,7 +1135,7 @@ class LayoutEngine {
/** /**
* We use this method to center a parent node and check if it does not cross other nodes when it does. * We use this method to center a parent node and check if it does not cross other nodes when it does.
* @param node
* @param {vis.Node} node
* @private * @private
*/ */
_centerParent(node) { _centerParent(node) {
@ -1176,8 +1205,8 @@ class LayoutEngine {
* This is a recursively called function to enumerate the branches from the largest hubs and place the nodes * This is a recursively called function to enumerate the branches from the largest hubs and place the nodes
* on a X position that ensures there will be no overlap. * on a X position that ensures there will be no overlap.
* *
* @param parentId
* @param parentLevel
* @param {vis.Node.id} parentId
* @param {Number} parentLevel
* @private * @private
*/ */
_placeBranchNodes(parentId, parentLevel) { _placeBranchNodes(parentId, parentLevel) {
@ -1228,9 +1257,9 @@ class LayoutEngine {
/** /**
* This method checks for overlap and if required shifts the branch. It also keeps records of positioned nodes. * This method checks for overlap and if required shifts the branch. It also keeps records of positioned nodes.
* Finally it will call _placeBranchNodes to place the branch nodes. * Finally it will call _placeBranchNodes to place the branch nodes.
* @param node
* @param level
* @param pos
* @param {vis.Node} node
* @param {Number} level
* @param {Number} pos
* @private * @private
*/ */
_validatePositionAndContinue(node, level, pos) { _validatePositionAndContinue(node, level, pos) {
@ -1256,7 +1285,8 @@ class LayoutEngine {
/** /**
* Receives an array with node indices and returns an array with the actual node references. * Receives an array with node indices and returns an array with the actual node references.
* Used for sorting based on node properties. * Used for sorting based on node properties.
* @param idArray
* @param {Array<vis.Node.id>} idArray
* @returns {Array<vis.Node>}
*/ */
_indexArrayToNodes(idArray) { _indexArrayToNodes(idArray) {
let array = []; let array = [];
@ -1304,7 +1334,8 @@ class LayoutEngine {
/** /**
* Return the active (i.e. visible) edges for this node * Return the active (i.e. visible) edges for this node
* *
* @returns {array} Array of edge instances
* @param {vis.Node} node
* @returns {Array<vis.Edge>} Array of edge instances
* @private * @private
*/ */
_getActiveEdges(node) { _getActiveEdges(node) {
@ -1417,7 +1448,6 @@ class LayoutEngine {
/** /**
* Allocate nodes in levels based on the direction of the edges. * Allocate nodes in levels based on the direction of the edges.
* *
* @param hubsize
* @private * @private
*/ */
_determineLevelsDirected() { _determineLevelsDirected() {
@ -1480,8 +1510,8 @@ class LayoutEngine {
/** /**
* Crawl over the entire network and use a callback on each node couple that is connected to each other. * Crawl over the entire network and use a callback on each node couple that is connected to each other.
* @param callback | will receive nodeA, nodeB and the connecting edge. A and B are distinct.
* @param startingNodeId
* @param {function} [callback=function(){}] | will receive nodeA, nodeB and the connecting edge. A and B are distinct.
* @param {vis.Node.id} startingNodeId
* @private * @private
*/ */
_crawlNetwork(callback = function() {}, startingNodeId) { _crawlNetwork(callback = function() {}, startingNodeId) {
@ -1542,8 +1572,8 @@ class LayoutEngine {
/** /**
* Shift a branch a certain distance * Shift a branch a certain distance
* @param parentId
* @param diff
* @param {vis.Node.id} parentId
* @param {number} diff
* @private * @private
*/ */
_shiftBlock(parentId, diff) { _shiftBlock(parentId, diff) {
@ -1573,8 +1603,8 @@ class LayoutEngine {
/** /**
* Find a common parent between branches. * Find a common parent between branches.
* @param childA
* @param childB
* @param {vis.Node.id} childA
* @param {vis.Node.id} childB
* @returns {{foundParent, withChild}} * @returns {{foundParent, withChild}}
* @private * @private
*/ */
@ -1613,9 +1643,10 @@ class LayoutEngine {
/** /**
* Abstract the getting of the position so we won't have to repeat the check for direction all the time * Abstract the getting of the position so we won't have to repeat the check for direction all the time
* @param node
* @param position
* @param level
* @param {vis.Node} node
* @param {{x: Number, y: Number}} position
* @param {Number} level
* @param {boolean} [doNotUpdate=false]
* @private * @private
*/ */
_setPositionForHierarchy(node, position, level, doNotUpdate = false) { _setPositionForHierarchy(node, position, level, doNotUpdate = false) {
@ -1637,7 +1668,7 @@ class LayoutEngine {
* Utility function to cut down on typing this all the time. * Utility function to cut down on typing this all the time.
* *
* TODO: use this in all applicable situations in this class. * TODO: use this in all applicable situations in this class.
*
* @returns {boolean}
* @private * @private
*/ */
_isVertical() { _isVertical() {
@ -1646,7 +1677,7 @@ class LayoutEngine {
/** /**
* Abstract the getting of the position of a node so we do not have to repeat the direction check all the time. * Abstract the getting of the position of a node so we do not have to repeat the direction check all the time.
* @param node
* @param {vis.Node} node
* @returns {number|*} * @returns {number|*}
* @private * @private
*/ */
@ -1661,7 +1692,8 @@ class LayoutEngine {
/** /**
* Use the x or y value to sort the array, allowing users to specify order. * Use the x or y value to sort the array, allowing users to specify order.
* @param nodeArray
*
* @param {Array<vis.Node>} nodeArray
* @private * @private
*/ */
_sortNodeArray(nodeArray) { _sortNodeArray(nodeArray) {
@ -1686,6 +1718,7 @@ class LayoutEngine {
* The return value is the type to use to translate dynamic curves to * The return value is the type to use to translate dynamic curves to
* another type, in the case of hierarchical layout. Dynamic curves do * another type, in the case of hierarchical layout. Dynamic curves do
* not work for that layout type. * not work for that layout type.
* @returns {'horizontal'|'vertical'}
*/ */
getStaticType() { getStaticType() {
// Node that 'type' is the edge type, and therefore 'orthogonal' to the layout type. // Node that 'type' is the edge type, and therefore 'orthogonal' to the layout type.
@ -1702,7 +1735,7 @@ class LayoutEngine {
* Determine the center position of a branch from the passed list of child nodes * Determine the center position of a branch from the passed list of child nodes
* *
* This takes into account the positions of all the child nodes. * This takes into account the positions of all the child nodes.
* @param childNodes {array} Array of either child nodes or node id's
* @param {Array<vis.Node|vis.Node.id>} childNodes Array of either child nodes or node id's
* @return {number} * @return {number}
* @private * @private
*/ */

+ 29
- 16
lib/network/modules/ManipulationSystem.js View File

@ -72,7 +72,10 @@ class ManipulationSystem {
/** /**
* Set the Options * Set the Options
* @param options
*
* @param {Object} options
* @param {Object} allOptions
* @param {Object} globalOptions
*/ */
setOptions(options, allOptions, globalOptions) { setOptions(options, allOptions, globalOptions) {
if (allOptions !== undefined) { if (allOptions !== undefined) {
@ -541,9 +544,10 @@ class ManipulationSystem {
/** /**
* generate a new target node. Used for creating new edges and editing edges * generate a new target node. Used for creating new edges and editing edges
* @param x
* @param y
* @returns {*}
*
* @param {Number} x
* @param {Number} y
* @returns {vis.Node}
* @private * @private
*/ */
_getNewTargetNode(x,y) { _getNewTargetNode(x,y) {
@ -660,7 +664,7 @@ class ManipulationSystem {
/** /**
* create a seperator line. the index is to differentiate in the manipulation dom * create a seperator line. the index is to differentiate in the manipulation dom
* @param index
* @param {Number} [index=1]
* @private * @private
*/ */
_createSeperator(index = 1) { _createSeperator(index = 1) {
@ -734,8 +738,8 @@ class ManipulationSystem {
/** /**
* this binds an event until cleanup by the clean functions. * this binds an event until cleanup by the clean functions.
* @param event
* @param newFunction
* @param {Event} event The event
* @param {function} newFunction
* @private * @private
*/ */
_temporaryBindEvent(event, newFunction) { _temporaryBindEvent(event, newFunction) {
@ -745,8 +749,8 @@ class ManipulationSystem {
/** /**
* this overrides an UI function until cleanup by the clean function * this overrides an UI function until cleanup by the clean function
* @param UIfunctionName
* @param newFunction
* @param {String} UIfunctionName
* @param {function} newFunction
* @private * @private
*/ */
_temporaryBindUI(UIfunctionName, newFunction) { _temporaryBindUI(UIfunctionName, newFunction) {
@ -789,8 +793,9 @@ class ManipulationSystem {
/** /**
* Bind an hammer instance to a DOM element. * Bind an hammer instance to a DOM element.
* @param domElement
* @param funct
*
* @param {Element} domElement
* @param {function} boundFunction
*/ */
_bindHammerToDiv(domElement, boundFunction) { _bindHammerToDiv(domElement, boundFunction) {
let hammer = new Hammer(domElement, {}); let hammer = new Hammer(domElement, {});
@ -826,7 +831,7 @@ class ManipulationSystem {
/** /**
* the touch is used to get the position of the initial click * the touch is used to get the position of the initial click
* @param event
* @param {Event} event The event
* @private * @private
*/ */
_controlNodeTouch(event) { _controlNodeTouch(event) {
@ -838,7 +843,7 @@ class ManipulationSystem {
/** /**
* the drag start is used to mark one of the control nodes as selected. * the drag start is used to mark one of the control nodes as selected.
* @param event
* @param {Event} event The event
* @private * @private
*/ */
_controlNodeDragStart(event) { // eslint-disable-line no-unused-vars _controlNodeDragStart(event) { // eslint-disable-line no-unused-vars
@ -871,7 +876,7 @@ class ManipulationSystem {
/** /**
* dragging the control nodes or the canvas * dragging the control nodes or the canvas
* @param event
* @param {Event} event The event
* @private * @private
*/ */
_controlNodeDrag(event) { _controlNodeDrag(event) {
@ -894,7 +899,7 @@ class ManipulationSystem {
/** /**
* connecting or restoring the control nodes. * connecting or restoring the control nodes.
* @param event
* @param {Event} event The event
* @private * @private
*/ */
_controlNodeDragEnd(event) { _controlNodeDragEnd(event) {
@ -948,6 +953,7 @@ class ManipulationSystem {
* the function bound to the selection event. It checks if you want to connect a cluster and changes the description * the function bound to the selection event. It checks if you want to connect a cluster and changes the description
* to walk the user through the process. * to walk the user through the process.
* *
* @param {Event} event
* @private * @private
*/ */
_handleConnect(event) { _handleConnect(event) {
@ -1011,7 +1017,7 @@ class ManipulationSystem {
/** /**
* Connect the new edge to the target if one exists, otherwise remove temp line * Connect the new edge to the target if one exists, otherwise remove temp line
* @param event
* @param {Event} event The event
* @private * @private
*/ */
_finishConnect(event) { _finishConnect(event) {
@ -1068,6 +1074,9 @@ class ManipulationSystem {
/** /**
* Adds a node on the specified location * Adds a node on the specified location
*
* @param {Object} clickData
* @private
*/ */
_performAddNode(clickData) { _performAddNode(clickData) {
let defaultData = { let defaultData = {
@ -1101,6 +1110,8 @@ class ManipulationSystem {
/** /**
* connect two nodes with a new edge. * connect two nodes with a new edge.
* *
* @param {vis.Node.id} sourceNodeId
* @param {vis.Node.id} targetNodeId
* @private * @private
*/ */
_performAddEdge(sourceNodeId, targetNodeId) { _performAddEdge(sourceNodeId, targetNodeId) {
@ -1129,6 +1140,8 @@ class ManipulationSystem {
/** /**
* connect two nodes with a new edge. * connect two nodes with a new edge.
* *
* @param {vis.Node.id} sourceNodeId
* @param {vis.Node.id} targetNodeId
* @private * @private
*/ */
_performEditEdge(sourceNodeId, targetNodeId) { _performEditEdge(sourceNodeId, targetNodeId) {

+ 15
- 11
lib/network/modules/NodesHandler.js View File

@ -201,6 +201,7 @@ class NodesHandler {
/** /**
* Set a data set with nodes for the network * Set a data set with nodes for the network
* @param {Array | DataSet | DataView} nodes The data containing the nodes. * @param {Array | DataSet | DataView} nodes The data containing the nodes.
* @param {Boolean} [doNotEmit=false]
* @private * @private
*/ */
setData(nodes, doNotEmit = false) { setData(nodes, doNotEmit = false) {
@ -251,6 +252,7 @@ class NodesHandler {
/** /**
* Add nodes * Add nodes
* @param {Number[] | String[]} ids * @param {Number[] | String[]} ids
* @param {Boolean} [doNotEmit=false]
* @private * @private
*/ */
add(ids, doNotEmit = false) { add(ids, doNotEmit = false) {
@ -336,8 +338,9 @@ class NodesHandler {
/** /**
* create a node * create a node
* @param properties
* @param constructorClass
* @param {Object} properties
* @param {class} [constructorClass=Node.default]
* @returns {*}
*/ */
create(properties, constructorClass = Node) { create(properties, constructorClass = Node) {
return new constructorClass(properties, this.body, this.images, this.groups, this.options, this.defaultOptions, this.nodeOptions) return new constructorClass(properties, this.body, this.images, this.groups, this.options, this.defaultOptions, this.nodeOptions)
@ -364,7 +367,7 @@ class NodesHandler {
/** /**
* Returns the positions of the nodes. * Returns the positions of the nodes.
* @param ids --> optional, can be array of nodeIds, can be string
* @param {Array<vis.Node.id>|String} [ids] --> optional, can be array of nodeIds, can be string
* @returns {{}} * @returns {{}}
*/ */
getPositions(ids) { getPositions(ids) {
@ -416,7 +419,7 @@ class NodesHandler {
/** /**
* get the bounding box of a node. * get the bounding box of a node.
* @param nodeId
* @param {vis.Node.id} nodeId
* @returns {j|*} * @returns {j|*}
*/ */
getBoundingBox(nodeId) { getBoundingBox(nodeId) {
@ -428,9 +431,9 @@ class NodesHandler {
/** /**
* Get the Ids of nodes connected to this node. * Get the Ids of nodes connected to this node.
* @param nodeId
* @param direction {String|undefined} values 'from' and 'to' select respectively parent and child nodes only.
* Any other value returns both parent and child nodes.
* @param {vis.Node.id} nodeId
* @param {'to'|'from'|undefined} direction values 'from' and 'to' select respectively parent and child nodes only.
* Any other value returns both parent and child nodes.
* @returns {Array} * @returns {Array}
*/ */
getConnectedNodes(nodeId, direction) { getConnectedNodes(nodeId, direction) {
@ -459,7 +462,7 @@ class NodesHandler {
/** /**
* Get the ids of the edges connected to this node. * Get the ids of the edges connected to this node.
* @param nodeId
* @param {vis.Node.id} nodeId
* @returns {*} * @returns {*}
*/ */
getConnectedEdges(nodeId) { getConnectedEdges(nodeId) {
@ -479,9 +482,10 @@ class NodesHandler {
/** /**
* Move a node. * Move a node.
* @param String nodeId
* @param Number x
* @param Number y
*
* @param {vis.Node.id} nodeId
* @param {Number} x
* @param {Number} y
*/ */
moveNode(nodeId, x, y) { moveNode(nodeId, x, y) {
if (this.body.nodes[nodeId] !== undefined) { if (this.body.nodes[nodeId] !== undefined) {

+ 12
- 5
lib/network/modules/PhysicsEngine.js View File

@ -125,7 +125,7 @@ class PhysicsEngine {
/** /**
* set the physics options * set the physics options
* @param options
* @param {Object} options
*/ */
setOptions(options) { setOptions(options) {
if (options !== undefined) { if (options !== undefined) {
@ -242,6 +242,7 @@ class PhysicsEngine {
/** /**
* Stop the simulation, force stabilization. * Stop the simulation, force stabilization.
* @param {boolean} [emit=true]
*/ */
stopSimulation(emit = true) { stopSimulation(emit = true) {
this.stabilized = true; this.stabilized = true;
@ -284,6 +285,8 @@ class PhysicsEngine {
/** /**
* trigger the stabilized event. * trigger the stabilized event.
*
* @param {Number} [amountOfIterations=this.stabilizationIterations]
* @private * @private
*/ */
_emitStabilized(amountOfIterations = this.stabilizationIterations) { _emitStabilized(amountOfIterations = this.stabilizationIterations) {
@ -455,6 +458,9 @@ class PhysicsEngine {
/** /**
* This compares the reference state to the current state * This compares the reference state to the current state
*
* @returns {boolean}
* @private
*/ */
_evaluateStepQuality() { _evaluateStepQuality() {
let dx, dy, dpos; let dx, dy, dpos;
@ -479,7 +485,6 @@ class PhysicsEngine {
/** /**
* move the nodes one timestep and check if they are stabilized * move the nodes one timestep and check if they are stabilized
* @returns {boolean}
*/ */
moveNodes() { moveNodes() {
var nodeIndices = this.physicsBody.physicsNodeIndices; var nodeIndices = this.physicsBody.physicsNodeIndices;
@ -507,12 +512,12 @@ class PhysicsEngine {
/** /**
* Perform the actual step * Perform the actual step
* *
* @param nodeId
* @param maxVelocity
* @param {vis.Node.id} nodeId
* @param {number} maxVelocity
* @returns {number} * @returns {number}
* @private * @private
*/ */
_performStep(nodeId,maxVelocity) {
_performStep(nodeId, maxVelocity) {
let node = this.body.nodes[nodeId]; let node = this.body.nodes[nodeId];
let timestep = this.timestep; let timestep = this.timestep;
let forces = this.physicsBody.forces; let forces = this.physicsBody.forces;
@ -600,6 +605,8 @@ class PhysicsEngine {
/** /**
* Find a stable position for all nodes * Find a stable position for all nodes
*
* @param {Number} [iterations=this.options.stabilization.iterations]
*/ */
stabilize(iterations = this.options.stabilization.iterations) { stabilize(iterations = this.options.stabilization.iterations) {
if (typeof iterations !== 'number') { if (typeof iterations !== 'number') {

+ 22
- 18
lib/network/modules/SelectionHandler.js View File

@ -36,8 +36,8 @@ class SelectionHandler {
/** /**
* handles the selection part of the tap; * handles the selection part of the tap;
* *
* @param {Object} pointer
* @private
* @param {{x: number, y: number}} pointer
* @returns {boolean}
*/ */
selectOnPoint(pointer) { selectOnPoint(pointer) {
let selected = false; let selected = false;
@ -79,8 +79,9 @@ class SelectionHandler {
/** /**
* Create an object containing the standard fields for an event. * Create an object containing the standard fields for an event.
* *
* @param {Event} event
* @param {Object} pointer | object with the x and y screen coordinates of the mouse
* @param {Event} event
* @param {{x: number, y: number}} pointer Object with the x and y screen coordinates of the mouse
* @returns {{}}
* @private * @private
*/ */
_initBaseEvent(event, pointer) { _initBaseEvent(event, pointer) {
@ -102,11 +103,11 @@ class SelectionHandler {
* This adds some extra data to the event with respect to cursor position and * This adds some extra data to the event with respect to cursor position and
* selected nodes and edges. * selected nodes and edges.
* *
* @param {String} eventType | Name of event to send
* @param {String} eventType Name of event to send
* @param {Event} event * @param {Event} event
* @param {Object} pointer | object with the x and y screen coordinates of the mouse
* @param {Object|undefined} object | If present, selection state before event occured
* @param {boolean|undefined} | Indicate if selection data should be passed
* @param {{x: number, y: number}} pointer Object with the x and y screen coordinates of the mouse
* @param {Object|undefined} oldSelection If present, selection state before event occured
* @param {boolean|undefined} [emptySelection=false] Indicate if selection data should be passed
*/ */
_generateClickEvent(eventType, event, pointer, oldSelection, emptySelection = false) { _generateClickEvent(eventType, event, pointer, oldSelection, emptySelection = false) {
let properties = this._initBaseEvent(event, pointer); let properties = this._initBaseEvent(event, pointer);
@ -172,7 +173,7 @@ class SelectionHandler {
/** /**
* Return a position object in canvasspace from a single point in screenspace * Return a position object in canvasspace from a single point in screenspace
* *
* @param pointer
* @param {{x: number, y: number}} pointer
* @returns {{left: number, top: number, right: number, bottom: number}} * @returns {{left: number, top: number, right: number, bottom: number}}
* @private * @private
*/ */
@ -191,6 +192,7 @@ class SelectionHandler {
* Get the top node at the passed point (like a click) * Get the top node at the passed point (like a click)
* *
* @param {{x: Number, y: Number}} pointer * @param {{x: Number, y: Number}} pointer
* @param {boolean} [returnNode=true]
* @return {Node | undefined} node * @return {Node | undefined} node
*/ */
getNodeAt(pointer, returnNode = true) { getNodeAt(pointer, returnNode = true) {
@ -216,7 +218,7 @@ class SelectionHandler {
/** /**
* retrieve all edges overlapping with given object, selector is around center * retrieve all edges overlapping with given object, selector is around center
* @param {Object} object An object with parameters left, top, right, bottom * @param {Object} object An object with parameters left, top, right, bottom
* @return {Number[]} An array with id's of the overlapping nodes
* @param {Number[]} overlappingEdges An array with id's of the overlapping nodes
* @private * @private
*/ */
_getEdgesOverlappingWith(object, overlappingEdges) { _getEdgesOverlappingWith(object, overlappingEdges) {
@ -247,6 +249,7 @@ class SelectionHandler {
* Get the edges nearest to the passed point (like a click) * Get the edges nearest to the passed point (like a click)
* *
* @param {{x: Number, y: Number}} pointer * @param {{x: Number, y: Number}} pointer
* @param {boolean} [returnEdge=true]
* @return {Edge | undefined} node * @return {Edge | undefined} node
*/ */
getEdgeAt(pointer, returnEdge = true) { getEdgeAt(pointer, returnEdge = true) {
@ -287,7 +290,7 @@ class SelectionHandler {
/** /**
* Add object to the selection array. * Add object to the selection array.
* *
* @param obj
* @param {Object} obj
* @private * @private
*/ */
_addToSelection(obj) { _addToSelection(obj) {
@ -302,7 +305,7 @@ class SelectionHandler {
/** /**
* Add object to the selection array. * Add object to the selection array.
* *
* @param obj
* @param {Object} obj
* @private * @private
*/ */
_addToHover(obj) { _addToHover(obj) {
@ -521,8 +524,8 @@ class SelectionHandler {
* Remove the highlight from a node or edge, in response to mouse movement * Remove the highlight from a node or edge, in response to mouse movement
* *
* @param {Event} event * @param {Event} event
* @param {Object} pointer | object with the x and y screen coordinates of the mouse
* @param {Node || Edge} object
* @param {{x: number, y: number}} pointer object with the x and y screen coordinates of the mouse
* @param {vis.Node|vis.Edge} object
* @private * @private
*/ */
emitBlurEvent(event, pointer, object) { emitBlurEvent(event, pointer, object) {
@ -546,8 +549,9 @@ class SelectionHandler {
* Create the highlight for a node or edge, in response to mouse movement * Create the highlight for a node or edge, in response to mouse movement
* *
* @param {Event} event * @param {Event} event
* @param {Object} pointer | object with the x and y screen coordinates of the mouse
* @param {Node || Edge} object
* @param {{x: number, y: number}} pointer object with the x and y screen coordinates of the mouse
* @param {vis.Node|vis.Edge} object
* @returns {boolean} hoverChanged
* @private * @private
*/ */
emitHoverEvent(event, pointer, object) { emitHoverEvent(event, pointer, object) {
@ -576,7 +580,7 @@ class SelectionHandler {
* Perform actions in response to a mouse movement. * Perform actions in response to a mouse movement.
* *
* @param {Event} event * @param {Event} event
* @param {Object} pointer | object with the x and y screen coordinates of the mouse
* @param {{x: number, y: number}} pointer | object with the x and y screen coordinates of the mouse
*/ */
hoverObject(event, pointer) { hoverObject(event, pointer) {
let object = this.getNodeAt(pointer); let object = this.getNodeAt(pointer);
@ -679,7 +683,7 @@ class SelectionHandler {
/** /**
* Updates the current selection * Updates the current selection
* @param {{nodes: Array.<String>, edges: Array.<String>}} Selection
* @param {{nodes: Array.<String>, edges: Array.<String>}} selection
* @param {Object} options Options * @param {Object} options Options
*/ */
setSelection(selection, options = {}) { setSelection(selection, options = {}) {

+ 3
- 4
lib/network/modules/View.js View File

@ -33,8 +33,8 @@ class View {
/** /**
* This function zooms out to fit all data on screen based on amount of nodes * This function zooms out to fit all data on screen based on amount of nodes
* @param {Object} Options
* @param {Boolean} [initialZoom] | zoom based on fitted formula or range, true = fitted, default = false;
* @param {Object} [options={{nodes=Array}}]
* @param {Boolean} [initialZoom=false] | zoom based on fitted formula or range, true = fitted, default = false;
*/ */
fit(options = {nodes:[]}, initialZoom = false) { fit(options = {nodes:[]}, initialZoom = false) {
let range; let range;
@ -239,8 +239,7 @@ class View {
} }
/** /**
*
* @param easingTime
* @param {boolean} [finished=false]
* @private * @private
*/ */
_transitionRedraw(finished = false) { _transitionRedraw(finished = false) {

+ 7
- 5
lib/network/modules/components/Edge.js View File

@ -7,8 +7,6 @@ var BezierEdgeStatic = require('./edges/BezierEdgeStatic').default;
var StraightEdge = require('./edges/StraightEdge').default; var StraightEdge = require('./edges/StraightEdge').default;
/** /**
* @class Edge
*
* A edge connects two nodes * A edge connects two nodes
* @param {Object} properties Object with options. Must contain * @param {Object} properties Object with options. Must contain
* At least options from and to. * At least options from and to.
@ -20,6 +18,7 @@ var StraightEdge = require('./edges/StraightEdge').default;
* nodes. * nodes.
* @param {Object} constants An object with default values for * @param {Object} constants An object with default values for
* example for the color * example for the color
* @class Edge
*/ */
class Edge { class Edge {
constructor(options, body, globalOptions, defaultOptions, edgeOptions) { constructor(options, body, globalOptions, defaultOptions, edgeOptions) {
@ -58,7 +57,7 @@ class Edge {
/** /**
* Set or overwrite options for the edge * Set or overwrite options for the edge
* @param {Object} options an object with options * @param {Object} options an object with options
* @param doNotEmit
* @returns {null|boolean} null if no options, boolean if date changed
*/ */
setOptions(options) { setOptions(options) {
if (!options) { if (!options) {
@ -297,6 +296,8 @@ class Edge {
/** /**
* update the options in the label module * update the options in the label module
*
* @param {Object} options
*/ */
updateLabelModule(options) { updateLabelModule(options) {
this.labelModule.setOptions(this.options, true); this.labelModule.setOptions(this.options, true);
@ -431,7 +432,7 @@ class Edge {
* based on its value. * based on its value.
* @param {Number} min * @param {Number} min
* @param {Number} max * @param {Number} max
* @param total
* @param {Number} total
*/ */
setValueRange(min, max, total) { setValueRange(min, max, total) {
if (this.options.value !== undefined) { if (this.options.value !== undefined) {
@ -618,7 +619,7 @@ class Edge {
* @param {Number} x * @param {Number} x
* @param {Number} y * @param {Number} y
* @param {Number} radius * @param {Number} radius
* @param {Number} percentage. Value between 0 (line start) and 1 (line end)
* @param {Number} percentage Value between 0 (line start) and 1 (line end)
* @return {Object} point * @return {Object} point
* @private * @private
*/ */
@ -662,6 +663,7 @@ class Edge {
/** /**
* Check if both connecting nodes exist * Check if both connecting nodes exist
* @returns {boolean}
*/ */
endPointsValid() { endPointsValid() {
return this.body.nodes[this.fromId] !== undefined return this.body.nodes[this.fromId] !== undefined

+ 16
- 12
lib/network/modules/components/Node.js View File

@ -20,7 +20,6 @@ var { printStyle } = require("../../../shared/Validator");
/** /**
* @class Node
* A node. A node can be connected to other nodes via one or multiple edges. * A node. A node can be connected to other nodes via one or multiple edges.
* @param {object} options An object containing options for the node. All * @param {object} options An object containing options for the node. All
* options are optional, except for the id. * options are optional, except for the id.
@ -42,7 +41,7 @@ var { printStyle } = require("../../../shared/Validator");
* retrieving group options * retrieving group options
* @param {Object} constants An object with default values for * @param {Object} constants An object with default values for
* example for the color * example for the color
*
* @class Node
*/ */
class Node { class Node {
constructor(options, body, imagelist, grouplist, globalOptions, defaultOptions, nodeOptions) { constructor(options, body, imagelist, grouplist, globalOptions, defaultOptions, nodeOptions) {
@ -86,6 +85,7 @@ class Node {
/** /**
* Detach a edge from the node * Detach a edge from the node
*
* @param {Edge} edge * @param {Edge} edge
*/ */
detachEdge(edge) { detachEdge(edge) {
@ -98,8 +98,9 @@ class Node {
/** /**
* Set or overwrite options for the node * Set or overwrite options for the node
*
* @param {Object} options an object with options * @param {Object} options an object with options
* @param {Object} constants and object with default, global options
* @returns {null|boolean}
*/ */
setOptions(options) { setOptions(options) {
let currentShape = this.options.shape; let currentShape = this.options.shape;
@ -147,10 +148,7 @@ class Node {
this.updateShape(currentShape); this.updateShape(currentShape);
this.labelModule.propagateFonts(this.nodeOptions, options, this.defaultOptions); this.labelModule.propagateFonts(this.nodeOptions, options, this.defaultOptions);
if (options.hidden !== undefined || options.physics !== undefined) {
return true;
}
return false;
return (options.hidden !== undefined || options.physics !== undefined);
} }
@ -197,10 +195,11 @@ class Node {
/** /**
* This process all possible shorthands in the new options and makes sure that the parentOptions are fully defined. * This process all possible shorthands in the new options and makes sure that the parentOptions are fully defined.
* Static so it can also be used by the handler. * Static so it can also be used by the handler.
* @param parentOptions
* @param newOptions
* @param allowDeletion
* @param globalOptions
*
* @param {Object} parentOptions
* @param {Object} newOptions
* @param {boolean} [allowDeletion=false]
* @param {Object} [globalOptions={}]
*/ */
static parseOptions(parentOptions, newOptions, allowDeletion = false, globalOptions = {}) { static parseOptions(parentOptions, newOptions, allowDeletion = false, globalOptions = {}) {
var fields = [ var fields = [
@ -465,6 +464,7 @@ class Node {
* based on its value. * based on its value.
* @param {Number} min * @param {Number} min
* @param {Number} max * @param {Number} max
* @param {Number} total
*/ */
setValueRange(min, max, total) { setValueRange(min, max, total) {
if (this.options.value !== undefined) { if (this.options.value !== undefined) {
@ -498,6 +498,7 @@ class Node {
/** /**
* Update the bounding box of the shape * Update the bounding box of the shape
* @param {CanvasRenderingContext2D} ctx
*/ */
updateBoundingBox(ctx) { updateBoundingBox(ctx) {
this.shape.updateBoundingBox(this.x,this.y,ctx); this.shape.updateBoundingBox(this.x,this.y,ctx);
@ -543,10 +544,13 @@ class Node {
} }
/**
/**
* Check valid values for mass * Check valid values for mass
* *
* The mass may not be negative or zero. If it is, reset to 1 * The mass may not be negative or zero. If it is, reset to 1
*
* @param {object} options
* @param {vis.Node.id} id
*/ */
static checkMass(options, id) { static checkMass(options, id) {
if (options.mass !== undefined && options.mass <= 0) { if (options.mass !== undefined && options.mass <= 0) {

+ 23
- 2
lib/network/modules/components/edges/BezierEdgeDynamic.js View File

@ -100,6 +100,8 @@ class BezierEdgeDynamic extends BezierEdgeBase {
/** /**
* Draw a line between two nodes * Draw a line between two nodes
* @param {CanvasRenderingContext2D} ctx * @param {CanvasRenderingContext2D} ctx
* @param {Array<Object>} values
* @param {vis.Node} viaNode
* @private * @private
*/ */
_line(ctx, values, viaNode) { _line(ctx, values, viaNode) {
@ -113,8 +115,9 @@ class BezierEdgeDynamic extends BezierEdgeBase {
/** /**
* Combined function of pointOnLine and pointOnBezier. This gives the coordinates of a point on the line at a certain percentage of the way * Combined function of pointOnLine and pointOnBezier. This gives the coordinates of a point on the line at a certain percentage of the way
* @param percentage
* @param viaNode
*
* @param {number} percentage
* @param {vis.Node} viaNode
* @returns {{x: number, y: number}} * @returns {{x: number, y: number}}
* @private * @private
*/ */
@ -134,10 +137,28 @@ class BezierEdgeDynamic extends BezierEdgeBase {
return {x: x, y: y}; return {x: x, y: y};
} }
/**
*
* @param {vis.Node} nearNode
* @param {CanvasRenderingContext2D} ctx
* @returns {*}
* @private
*/
_findBorderPosition(nearNode, ctx) { _findBorderPosition(nearNode, ctx) {
return this._findBorderPositionBezier(nearNode, ctx, this.via); return this._findBorderPositionBezier(nearNode, ctx, this.via);
} }
/**
*
* @param {number} x1
* @param {number} y1
* @param {number} x2
* @param {number} y2
* @param {number} x3
* @param {number} y3
* @returns {number}
* @private
*/
_getDistanceToEdge(x1, y1, x2, y2, x3, y3) { // x3,y3 is the point _getDistanceToEdge(x1, y1, x2, y2, x3, y3) { // x3,y3 is the point
return this._getDistanceToBezierEdge(x1, y1, x2, y2, x3, y3, this.via); return this._getDistanceToBezierEdge(x1, y1, x2, y2, x3, y3, this.via);
} }

+ 24
- 2
lib/network/modules/components/edges/BezierEdgeStatic.js View File

@ -8,6 +8,8 @@ class BezierEdgeStatic extends BezierEdgeBase {
/** /**
* Draw a line between two nodes * Draw a line between two nodes
* @param {CanvasRenderingContext2D} ctx * @param {CanvasRenderingContext2D} ctx
* @param {Array<Object>} values
* @param {vis.Node} viaNode
* @private * @private
*/ */
_line(ctx, values, viaNode) { _line(ctx, values, viaNode) {
@ -142,18 +144,38 @@ class BezierEdgeStatic extends BezierEdgeBase {
return {x: xVia, y: yVia}; return {x: xVia, y: yVia};
} }
/**
*
* @param {vis.Node} nearNode
* @param {CanvasRenderingContext2D} ctx
* @param {Object} options
* @returns {*}
* @private
*/
_findBorderPosition(nearNode, ctx, options = {}) { _findBorderPosition(nearNode, ctx, options = {}) {
return this._findBorderPositionBezier(nearNode, ctx, options.via); return this._findBorderPositionBezier(nearNode, ctx, options.via);
} }
/**
*
* @param {number} x1
* @param {number} y1
* @param {number} x2
* @param {number} y2
* @param {number} x3
* @param {number} y3
* @param {vis.Node} viaNode
* @returns {number}
* @private
*/
_getDistanceToEdge(x1, y1, x2, y2, x3, y3, viaNode = this._getViaCoordinates()) { // x3,y3 is the point _getDistanceToEdge(x1, y1, x2, y2, x3, y3, viaNode = this._getViaCoordinates()) { // x3,y3 is the point
return this._getDistanceToBezierEdge(x1, y1, x2, y2, x3, y3, viaNode); return this._getDistanceToBezierEdge(x1, y1, x2, y2, x3, y3, viaNode);
} }
/** /**
* Combined function of pointOnLine and pointOnBezier. This gives the coordinates of a point on the line at a certain percentage of the way * Combined function of pointOnLine and pointOnBezier. This gives the coordinates of a point on the line at a certain percentage of the way
* @param percentage
* @param viaNode
* @param {number} percentage
* @param {vis.Node} viaNode
* @returns {{x: number, y: number}} * @returns {{x: number, y: number}}
* @private * @private
*/ */

+ 5
- 2
lib/network/modules/components/edges/CubicBezierEdge.js View File

@ -8,6 +8,8 @@ class CubicBezierEdge extends CubicBezierEdgeBase {
/** /**
* Draw a line between two nodes * Draw a line between two nodes
* @param {CanvasRenderingContext2D} ctx * @param {CanvasRenderingContext2D} ctx
* @param {Array<Object>} values
* @param {Array<vis.Node>} viaNodes
* @private * @private
*/ */
_line(ctx, values, viaNodes) { _line(ctx, values, viaNodes) {
@ -55,8 +57,9 @@ class CubicBezierEdge extends CubicBezierEdgeBase {
/** /**
* Combined function of pointOnLine and pointOnBezier. This gives the coordinates of a point on the line at a certain percentage of the way * Combined function of pointOnLine and pointOnBezier. This gives the coordinates of a point on the line at a certain percentage of the way
* @param percentage
* @param via
* @param {number} percentage
* @param {{x: number, y: number}} [via1=this._getViaCoordinates()[0]]
* @param {{x: number, y: number}} [via2=this._getViaCoordinates()[1]]
* @returns {{x: number, y: number}} * @returns {{x: number, y: number}}
* @private * @private
*/ */

+ 3
- 2
lib/network/modules/components/edges/StraightEdge.js View File

@ -8,6 +8,7 @@ class StraightEdge extends EdgeBase {
/** /**
* Draw a line between two nodes * Draw a line between two nodes
* @param {CanvasRenderingContext2D} ctx * @param {CanvasRenderingContext2D} ctx
* @param {Array<Object>} values
* @private * @private
*/ */
_line(ctx, values) { _line(ctx, values) {
@ -27,8 +28,8 @@ class StraightEdge extends EdgeBase {
/** /**
* Combined function of pointOnLine and pointOnBezier. This gives the coordinates of a point on the line at a certain percentage of the way * Combined function of pointOnLine and pointOnBezier. This gives the coordinates of a point on the line at a certain percentage of the way
* @param percentage
* @param via
*
* @param {number} percentage
* @returns {{x: number, y: number}} * @returns {{x: number, y: number}}
* @private * @private
*/ */

+ 7
- 9
lib/network/modules/components/edges/util/BezierEdgeBase.js View File

@ -8,15 +8,11 @@ class BezierEdgeBase extends EdgeBase {
/** /**
* This function uses binary search to look for the point where the bezier curve crosses the border of the node. * This function uses binary search to look for the point where the bezier curve crosses the border of the node.
* *
* @param nearNode
* @param ctx
* @param viaNode
* @param nearNode
* @param ctx
* @param viaNode
* @param nearNode
* @param ctx
* @param viaNode
* @param {vis.Node} nearNode
* @param {CanvasRenderingContext2D} ctx
* @param {vis.Node} viaNode
* @returns {*}
* @private
*/ */
_findBorderPositionBezier(nearNode, ctx, viaNode = this._getViaCoordinates()) { _findBorderPositionBezier(nearNode, ctx, viaNode = this._getViaCoordinates()) {
var maxIterations = 10; var maxIterations = 10;
@ -79,6 +75,8 @@ class BezierEdgeBase extends EdgeBase {
* @param {number} y2 to y * @param {number} y2 to y
* @param {number} x3 point to check x * @param {number} x3 point to check x
* @param {number} y3 point to check y * @param {number} y3 point to check y
* @param {vis.Node} via
* @returns {number}
* @private * @private
*/ */
_getDistanceToBezierEdge(x1, y1, x2, y2, x3, y3, via) { // x3,y3 is the point _getDistanceToBezierEdge(x1, y1, x2, y2, x3, y3, via) { // x3,y3 is the point

+ 3
- 0
lib/network/modules/components/edges/util/CubicBezierEdgeBase.js View File

@ -16,6 +16,9 @@ class CubicBezierEdgeBase extends BezierEdgeBase {
* @param {number} y2 to y * @param {number} y2 to y
* @param {number} x3 point to check x * @param {number} x3 point to check x
* @param {number} y3 point to check y * @param {number} y3 point to check y
* @param {vis.Node} via1
* @param {vis.Node} via2
* @returns {number}
* @private * @private
*/ */
_getDistanceToBezierEdge(x1, y1, x2, y2, x3, y3, via1, via2) { // x3,y3 is the point _getDistanceToBezierEdge(x1, y1, x2, y2, x3, y3, via1, via2) { // x3,y3 is the point

+ 28
- 13
lib/network/modules/components/edges/util/EdgeBase.js View File

@ -34,7 +34,12 @@ class EdgeBase {
* Redraw a edge as a line * Redraw a edge as a line
* Draw this edge in the given canvas * Draw this edge in the given canvas
* The 2d context of a HTML canvas can be retrieved by canvas.getContext("2d"); * The 2d context of a HTML canvas can be retrieved by canvas.getContext("2d");
*
* @param {CanvasRenderingContext2D} ctx * @param {CanvasRenderingContext2D} ctx
* @param {Array} values
* @param {boolean} selected
* @param {boolean} hover
* @param {vis.Node} viaNode
* @private * @private
*/ */
drawLine(ctx, values, selected, hover, viaNode) { drawLine(ctx, values, selected, hover, viaNode) {
@ -165,7 +170,7 @@ class EdgeBase {
* @param {Number} x * @param {Number} x
* @param {Number} y * @param {Number} y
* @param {Number} radius * @param {Number} radius
* @param {Number} percentage. Value between 0 (line start) and 1 (line end)
* @param {Number} percentage - Value between 0 (line start) and 1 (line end)
* @return {Object} point * @return {Object} point
* @private * @private
*/ */
@ -179,9 +184,9 @@ class EdgeBase {
/** /**
* This function uses binary search to look for the point where the circle crosses the border of the node. * This function uses binary search to look for the point where the circle crosses the border of the node.
* @param node
* @param ctx
* @param options
* @param {vis.Node} node
* @param {CanvasRenderingContext2D} ctx
* @param {Object} options
* @returns {*} * @returns {*}
* @private * @private
*/ */
@ -237,6 +242,8 @@ class EdgeBase {
/** /**
* Get the line width of the edge. Depends on width and whether one of the * Get the line width of the edge. Depends on width and whether one of the
* connected nodes is selected. * connected nodes is selected.
* @param {boolean} selected
* @param {boolean} hover
* @return {Number} width * @return {Number} width
* @private * @private
*/ */
@ -293,7 +300,9 @@ class EdgeBase {
/** /**
* Draw a line from a node to itself, a circle * Draw a line from a node to itself, a circle
*
* @param {CanvasRenderingContext2D} ctx * @param {CanvasRenderingContext2D} ctx
* @param {Array} values
* @param {Number} x * @param {Number} x
* @param {Number} y * @param {Number} y
* @param {Number} radius * @param {Number} radius
@ -324,7 +333,9 @@ class EdgeBase {
* @param {number} y2 * @param {number} y2
* @param {number} x3 * @param {number} x3
* @param {number} y3 * @param {number} y3
* @param via
* @param {vis.Node} via
* @param {Array} values
* @returns {number}
* @private * @private
*/ */
getDistanceToEdge(x1, y1, x2, y2, x3, y3, via, values) { // eslint-disable-line no-unused-vars getDistanceToEdge(x1, y1, x2, y2, x3, y3, via, values) { // eslint-disable-line no-unused-vars
@ -379,10 +390,13 @@ class EdgeBase {
/** /**
*
* @param ctx
* @param position
* @param viaNode
* @param {CanvasRenderingContext2D} ctx
* @param {string} position
* @param {vis.Node} viaNode
* @param {boolean} selected
* @param {boolean} hover
* @param {Array} values
* @returns {{point: *, core: {x: number, y: number}, angle: *, length: number, type: *}}
*/ */
getArrowData(ctx, position, viaNode, selected, hover, values) { getArrowData(ctx, position, viaNode, selected, hover, values) {
// set lets // set lets
@ -459,10 +473,11 @@ class EdgeBase {
/** /**
* *
* @param ctx
* @param selected
* @param hover
* @param arrowData
* @param {CanvasRenderingContext2D} ctx
* @param {Array<Object>} values
* @param {boolean} selected
* @param {boolean} hover
* @param {Object} arrowData
*/ */
drawArrowHead(ctx, values, selected, hover, arrowData) { drawArrowHead(ctx, values, selected, hover, arrowData) {
// set style // set style

+ 1
- 1
lib/network/modules/components/nodes/util/CircleImageBase.js View File

@ -39,7 +39,7 @@ class CircleImageBase extends NodeBase {
* field 'nodes.brokenImage' in the options. * field 'nodes.brokenImage' in the options.
* *
* @param {Image} imageObj required; main image to show for this node * @param {Image} imageObj required; main image to show for this node
* @param {Image|undefined} optional; image to show when node is selected
* @param {Image|undefined} imageObjAlt optional; image to show when node is selected
*/ */
setImages(imageObj, imageObjAlt) { setImages(imageObj, imageObjAlt) {
if (imageObjAlt && this.selected) { if (imageObjAlt && this.selected) {

+ 16
- 1
lib/network/modules/components/nodes/util/NodeBase.js View File

@ -95,6 +95,9 @@ class NodeBase {
/** /**
* Determine if the shape of a node needs to be recalculated. * Determine if the shape of a node needs to be recalculated.
* *
* @param {boolean} selected
* @param {boolean} hover
* @returns {boolean}
* @protected * @protected
*/ */
needsRefresh(selected, hover) { needsRefresh(selected, hover) {
@ -160,6 +163,13 @@ class NodeBase {
* *
* Doing it like this makes it easier to override * Doing it like this makes it easier to override
* in the child classes. * in the child classes.
*
* @param {number} x width
* @param {number} y height
* @param {CanvasRenderingContext2D} ctx
* @param {boolean} selected
* @param {boolean} hover
* @private
*/ */
_updateBoundingBox(x, y, ctx, selected, hover) { _updateBoundingBox(x, y, ctx, selected, hover) {
if (ctx !== undefined) { if (ctx !== undefined) {
@ -178,8 +188,13 @@ class NodeBase {
/** /**
* Default implementation of this method call. * Default implementation of this method call.
*
* This acts as a stub which can be overridden. * This acts as a stub which can be overridden.
*
* @param {number} x width
* @param {number} y height
* @param {CanvasRenderingContext2D} ctx
* @param {boolean} selected
* @param {boolean} hover
*/ */
updateBoundingBox(x, y, ctx, selected, hover) { updateBoundingBox(x, y, ctx, selected, hover) {
this._updateBoundingBox(x, y, ctx, selected, hover); this._updateBoundingBox(x, y, ctx, selected, hover);

+ 26
- 27
lib/network/modules/components/physics/BarnesHutSolver.js View File

@ -1,4 +1,3 @@
class BarnesHutSolver { class BarnesHutSolver {
constructor(body, physicsBody, options) { constructor(body, physicsBody, options) {
this.body = body; this.body = body;
@ -61,8 +60,8 @@ class BarnesHutSolver {
* This function traverses the barnesHutTree. It checks when it can approximate distant nodes with their center of mass. * This function traverses the barnesHutTree. It checks when it can approximate distant nodes with their center of mass.
* If a region contains a single node, we check if it is not itself, then we apply the force. * If a region contains a single node, we check if it is not itself, then we apply the force.
* *
* @param parentBranch
* @param node
* @param {Object} parentBranch
* @param {vis.Node} node
* @private * @private
*/ */
_getForceContribution(parentBranch, node) { _getForceContribution(parentBranch, node) {
@ -102,11 +101,11 @@ class BarnesHutSolver {
/** /**
* Calculate the forces based on the distance. * Calculate the forces based on the distance.
* *
* @param distance
* @param dx
* @param dy
* @param node
* @param parentBranch
* @param {number} distance
* @param {number} dx
* @param {number} dy
* @param {vis.Node} node
* @param {Object} parentBranch
* @private * @private
*/ */
_calculateForces(distance, dx, dy, node, parentBranch) { _calculateForces(distance, dx, dy, node, parentBranch) {
@ -133,8 +132,9 @@ class BarnesHutSolver {
/** /**
* This function constructs the barnesHut tree recursively. It creates the root, splits it and starts placing the nodes. * This function constructs the barnesHut tree recursively. It creates the root, splits it and starts placing the nodes.
* *
* @param nodes
* @param nodeIndices
* @param {Array<vis.Node>} nodes
* @param {Array<number>} nodeIndices
* @returns {{root: {centerOfMass: {x: number, y: number}, mass: number, range: {minX: number, maxX: number, minY: number, maxY: number}, size: number, calcSize: number, children: {data: null}, maxWidth: number, level: number, childrenCount: number}}} BarnesHutTree
* @private * @private
*/ */
_formBarnesHutTree(nodes, nodeIndices) { _formBarnesHutTree(nodes, nodeIndices) {
@ -217,8 +217,8 @@ class BarnesHutSolver {
/** /**
* this updates the mass of a branch. this is increased by adding a node. * this updates the mass of a branch. this is increased by adding a node.
* *
* @param parentBranch
* @param node
* @param {Object} parentBranch
* @param {vis.Node} node
* @private * @private
*/ */
_updateBranchMass(parentBranch, node) { _updateBranchMass(parentBranch, node) {
@ -241,9 +241,9 @@ class BarnesHutSolver {
/** /**
* determine in which branch the node will be placed. * determine in which branch the node will be placed.
* *
* @param parentBranch
* @param node
* @param skipMassUpdate
* @param {Object} parentBranch
* @param {vis.Node} node
* @param {boolean} skipMassUpdate
* @private * @private
*/ */
_placeInTree(parentBranch, node, skipMassUpdate) { _placeInTree(parentBranch, node, skipMassUpdate) {
@ -274,9 +274,9 @@ class BarnesHutSolver {
/** /**
* actually place the node in a region (or branch) * actually place the node in a region (or branch)
* *
* @param parentBranch
* @param node
* @param region
* @param {Object} parentBranch
* @param {vis.Node} node
* @param {'NW'| 'NE' | 'SW' | 'SE'} region
* @private * @private
*/ */
_placeInRegion(parentBranch, node, region) { _placeInRegion(parentBranch, node, region) {
@ -310,7 +310,7 @@ class BarnesHutSolver {
* this function splits a branch into 4 sub branches. If the branch contained a node, we place it in the subbranch * this function splits a branch into 4 sub branches. If the branch contained a node, we place it in the subbranch
* after the split is complete. * after the split is complete.
* *
* @param parentBranch
* @param {Object} parentBranch
* @private * @private
*/ */
_splitBranch(parentBranch) { _splitBranch(parentBranch) {
@ -340,9 +340,8 @@ class BarnesHutSolver {
* Specifically, this inserts a single new segment. * Specifically, this inserts a single new segment.
* It fills the children section of the parentBranch * It fills the children section of the parentBranch
* *
* @param parentBranch
* @param region
* @param parentRange
* @param {Object} parentBranch
* @param {'NW'| 'NE' | 'SW' | 'SE'} region
* @private * @private
*/ */
_insertRegion(parentBranch, region) { _insertRegion(parentBranch, region) {
@ -398,8 +397,8 @@ class BarnesHutSolver {
/** /**
* This function is for debugging purposed, it draws the tree. * This function is for debugging purposed, it draws the tree.
* *
* @param ctx
* @param color
* @param {CanvasRenderingContext2D} ctx
* @param {string} color
* @private * @private
*/ */
_debug(ctx, color) { _debug(ctx, color) {
@ -415,9 +414,9 @@ class BarnesHutSolver {
/** /**
* This function is for debugging purposes. It draws the branches recursively. * This function is for debugging purposes. It draws the branches recursively.
* *
* @param branch
* @param ctx
* @param color
* @param {Object} branch
* @param {CanvasRenderingContext2D} ctx
* @param {string} color
* @private * @private
*/ */
_drawBranch(branch, ctx, color) { _drawBranch(branch, ctx, color) {

+ 5
- 0
lib/network/modules/components/physics/CentralGravitySolver.js View File

@ -28,6 +28,11 @@ class CentralGravitySolver {
/** /**
* Calculate the forces based on the distance. * Calculate the forces based on the distance.
* @param {number} distance
* @param {number} dx
* @param {number} dy
* @param {Object<vis.Node.id, vis.Node>} forces
* @param {vis.Node} node
* @private * @private
*/ */
_calculateForces(distance, dx, dy, forces, node) { _calculateForces(distance, dx, dy, forces, node) {

+ 6
- 0
lib/network/modules/components/physics/FA2BasedCentralGravitySolver.js View File

@ -8,6 +8,12 @@ class ForceAtlas2BasedCentralGravitySolver extends CentralGravitySolver {
/** /**
* Calculate the forces based on the distance. * Calculate the forces based on the distance.
*
* @param {number} distance
* @param {number} dx
* @param {number} dy
* @param {Object<vis.Node.id, vis.Node>} forces
* @param {vis.Node} node
* @private * @private
*/ */
_calculateForces(distance, dx, dy, forces, node) { _calculateForces(distance, dx, dy, forces, node) {

+ 5
- 5
lib/network/modules/components/physics/FA2BasedRepulsionSolver.js View File

@ -8,11 +8,11 @@ class ForceAtlas2BasedRepulsionSolver extends BarnesHutSolver {
/** /**
* Calculate the forces based on the distance. * Calculate the forces based on the distance.
* *
* @param distance
* @param dx
* @param dy
* @param node
* @param parentBranch
* @param {number} distance
* @param {number} dx
* @param {number} dy
* @param {vis.Node} node
* @param {Object} parentBranch
* @private * @private
*/ */
_calculateForces(distance, dx, dy, node, parentBranch) { _calculateForces(distance, dx, dy, node, parentBranch) {

+ 1
- 0
lib/network/modules/components/physics/RepulsionSolver.js View File

@ -8,6 +8,7 @@ class RepulsionSolver {
setOptions(options) { setOptions(options) {
this.options = options; this.options = options;
} }
/** /**
* Calculate the forces the nodes apply on each other based on a repulsion field. * Calculate the forces the nodes apply on each other based on a repulsion field.
* This field is linearly approximated. * This field is linearly approximated.

+ 3
- 3
lib/network/modules/components/physics/SpringSolver.js View File

@ -50,9 +50,9 @@ class SpringSolver {
/** /**
* This is the code actually performing the calculation for the function above. * This is the code actually performing the calculation for the function above.
* *
* @param node1
* @param node2
* @param edgeLength
* @param {vis.Node} node1
* @param {vis.Node} node2
* @param {number} edgeLength
* @private * @private
*/ */
_calculateSpringForce(node1, node2, edgeLength) { _calculateSpringForce(node1, node2, edgeLength) {

+ 85
- 49
lib/network/modules/components/shared/Label.js View File

@ -23,7 +23,7 @@ class LabelAccumulator {
* *
* @param {number} l index of line to add to * @param {number} l index of line to add to
* @param {string} text string to append to line * @param {string} text string to append to line
* @param {boolean} mod id of multi-font to use, default 'normal'
* @param {'bold'|'ital'|'boldital'|'mono'|'normal'} [mod='normal']
* @private * @private
*/ */
_add(l, text, mod = 'normal') { _add(l, text, mod = 'normal') {
@ -54,6 +54,8 @@ class LabelAccumulator {
/** /**
* Returns the width in pixels of the current line. * Returns the width in pixels of the current line.
*
* @returns {number}
*/ */
curWidth() { curWidth() {
let line = this.lines[this.current]; let line = this.lines[this.current];
@ -65,6 +67,9 @@ class LabelAccumulator {
/** /**
* Add text in block to current line * Add text in block to current line
*
* @param {string} text
* @param {'bold'|'ital'|'boldital'|'mono'|'normal'} [mod='normal']
*/ */
append(text, mod = 'normal') { append(text, mod = 'normal') {
this._add(this.current, text, mod); this._add(this.current, text, mod);
@ -73,8 +78,11 @@ class LabelAccumulator {
/** /**
* Add text in block to current line and start a new line * Add text in block to current line and start a new line
*
* @param {string} text
* @param {'bold'|'ital'|'boldital'|'mono'|'normal'} [mod='normal']
*/ */
newLine(text, mod = 'normal') {
newLine(text, mod = 'normal') {
this._add(this.current, text, mod); this._add(this.current, text, mod);
this.current++; this.current++;
} }
@ -82,6 +90,8 @@ class LabelAccumulator {
/** /**
* Set the sizes for all lines and the whole thing. * Set the sizes for all lines and the whole thing.
*
* @returns {{width: (number|*), height: (number|*), lines: Array}}
*/ */
finalize() { finalize() {
// console.log(JSON.stringify(this.lines, null, 2)); // console.log(JSON.stringify(this.lines, null, 2));
@ -180,10 +190,9 @@ class Label {
* - No number conversion (size) * - No number conversion (size)
* - Not all font options are set (vadjust, mod) * - Not all font options are set (vadjust, mod)
* *
* @param inOptions {Object} font options to parse
* @param outOptions {Object} out-parameter, object in which to store the parse results (if any)
*
* @return true if font parsed as string, false otherwise
* @param {Object} outOptions out-parameter, object in which to store the parse results (if any)
* @param {Object} inOptions font options to parse
* @return {boolean} true if font parsed as string, false otherwise
*/ */
static parseFontString(outOptions, inOptions) { static parseFontString(outOptions, inOptions) {
if (!inOptions || typeof inOptions !== 'string') return false; if (!inOptions || typeof inOptions !== 'string') return false;
@ -283,6 +292,10 @@ class Label {
* *
* NOTE: naming of 'groupOptions' is a misnomer; the actual value passed * NOTE: naming of 'groupOptions' is a misnomer; the actual value passed
* is the new values to set from setOptions(). * is the new values to set from setOptions().
*
* @param {Object} options
* @param {Object} groupOptions
* @param {Object} defaultOptions
*/ */
propagateFonts(options, groupOptions, defaultOptions) { propagateFonts(options, groupOptions, defaultOptions) {
if (!this.fontOptions.multi) return; if (!this.fontOptions.multi) return;
@ -292,10 +305,9 @@ class Label {
* If valid, return a reference to the object in question. * If valid, return a reference to the object in question.
* Otherwise, just return null. * Otherwise, just return null.
* *
* param 'mod' is optional.
*
* options {Object} base object to determine path from
* mod {string|undefined} if present, sub path for the mod-font
* @param {Object} options base object to determine path from
* @param {'bold'|'ital'|'boldital'|'mono'|'normal'} [mod=undefined] if present, sub path for the mod-font
* @returns {Object|null}
*/ */
var pathP = function(options, mod) { var pathP = function(options, mod) {
if (!options || !options.font) return null; if (!options || !options.font) return null;
@ -315,7 +327,10 @@ class Label {
* Get property value from options.font[mod][property] if present. * Get property value from options.font[mod][property] if present.
* If mod not passed, use property value from options.font[property]. * If mod not passed, use property value from options.font[property].
* *
* @return value if found, null otherwise.
* @param {vis.Label.options} options
* @param {'bold'|'ital'|'boldital'|'mono'|'normal'} mod
* @param {string} property
* @return {*|null} value if found, null otherwise.
*/ */
var getP = function(options, mod, property) { var getP = function(options, mod, property) {
let opt = pathP(options, mod); let opt = pathP(options, mod);
@ -413,11 +428,12 @@ class Label {
/** /**
* Main function. This is called from anything that wants to draw a label. * Main function. This is called from anything that wants to draw a label.
* @param ctx
* @param x
* @param y
* @param selected
* @param baseline
* @param {CanvasRenderingContext2D} ctx
* @param {number} x
* @param {number} y
* @param {boolean} selected
* @param {boolean} hover
* @param {string} [baseline='middle']
*/ */
draw(ctx, x, y, selected, hover, baseline = 'middle') { draw(ctx, x, y, selected, hover, baseline = 'middle') {
// if no label, return // if no label, return
@ -473,9 +489,12 @@ class Label {
/** /**
* *
* @param ctx
* @param x
* @param baseline
* @param {CanvasRenderingContext2D} ctx
* @param {boolean} selected
* @param {boolean} hover
* @param {number} x
* @param {number} y
* @param {string} [baseline='middle']
* @private * @private
*/ */
_drawText(ctx, selected, hover, x, y, baseline = 'middle') { _drawText(ctx, selected, hover, x, y, baseline = 'middle') {
@ -483,13 +502,14 @@ class Label {
let viewFontSize = fontSize * this.body.view.scale; let viewFontSize = fontSize * this.body.view.scale;
// this ensures that there will not be HUGE letters on screen by setting an upper limit on the visible text size (regardless of zoomLevel) // this ensures that there will not be HUGE letters on screen by setting an upper limit on the visible text size (regardless of zoomLevel)
if (viewFontSize >= this.elementOptions.scaling.label.maxVisible) { if (viewFontSize >= this.elementOptions.scaling.label.maxVisible) {
// TODO: Does this actually do anything?
fontSize = Number(this.elementOptions.scaling.label.maxVisible) / this.body.view.scale; fontSize = Number(this.elementOptions.scaling.label.maxVisible) / this.body.view.scale;
} }
let yLine = this.size.yLine; let yLine = this.size.yLine;
[x, yLine] = this._setAlignment(ctx, x, yLine, baseline); [x, yLine] = this._setAlignment(ctx, x, yLine, baseline);
ctx.textAlign = 'left'
ctx.textAlign = 'left';
x = x - this.size.width / 2; // Shift label 1/2-distance to the left x = x - this.size.width / 2; // Shift label 1/2-distance to the left
if ((this.fontOptions.valign) && (this.size.height > this.size.labelHeight)) { if ((this.fontOptions.valign) && (this.size.height > this.size.labelHeight)) {
if (this.fontOptions.valign === 'top') { if (this.fontOptions.valign === 'top') {
@ -531,6 +551,15 @@ class Label {
} }
} }
/**
*
* @param {CanvasRenderingContext2D} ctx
* @param {Number} x
* @param {Number} yLine
* @param {String} baseline
* @returns {Array<Number>}
* @private
*/
_setAlignment(ctx, x, yLine, baseline) { _setAlignment(ctx, x, yLine, baseline) {
// check for label alignment (for edges) // check for label alignment (for edges)
// TODO: make alignment for nodes // TODO: make alignment for nodes
@ -561,8 +590,10 @@ class Label {
* fade in when relative scale is between threshold and threshold - 1. * fade in when relative scale is between threshold and threshold - 1.
* If the relative scale would be smaller than threshold -1 the draw function would have returned before coming here. * If the relative scale would be smaller than threshold -1 the draw function would have returned before coming here.
* *
* @param viewFontSize
* @returns {*[]}
* @param {string} color The font color to use
* @param {number} viewFontSize
* @param {string} initialStrokeColor
* @returns {Array<string>} An array containing the font color and stroke color
* @private * @private
*/ */
_getColor(color, viewFontSize, initialStrokeColor) { _getColor(color, viewFontSize, initialStrokeColor) {
@ -576,11 +607,11 @@ class Label {
return [fontColor, strokeColor]; return [fontColor, strokeColor];
} }
/** /**
* *
* @param ctx
* @param selected
* @param {CanvasRenderingContext2D} ctx
* @param {boolean} selected
* @param {boolean} hover
* @returns {{width: number, height: number}} * @returns {{width: number, height: number}}
*/ */
getTextSize(ctx, selected = false, hover = false) { getTextSize(ctx, selected = false, hover = false) {
@ -595,11 +626,12 @@ class Label {
/** /**
* *
* @param ctx
* @param selected
* @param x
* @param y
* @param baseline
* @param {CanvasRenderingContext2D} ctx
* @param {boolean} selected
* @param {boolean} hover
* @param {number} [x=0]
* @param {number} [y=0]
* @param {'middle'|'hanging'} [baseline='middle']
*/ */
calculateLabelSize(ctx, selected, hover, x = 0, y = 0, baseline = 'middle') { calculateLabelSize(ctx, selected, hover, x = 0, y = 0, baseline = 'middle') {
if (this.labelDirty === true) { if (this.labelDirty === true) {
@ -618,6 +650,9 @@ class Label {
/** /**
* normalize the markup system * normalize the markup system
*
* @param {boolean|'md'|'markdown'|'html'} markupSystem
* @returns {string}
*/ */
decodeMarkupSystem(markupSystem) { decodeMarkupSystem(markupSystem) {
let system = 'none'; let system = 'none';
@ -631,9 +666,9 @@ class Label {
/** /**
* Explodes a piece of text into single-font blocks using a given markup * Explodes a piece of text into single-font blocks using a given markup
* @param text
* @param markupSystem
* @returns [{ text, mod }]
* @param {string} text
* @param {boolean|'md'|'markdown'|'html'} markupSystem
* @returns {Array<{text: string, mod: string}>}
*/ */
splitBlocks(text, markupSystem) { splitBlocks(text, markupSystem) {
let system = this.decodeMarkupSystem(markupSystem); let system = this.decodeMarkupSystem(markupSystem);
@ -926,10 +961,11 @@ class Label {
/** /**
* This explodes the passed text into lines and determines the width, height and number of lines. * This explodes the passed text into lines and determines the width, height and number of lines.
* *
* @param ctx
* @param selected
* @param hover
* @param {CanvasRenderingContext2D} ctx
* @param {boolean} selected
* @param {boolean} hover
* @param {String} text the text to explode * @param {String} text the text to explode
* @returns {{width, height, lines}|*}
* @private * @private
*/ */
_processLabelText(ctx, selected, hover, text) { _processLabelText(ctx, selected, hover, text) {
@ -972,7 +1008,7 @@ class Label {
let overMaxWidth = function(text) { let overMaxWidth = function(text) {
let width = ctx.measureText(text).width; let width = ctx.measureText(text).width;
return (lines.curWidth() + width > self.fontOptions.maxWdt); return (lines.curWidth() + width > self.fontOptions.maxWdt);
}
};
/** /**
@ -980,7 +1016,7 @@ class Label {
* current max width. * current max width.
* *
* @param {Array} words Array of strings signifying a text lines * @param {Array} words Array of strings signifying a text lines
* @return index of first item in string making string go over max
* @return {number} index of first item in string making string go over max
*/ */
let getLongestFit = function(words) { let getLongestFit = function(words) {
let text = ''; let text = '';
@ -996,25 +1032,25 @@ class Label {
} }
return w; return w;
}
};
/** /**
* Determine the longest part of th string which still fits in the
* Determine the longest part of the string which still fits in the
* current max width. * current max width.
* *
* @param {Array} words Array of strings signifying a text lines * @param {Array} words Array of strings signifying a text lines
* @return index of first item in string making string go over max
* @return {number} index of first item in string making string go over max
*/ */
let getLongestFitWord = function(word) {
let getLongestFitWord = function(words) {
let w = 0; let w = 0;
while (w < word.length) {
if (overMaxWidth(word.slice(0,w))) break;
while (w < words.length) {
if (overMaxWidth(words.slice(0,w))) break;
w++; w++;
} }
return w; return w;
}
};
let splitStringIntoLines = function(str, mod = 'normal', appendLast = false) { let splitStringIntoLines = function(str, mod = 'normal', appendLast = false) {
@ -1046,7 +1082,7 @@ class Label {
words = words.slice(w); words = words.slice(w);
} }
} }
}
};
let nlLines = String(text).split('\n'); let nlLines = String(text).split('\n');
@ -1104,9 +1140,9 @@ class Label {
/** /**
* This explodes the label string into lines and sets the width, height and number of lines. * This explodes the label string into lines and sets the width, height and number of lines.
* @param ctx
* @param selected
* @param hover
* @param {CanvasRenderingContext2D} ctx
* @param {boolean} selected
* @param {boolean} hover
* @private * @private
*/ */
_processLabel(ctx, selected, hover) { _processLabel(ctx, selected, hover) {

+ 36
- 0
lib/network/shapes.js View File

@ -5,6 +5,10 @@ if (typeof CanvasRenderingContext2D !== 'undefined') {
/** /**
* Draw a circle shape * Draw a circle shape
*
* @param {Number} x
* @param {Number} y
* @param {Number} r
*/ */
CanvasRenderingContext2D.prototype.circle = function (x, y, r) { CanvasRenderingContext2D.prototype.circle = function (x, y, r) {
this.beginPath(); this.beginPath();
@ -125,6 +129,12 @@ if (typeof CanvasRenderingContext2D !== 'undefined') {
/** /**
* http://stackoverflow.com/questions/1255512/how-to-draw-a-rounded-rectangle-on-html-canvas * http://stackoverflow.com/questions/1255512/how-to-draw-a-rounded-rectangle-on-html-canvas
*
* @param {Number} x
* @param {Number} y
* @param {Number} w
* @param {Number} h
* @param {Number} r
*/ */
CanvasRenderingContext2D.prototype.roundRect = function (x, y, w, h, r) { CanvasRenderingContext2D.prototype.roundRect = function (x, y, w, h, r) {
var r2d = Math.PI / 180; var r2d = Math.PI / 180;
@ -151,6 +161,11 @@ if (typeof CanvasRenderingContext2D !== 'undefined') {
* http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas * http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas
* *
* Postfix '_vis' added to discern it from standard method ellipse(). * Postfix '_vis' added to discern it from standard method ellipse().
*
* @param {Number} x
* @param {Number} y
* @param {Number} w
* @param {Number} h
*/ */
CanvasRenderingContext2D.prototype.ellipse_vis = function (x, y, w, h) { CanvasRenderingContext2D.prototype.ellipse_vis = function (x, y, w, h) {
var kappa = .5522848, var kappa = .5522848,
@ -173,6 +188,11 @@ if (typeof CanvasRenderingContext2D !== 'undefined') {
/** /**
* http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas * http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas
*
* @param {Number} x
* @param {Number} y
* @param {Number} w
* @param {Number} h
*/ */
CanvasRenderingContext2D.prototype.database = function (x, y, w, h) { CanvasRenderingContext2D.prototype.database = function (x, y, w, h) {
var f = 1 / 3; var f = 1 / 3;
@ -209,6 +229,11 @@ if (typeof CanvasRenderingContext2D !== 'undefined') {
/** /**
* Draw an arrow at the end of a line with the given angle. * Draw an arrow at the end of a line with the given angle.
*
* @param {Number} x
* @param {Number} y
* @param {Number} angle
* @param {Number} length
*/ */
CanvasRenderingContext2D.prototype.arrowEndpoint = function (x, y, angle, length) { CanvasRenderingContext2D.prototype.arrowEndpoint = function (x, y, angle, length) {
// tail // tail
@ -237,6 +262,11 @@ if (typeof CanvasRenderingContext2D !== 'undefined') {
/** /**
* Draw an circle an the end of an line with the given angle. * Draw an circle an the end of an line with the given angle.
*
* @param {Number} x
* @param {Number} y
* @param {Number} angle
* @param {Number} length
*/ */
CanvasRenderingContext2D.prototype.circleEndpoint = function (x, y, angle, length) { CanvasRenderingContext2D.prototype.circleEndpoint = function (x, y, angle, length) {
var radius = length * 0.4; var radius = length * 0.4;
@ -250,6 +280,12 @@ if (typeof CanvasRenderingContext2D !== 'undefined') {
* Original code came from http://stackoverflow.com/questions/4576724/dotted-stroke-in-canvas * Original code came from http://stackoverflow.com/questions/4576724/dotted-stroke-in-canvas
* @author David Jordan * @author David Jordan
* @date 2012-08-08 * @date 2012-08-08
*
* @param {Number} x
* @param {Number} y
* @param {Number} x2
* @param {Number} y2
* @param {String} pattern
*/ */
CanvasRenderingContext2D.prototype.dashedLine = function (x, y, x2, y2, pattern) { CanvasRenderingContext2D.prototype.dashedLine = function (x, y, x2, y2, pattern) {
this.beginPath(); this.beginPath();

+ 1
- 1
lib/shared/Activator.js View File

@ -125,7 +125,7 @@ Activator.prototype.deactivate = function () {
/** /**
* Handle a tap event: activate the container * Handle a tap event: activate the container
* @param event
* @param {Event} event The event
* @private * @private
*/ */
Activator.prototype._onTapOverlay = function (event) { Activator.prototype._onTapOverlay = function (event) {

+ 12
- 12
lib/shared/ColorPicker.js View File

@ -25,7 +25,7 @@ class ColorPicker {
/** /**
* this inserts the colorPicker into a div from the DOM * this inserts the colorPicker into a div from the DOM
* @param container
* @param {Element} container
*/ */
insertTo(container) { insertTo(container) {
if (this.hammer !== undefined) { if (this.hammer !== undefined) {
@ -41,7 +41,7 @@ class ColorPicker {
/** /**
* the callback is executed on apply and save. Bind it to the application * the callback is executed on apply and save. Bind it to the application
* @param callback
* @param {function} callback
*/ */
setUpdateCallback(callback) { setUpdateCallback(callback) {
if (typeof callback === 'function') { if (typeof callback === 'function') {
@ -54,7 +54,7 @@ class ColorPicker {
/** /**
* the callback is executed on apply and save. Bind it to the application * the callback is executed on apply and save. Bind it to the application
* @param callback
* @param {function} callback
*/ */
setCloseCallback(callback) { setCloseCallback(callback) {
if (typeof callback === 'function') { if (typeof callback === 'function') {
@ -82,8 +82,8 @@ class ColorPicker {
* 'rgba(255,255,255,1.0)' --> rgba string * 'rgba(255,255,255,1.0)' --> rgba string
* {r:255,g:255,b:255} --> rgb object * {r:255,g:255,b:255} --> rgb object
* {r:255,g:255,b:255,a:1.0} --> rgba object * {r:255,g:255,b:255,a:1.0} --> rgba object
* @param color
* @param setInitial
* @param {String|Object} color
* @param {boolean} [setInitial=true]
*/ */
setColor(color, setInitial = true) { setColor(color, setInitial = true) {
if (color === 'none') { if (color === 'none') {
@ -152,7 +152,7 @@ class ColorPicker {
/** /**
* Hide the picker. Is called by the cancel button. * Hide the picker. Is called by the cancel button.
* Optional boolean to store the previous color for easy access later on. * Optional boolean to store the previous color for easy access later on.
* @param storePrevious
* @param {boolean} [storePrevious=true]
* @private * @private
*/ */
_hide(storePrevious = true) { _hide(storePrevious = true) {
@ -216,8 +216,8 @@ class ColorPicker {
/** /**
* set the color, place the picker * set the color, place the picker
* @param rgba
* @param setInitial
* @param {Object} rgba
* @param {boolean} [setInitial=true]
* @private * @private
*/ */
_setColor(rgba, setInitial = true) { _setColor(rgba, setInitial = true) {
@ -243,7 +243,7 @@ class ColorPicker {
/** /**
* bound to opacity control * bound to opacity control
* @param value
* @param {number} value
* @private * @private
*/ */
_setOpacity(value) { _setOpacity(value) {
@ -254,7 +254,7 @@ class ColorPicker {
/** /**
* bound to brightness control * bound to brightness control
* @param value
* @param {number} value
* @private * @private
*/ */
_setBrightness(value) { _setBrightness(value) {
@ -269,7 +269,7 @@ class ColorPicker {
/** /**
* update the color picker. A black circle overlays the hue circle to mimic the brightness decreasing. * update the color picker. A black circle overlays the hue circle to mimic the brightness decreasing.
* @param rgba
* @param {Object} rgba
* @private * @private
*/ */
_updatePicker(rgba = this.color) { _updatePicker(rgba = this.color) {
@ -515,7 +515,7 @@ class ColorPicker {
/** /**
* move the selector. This is called by hammer functions. * move the selector. This is called by hammer functions.
* *
* @param event
* @param {Event} event The event
* @private * @private
*/ */
_moveSelector(event) { _moveSelector(event) {

+ 41
- 40
lib/shared/Configurator.js View File

@ -11,10 +11,10 @@ var ColorPicker = require('./ColorPicker').default;
* *
* The options are matched with their counterparts in each of the modules and the values used in the configuration are * The options are matched with their counterparts in each of the modules and the values used in the configuration are
* *
* @param parentModule | the location where parentModule.setOptions() can be called
* @param defaultContainer | the default container of the module
* @param configureOptions | the fully configured and predefined options set found in allOptions.js
* @param pixelRatio | canvas pixel ratio
* @param {Object} parentModule | the location where parentModule.setOptions() can be called
* @param {Object} defaultContainer | the default container of the module
* @param {Object} configureOptions | the fully configured and predefined options set found in allOptions.js
* @param {Number} pixelRatio | canvas pixel ratio
*/ */
class Configurator { class Configurator {
constructor(parentModule, defaultContainer, configureOptions, pixelRatio = 1) { constructor(parentModule, defaultContainer, configureOptions, pixelRatio = 1) {
@ -49,7 +49,7 @@ class Configurator {
* refresh all options. * refresh all options.
* Because all modules parse their options by themselves, we just use their options. We copy them here. * Because all modules parse their options by themselves, we just use their options. We copy them here.
* *
* @param options
* @param {Object} options
*/ */
setOptions(options) { setOptions(options) {
if (options !== undefined) { if (options !== undefined) {
@ -225,8 +225,9 @@ class Configurator {
/** /**
* all option elements are wrapped in an item * all option elements are wrapped in an item
* @param path
* @param domElements
* @param {Array} path | where to look for the actual option
* @param {Array<Element>} domElements
* @returns {Number}
* @private * @private
*/ */
_makeItem(path, ...domElements) { _makeItem(path, ...domElements) {
@ -245,7 +246,7 @@ class Configurator {
/** /**
* header for major subjects * header for major subjects
* @param name
* @param {string} name
* @private * @private
*/ */
_makeHeader(name) { _makeHeader(name) {
@ -258,9 +259,9 @@ class Configurator {
/** /**
* make a label, if it is an object label, it gets different styling. * make a label, if it is an object label, it gets different styling.
* @param name
* @param path
* @param objectLabel
* @param {string} name
* @param {array} path | where to look for the actual option
* @param {string} objectLabel
* @returns {HTMLElement} * @returns {HTMLElement}
* @private * @private
*/ */
@ -279,9 +280,9 @@ class Configurator {
/** /**
* make a dropdown list for multiple possible string optoins * make a dropdown list for multiple possible string optoins
* @param arr
* @param value
* @param path
* @param {Array<number>} arr
* @param {number} value
* @param {array} path | where to look for the actual option
* @private * @private
*/ */
_makeDropdown(arr, value, path) { _makeDropdown(arr, value, path) {
@ -314,9 +315,9 @@ class Configurator {
/** /**
* make a range object for numeric options * make a range object for numeric options
* @param arr
* @param value
* @param path
* @param {Array<number>} arr
* @param {number} value
* @param {array} path | where to look for the actual option
* @private * @private
*/ */
_makeRange(arr, value, path) { _makeRange(arr, value, path) {
@ -384,8 +385,8 @@ class Configurator {
/** /**
* prepare the popup * prepare the popup
* @param string
* @param index
* @param {string} string
* @param {Number} index
* @private * @private
*/ */
_setupPopup(string, index) { _setupPopup(string, index) {
@ -437,9 +438,9 @@ class Configurator {
/** /**
* make a checkbox for boolean options. * make a checkbox for boolean options.
* @param defaultValue
* @param value
* @param path
* @param {number} defaultValue
* @param {number} value
* @param {array} path | where to look for the actual option
* @private * @private
*/ */
_makeCheckbox(defaultValue, value, path) { _makeCheckbox(defaultValue, value, path) {
@ -470,9 +471,9 @@ class Configurator {
/** /**
* make a text input field for string options. * make a text input field for string options.
* @param defaultValue
* @param value
* @param path
* @param {number} defaultValue
* @param {number} value
* @param {array} path | where to look for the actual option
* @private * @private
*/ */
_makeTextInput(defaultValue, value, path) { _makeTextInput(defaultValue, value, path) {
@ -494,9 +495,9 @@ class Configurator {
/** /**
* make a color field with a color picker for color fields * make a color field with a color picker for color fields
* @param arr
* @param value
* @param path
* @param {Array<number>} arr
* @param {number} value
* @param {array} path | where to look for the actual option
* @private * @private
*/ */
_makeColorField(arr, value, path) { _makeColorField(arr, value, path) {
@ -524,10 +525,9 @@ class Configurator {
/** /**
* used by the color buttons to call the color picker. * used by the color buttons to call the color picker.
* @param event
* @param value
* @param div
* @param path
* @param {number} value
* @param {HTMLElement} div
* @param {array} path | where to look for the actual option
* @private * @private
*/ */
_showColorPicker(value, div, path) { _showColorPicker(value, div, path) {
@ -555,8 +555,10 @@ class Configurator {
/** /**
* parse an object and draw the correct items * parse an object and draw the correct items
* @param obj
* @param path
* @param {Object} obj
* @param {array} [path=[]] | where to look for the actual option
* @param {boolean} [checkOnly=false]
* @returns {boolean}
* @private * @private
*/ */
_handleObject(obj, path = [], checkOnly = false) { _handleObject(obj, path = [], checkOnly = false) {
@ -636,10 +638,9 @@ class Configurator {
/** /**
* handle the array type of option * handle the array type of option
* @param optionName
* @param arr
* @param value
* @param path
* @param {Array<number>} arr
* @param {number} value
* @param {array} path | where to look for the actual option
* @private * @private
*/ */
_handleArray(arr, value, path) { _handleArray(arr, value, path) {
@ -661,8 +662,8 @@ class Configurator {
/** /**
* called to update the network with the new settings. * called to update the network with the new settings.
* @param value
* @param path
* @param {number} value
* @param {array} path | where to look for the actual option
* @private * @private
*/ */
_update(value, path) { _update(value, path) {

+ 15
- 14
lib/shared/Validator.js View File

@ -12,8 +12,9 @@ class Validator {
/** /**
* Main function to be called * Main function to be called
* @param options
* @param subObject
* @param {Object} options
* @param {Object} referenceOptions
* @param {Object} subObject
* @returns {boolean} * @returns {boolean}
*/ */
static validate(options, referenceOptions, subObject) { static validate(options, referenceOptions, subObject) {
@ -30,9 +31,9 @@ class Validator {
/** /**
* Will traverse an object recursively and check every value * Will traverse an object recursively and check every value
* @param options
* @param referenceOptions
* @param path
* @param {Object} options
* @param {Object} referenceOptions
* @param {array} path | where to look for the actual option
*/ */
static parse(options, referenceOptions, path) { static parse(options, referenceOptions, path) {
for (let option in options) { for (let option in options) {
@ -45,10 +46,10 @@ class Validator {
/** /**
* Check every value. If the value is an object, call the parse function on that object. * Check every value. If the value is an object, call the parse function on that object.
* @param option
* @param options
* @param referenceOptions
* @param path
* @param {String} option
* @param {Object} options
* @param {Object} referenceOptions
* @param {array} path | where to look for the actual option
*/ */
static check(option, options, referenceOptions, path) { static check(option, options, referenceOptions, path) {
if (referenceOptions[option] === undefined && referenceOptions.__any__ === undefined) { if (referenceOptions[option] === undefined && referenceOptions.__any__ === undefined) {
@ -91,7 +92,7 @@ class Validator {
* @param {Object} options | The supplied options object * @param {Object} options | The supplied options object
* @param {Object} referenceOptions | The reference options containing all options and their allowed formats * @param {Object} referenceOptions | The reference options containing all options and their allowed formats
* @param {String} referenceOption | Usually this is the same as option, except when handling an __any__ tag. * @param {String} referenceOption | Usually this is the same as option, except when handling an __any__ tag.
* @param {String} refOptionType | This is the type object from the reference options
* @param {String} refOptionObj | This is the type object from the reference options
* @param {Array} path | where in the object is the option * @param {Array} path | where in the object is the option
*/ */
static checkFields(option, options, referenceOptions, referenceOption, refOptionObj, path) { static checkFields(option, options, referenceOptions, referenceOption, refOptionObj, path) {
@ -202,10 +203,10 @@ class Validator {
/** /**
* traverse the options in search for a match. * traverse the options in search for a match.
* @param option
* @param options
* @param path
* @param recursive
* @param {String} option
* @param {Object} options
* @param {Array} path | where to look for the actual option
* @param {Boolean} [recursive=false]
* @returns {{closestMatch: string, path: Array, distance: number}} * @returns {{closestMatch: string, path: Array, distance: number}}
*/ */
static findInOptions(option, options, path, recursive = false) { static findInOptions(option, options, path, recursive = false) {

+ 1
- 1
lib/timeline/component/Group.js View File

@ -2,10 +2,10 @@ var util = require('../../util');
var stack = require('../Stack'); var stack = require('../Stack');
/** /**
* @constructor Group
* @param {Number | String} groupId * @param {Number | String} groupId
* @param {Object} data * @param {Object} data
* @param {ItemSet} itemSet * @param {ItemSet} itemSet
* @constructor Group
*/ */
function Group (groupId, data, itemSet) { function Group (groupId, data, itemSet) {
this.groupId = groupId; this.groupId = groupId;

+ 50
- 45
lib/util.js View File

@ -19,7 +19,7 @@ exports.isNumber = function (object) {
/** /**
* Remove everything in the DOM object * Remove everything in the DOM object
* @param DOMobject
* @param {Element} DOMobject
*/ */
exports.recursiveDOMDelete = function (DOMobject) { exports.recursiveDOMDelete = function (DOMobject) {
if (DOMobject) { if (DOMobject) {
@ -33,10 +33,10 @@ exports.recursiveDOMDelete = function (DOMobject) {
/** /**
* this function gives you a range between 0 and 1 based on the min and max values in the set, the total sum of all values and the current value. * this function gives you a range between 0 and 1 based on the min and max values in the set, the total sum of all values and the current value.
* *
* @param min
* @param max
* @param total
* @param value
* @param {number} min
* @param {number} max
* @param {number} total
* @param {number} value
* @returns {number} * @returns {number}
*/ */
exports.giveRange = function (min, max, total, value) { exports.giveRange = function (min, max, total, value) {
@ -47,7 +47,7 @@ exports.giveRange = function (min, max, total, value) {
var scale = 1 / (max - min); var scale = 1 / (max - min);
return Math.max(0, (value - min) * scale); return Math.max(0, (value - min) * scale);
} }
}
};
/** /**
* Test whether given object is a string * Test whether given object is a string
@ -92,8 +92,8 @@ exports.randomUUID = function () {
/** /**
* assign all keys of an object that are not nested objects to a certain value (used for color objects). * assign all keys of an object that are not nested objects to a certain value (used for color objects).
* @param obj
* @param value
* @param {object} obj
* @param {number} value
*/ */
exports.assignAllKeys = function (obj, value) { exports.assignAllKeys = function (obj, value) {
for (var prop in obj) { for (var prop in obj) {
@ -103,14 +103,15 @@ exports.assignAllKeys = function (obj, value) {
} }
} }
} }
}
};
/** /**
* Fill an object with a possibly partially defined other object. Only copies values if the a object has an object requiring values. * Fill an object with a possibly partially defined other object. Only copies values if the a object has an object requiring values.
* That means an object is not created on a property if only the b object has it. * That means an object is not created on a property if only the b object has it.
* @param obj
* @param value
* @param {object} a
* @param {object} b
* @param {boolean} [allowDeletion=false]
*/ */
exports.fillIfDefined = function (a, b, allowDeletion = false) { exports.fillIfDefined = function (a, b, allowDeletion = false) {
for (var prop in a) { for (var prop in a) {
@ -130,7 +131,7 @@ exports.fillIfDefined = function (a, b, allowDeletion = false) {
} }
} }
} }
}
};
@ -202,6 +203,7 @@ exports.selectiveExtend = function (props, a, b) { // eslint-disable-line no-un
* @param {Array.<String>} props * @param {Array.<String>} props
* @param {Object} a * @param {Object} a
* @param {Object} b * @param {Object} b
* @param {Boolean} [allowDeletion=false]
* @return {Object} a * @return {Object} a
*/ */
exports.selectiveDeepExtend = function (props, a, b, allowDeletion = false) { exports.selectiveDeepExtend = function (props, a, b, allowDeletion = false) {
@ -252,6 +254,7 @@ exports.selectiveDeepExtend = function (props, a, b, allowDeletion = false) {
* @param {Array.<String>} props * @param {Array.<String>} props
* @param {Object} a * @param {Object} a
* @param {Object} b * @param {Object} b
* @param {Boolean} [allowDeletion=false]
* @return {Object} a * @return {Object} a
*/ */
exports.selectiveNotDeepExtend = function (props, a, b, allowDeletion = false) { exports.selectiveNotDeepExtend = function (props, a, b, allowDeletion = false) {
@ -300,9 +303,9 @@ exports.selectiveNotDeepExtend = function (props, a, b, allowDeletion = false) {
* Deep extend an object a with the properties of object b * Deep extend an object a with the properties of object b
* @param {Object} a * @param {Object} a
* @param {Object} b * @param {Object} b
* @param [Boolean] protoExtend --> optional parameter. If true, the prototype values will also be extended.
* (ie. the options objects that inherit from others will also get the inherited options)
* @param [Boolean] global --> optional parameter. If true, the values of fields that are null will not deleted
* @param {Boolean} [protoExtend] --> optional parameter. If true, the prototype values will also be extended.
* (ie. the options objects that inherit from others will also get the inherited options)
* @param {Boolean} [allowDeletion] --> optional parameter. If true, the values of fields that are null will not deleted
* @returns {Object} * @returns {Object}
*/ */
exports.deepExtend = function (a, b, protoExtend, allowDeletion) { exports.deepExtend = function (a, b, protoExtend, allowDeletion) {
@ -564,8 +567,8 @@ exports.getType = function (object) {
/** /**
* Used to extend an array and copy it. This is used to propagate paths recursively. * Used to extend an array and copy it. This is used to propagate paths recursively.
* *
* @param arr
* @param newValue
* @param {Array} arr
* @param {*} newValue
* @returns {Array} * @returns {Array}
*/ */
exports.copyAndExtendArray = function (arr, newValue) { exports.copyAndExtendArray = function (arr, newValue) {
@ -575,13 +578,12 @@ exports.copyAndExtendArray = function (arr, newValue) {
} }
newArr.push(newValue); newArr.push(newValue);
return newArr; return newArr;
}
};
/** /**
* Used to extend an array and copy it. This is used to propagate paths recursively. * Used to extend an array and copy it. This is used to propagate paths recursively.
* *
* @param arr
* @param newValue
* @param {Array} arr
* @returns {Array} * @returns {Array}
*/ */
exports.copyArray = function (arr) { exports.copyArray = function (arr) {
@ -590,7 +592,7 @@ exports.copyArray = function (arr) {
newArr.push(arr[i]); newArr.push(arr[i]);
} }
return newArr; return newArr;
}
};
/** /**
* Retrieve the absolute left value of a DOM element * Retrieve the absolute left value of a DOM element
@ -619,7 +621,7 @@ exports.getAbsoluteTop = function (elem) {
/** /**
* add a className to the given elements style * add a className to the given elements style
* @param {Element} elem * @param {Element} elem
* @param {String} className
* @param {String} classNames
*/ */
exports.addClassName = function (elem, classNames) { exports.addClassName = function (elem, classNames) {
var classes = elem.className.split(' '); var classes = elem.className.split(' ');
@ -633,7 +635,7 @@ exports.addClassName = function (elem, classNames) {
/** /**
* add a className to the given elements style * add a className to the given elements style
* @param {Element} elem * @param {Element} elem
* @param {String} className
* @param {String} classNames
*/ */
exports.removeClassName = function (elem, classNames) { exports.removeClassName = function (elem, classNames) {
var classes = elem.className.split(' '); var classes = elem.className.split(' ');
@ -676,7 +678,7 @@ exports.forEach = function (object, callback) {
* Convert an object into an array: all objects properties are put into the * Convert an object into an array: all objects properties are put into the
* array. The resulting array is unordered. * array. The resulting array is unordered.
* @param {Object} object * @param {Object} object
* @param {Array} array
* @returns {Array} array
*/ */
exports.toArray = function (object) { exports.toArray = function (object) {
var array = []; var array = [];
@ -773,6 +775,7 @@ exports.removeEventListener = function (element, action, listener, useCapture) {
/** /**
* Cancels the event if it is cancelable, without stopping further propagation of the event. * Cancels the event if it is cancelable, without stopping further propagation of the event.
* @param {Event} event
*/ */
exports.preventDefault = function (event) { exports.preventDefault = function (event) {
if (!event) if (!event)
@ -818,6 +821,7 @@ exports.getTarget = function (event) {
* Check if given element contains given parent somewhere in the DOM tree * Check if given element contains given parent somewhere in the DOM tree
* @param {Element} element * @param {Element} element
* @param {Element} parent * @param {Element} parent
* @returns {boolean}
*/ */
exports.hasParent = function (element, parent) { exports.hasParent = function (element, parent) {
var e = element; var e = element;
@ -946,9 +950,9 @@ exports.hexToRGB = function (hex) {
/** /**
* This function takes color in hex format or rgb() or rgba() format and overrides the opacity. Returns rgba() string. * This function takes color in hex format or rgb() or rgba() format and overrides the opacity. Returns rgba() string.
* @param color
* @param opacity
* @returns {*}
* @param {String} color
* @param {Number} opacity
* @returns {String}
*/ */
exports.overrideOpacity = function (color, opacity) { exports.overrideOpacity = function (color, opacity) {
var rgb; var rgb;
@ -972,10 +976,10 @@ exports.overrideOpacity = function (color, opacity) {
/** /**
* *
* @param red 0 -- 255
* @param green 0 -- 255
* @param blue 0 -- 255
* @returns {string}
* @param {Number} red 0 -- 255
* @param {Number} green 0 -- 255
* @param {Number} blue 0 -- 255
* @returns {String}
* @constructor * @constructor
*/ */
exports.RGBToHex = function (red, green, blue) { exports.RGBToHex = function (red, green, blue) {
@ -1067,10 +1071,10 @@ exports.parseColor = function (color) {
/** /**
* http://www.javascripter.net/faq/rgb2hsv.htm * http://www.javascripter.net/faq/rgb2hsv.htm
* *
* @param red
* @param green
* @param blue
* @returns {*}
* @param {Number} red
* @param {Number} green
* @param {Number} blue
* @returns {{h: Number, s: Number, v: Number}}
* @constructor * @constructor
*/ */
exports.RGBToHSV = function (red, green, blue) { exports.RGBToHSV = function (red, green, blue) {
@ -1152,9 +1156,9 @@ exports.removeCssText = function (element, cssText) {
/** /**
* https://gist.github.com/mjijackson/5311256 * https://gist.github.com/mjijackson/5311256
* @param h
* @param s
* @param v
* @param {Number} h
* @param {Number} s
* @param {Number} v
* @returns {{r: number, g: number, b: number}} * @returns {{r: number, g: number, b: number}}
* @constructor * @constructor
*/ */
@ -1198,18 +1202,19 @@ exports.isValidRGB = function (rgb) {
rgb = rgb.replace(" ", ""); rgb = rgb.replace(" ", "");
var isOk = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/i.test(rgb); var isOk = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/i.test(rgb);
return isOk; return isOk;
}
};
exports.isValidRGBA = function (rgba) { exports.isValidRGBA = function (rgba) {
rgba = rgba.replace(" ", ""); rgba = rgba.replace(" ", "");
var isOk = /rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(.{1,3})\)/i.test(rgba); var isOk = /rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(.{1,3})\)/i.test(rgba);
return isOk; return isOk;
}
};
/** /**
* This recursively redirects the prototype of JSON objects to the referenceObject * This recursively redirects the prototype of JSON objects to the referenceObject
* This is used for default options. * This is used for default options.
* *
* @param referenceObject
* @param {Array<String>} fields
* @param {Object} referenceObject
* @returns {*} * @returns {*}
*/ */
exports.selectiveBridgeObject = function (fields, referenceObject) { exports.selectiveBridgeObject = function (fields, referenceObject) {
@ -1233,7 +1238,7 @@ exports.selectiveBridgeObject = function (fields, referenceObject) {
* This recursively redirects the prototype of JSON objects to the referenceObject * This recursively redirects the prototype of JSON objects to the referenceObject
* This is used for default options. * This is used for default options.
* *
* @param referenceObject
* @param {Object} referenceObject
* @returns {*} * @returns {*}
*/ */
exports.bridgeObject = function (referenceObject) { exports.bridgeObject = function (referenceObject) {
@ -1262,9 +1267,9 @@ exports.bridgeObject = function (referenceObject) {
/** /**
* This method provides a stable sort implementation, very fast for presorted data * This method provides a stable sort implementation, very fast for presorted data
* *
* @param a the array
* @param a order comparator
* @returns {the array}
* @param {Array} a the array
* @param {function} compare an order comparator
* @returns {Array}
*/ */
exports.insertSort = function (a,compare) { exports.insertSort = function (a,compare) {
for (var i = 0; i < a.length; i++) { for (var i = 0; i < a.length; i++) {

Loading…
Cancel
Save