Browse Source

updated history, added function documentation

css_transitions
Alex de Mulder 10 years ago
parent
commit
5e6718b164
13 changed files with 241 additions and 45 deletions
  1. +1
    -1
      HISTORY.md
  2. +120
    -22
      dist/vis.js
  3. +1
    -1
      src/graph/Edge.js
  4. +36
    -5
      src/graph/Graph.js
  5. +1
    -0
      src/graph/Node.js
  6. +4
    -2
      src/graph/graphMixins/ClusterMixin.js
  7. +3
    -3
      src/graph/graphMixins/HierarchicalLayoutMixin.js
  8. +0
    -2
      src/graph/graphMixins/ManipulationMixin.js
  9. +6
    -6
      src/graph/graphMixins/MixinLoader.js
  10. +1
    -1
      src/graph/graphMixins/SelectionMixin.js
  11. +23
    -0
      src/graph/graphMixins/physics/BarnesHut.js
  12. +29
    -1
      src/graph/graphMixins/physics/PhysicsMixin.js
  13. +16
    -1
      src/timeline/component/ItemSet.js

+ 1
- 1
HISTORY.md View File

@ -7,7 +7,7 @@ http://visjs.org
### Timeline ### Timeline
- Large refactoring of the Timeline, simplifying the code. - Large refactoring of the Timeline, simplifying the code.
- Performance improvements.
- Great performance improvements.
- Improved layout of box-items inside groups. - Improved layout of box-items inside groups.
- Function `setWindow` now accepts an object with properties `start` and `end`. - Function `setWindow` now accepts an object with properties `start` and `end`.
- Fixed option `autoResize` forcing a repaint of the Timeline with every check - Fixed option `autoResize` forcing a repaint of the Timeline with every check

+ 120
- 22
dist/vis.js View File

@ -5034,7 +5034,13 @@ ItemSet.prototype._binarySearch = function _binarySearch(byEnd) {
return guess; return guess;
} }
/**
* this function checks if an item is invisible. If it is NOT we make it visible and add it to the global visible items. If it is, return true.
*
* @param {itemRange | itemPoint | itemBox} item
* @returns {boolean}
* @private
*/
ItemSet.prototype._checkIfInvisible = function _checkIfInvisible(item) { ItemSet.prototype._checkIfInvisible = function _checkIfInvisible(item) {
if (item.isVisible(this.range)) { if (item.isVisible(this.range)) {
if (!item.displayed) item.show(); if (!item.displayed) item.show();
@ -5049,6 +5055,15 @@ ItemSet.prototype._checkIfInvisible = function _checkIfInvisible(item) {
} }
}; };
/**
* this function is very similar to the _checkIfInvisible() but it does not return booleans, hides the item if it should not be seen and always adds to the visibleItems.
* this one is for brute forcing and hiding.
*
* @param {itemRange | itemPoint | itemBox} item
* @param {array} visibleItems
* @private
*/
ItemSet.prototype._checkIfVisible = function _checkIfVisible(item, visibleItems) { ItemSet.prototype._checkIfVisible = function _checkIfVisible(item, visibleItems) {
if (item.isVisible(this.range)) { if (item.isVisible(this.range)) {
if (!item.displayed) item.show(); if (!item.displayed) item.show();
@ -9259,6 +9274,7 @@ Node.prototype.discreteStep = function(interval) {
/** /**
* Perform one discrete step for the node * Perform one discrete step for the node
* @param {number} interval Time interval in seconds * @param {number} interval Time interval in seconds
* @param {number} maxVelocity The speed limit imposed on the velocity
*/ */
Node.prototype.discreteStepLimited = function(interval, maxVelocity) { Node.prototype.discreteStepLimited = function(interval, maxVelocity) {
if (!this.xFixed) { if (!this.xFixed) {
@ -9966,7 +9982,7 @@ Edge.prototype.setProperties = function(properties, constants) {
this.customLength = true;} this.customLength = true;}
// scale the arrow // scale the arrow
if (properties.arrowScaleFactor !== undefined) {this.arrowScaleFactor = properties.arrowScaleFactor};
if (properties.arrowScaleFactor !== undefined) {this.arrowScaleFactor = properties.arrowScaleFactor;}
// Added to support dashed lines // Added to support dashed lines
// David Jordan // David Jordan
@ -11366,6 +11382,13 @@ var physicsMixin = {
} }
}, },
/**
* This overwrites the this.constants.
*
* @param constantsVariableName
* @param value
* @private
*/
_overWriteGraphConstants: function (constantsVariableName, value) { _overWriteGraphConstants: function (constantsVariableName, value) {
var nameArray = constantsVariableName.split("_"); var nameArray = constantsVariableName.split("_");
if (nameArray.length == 1) { if (nameArray.length == 1) {
@ -11380,6 +11403,9 @@ var physicsMixin = {
} }
}; };
/**
* this function is bound to the toggle smooth curves button. That is also why it is not in the prototype.
*/
function graphToggleSmoothCurves () { function graphToggleSmoothCurves () {
this.constants.smoothCurves = !this.constants.smoothCurves; this.constants.smoothCurves = !this.constants.smoothCurves;
var graph_toggleSmooth = document.getElementById("graph_toggleSmooth"); var graph_toggleSmooth = document.getElementById("graph_toggleSmooth");
@ -11389,6 +11415,10 @@ function graphToggleSmoothCurves () {
this._configureSmoothCurves(false); this._configureSmoothCurves(false);
}; };
/**
* this function is used to scramble the nodes
*
*/
function graphRepositionNodes () { function graphRepositionNodes () {
for (var nodeId in this.calculationNodes) { for (var nodeId in this.calculationNodes) {
if (this.calculationNodes.hasOwnProperty(nodeId)) { if (this.calculationNodes.hasOwnProperty(nodeId)) {
@ -11406,6 +11436,9 @@ function graphRepositionNodes () {
this.start(); this.start();
}; };
/**
* this is used to generate an options file from the playing with physics system.
*/
function graphGenerateOptions () { function graphGenerateOptions () {
var options = "No options are required, default values used."; var options = "No options are required, default values used.";
var optionsSpecific = []; var optionsSpecific = [];
@ -11503,7 +11536,10 @@ function graphGenerateOptions () {
}; };
/**
* this is used to switch between barnesHut, repulsion and hierarchical.
*
*/
function switchConfigurations () { function switchConfigurations () {
var ids = ["graph_BH_table", "graph_R_table", "graph_H_table"]; var ids = ["graph_BH_table", "graph_R_table", "graph_H_table"];
var radioButton = document.querySelector('input[name="graph_physicsMethod"]:checked').value; var radioButton = document.querySelector('input[name="graph_physicsMethod"]:checked').value;
@ -11542,6 +11578,14 @@ function switchConfigurations () {
} }
/**
* this generates the ranges depending on the iniital values.
*
* @param id
* @param map
* @param constantsVariableName
*/
function showValueOfRange (id,map,constantsVariableName) { function showValueOfRange (id,map,constantsVariableName) {
var valueId = id + "_value"; var valueId = id + "_value";
var rangeValue = document.getElementById(id).value; var rangeValue = document.getElementById(id).value;
@ -11788,6 +11832,13 @@ var barnesHutMixin = {
}, },
/**
* this updates the mass of a branch. this is increased by adding a node.
*
* @param parentBranch
* @param node
* @private
*/
_updateBranchMass : function(parentBranch, node) { _updateBranchMass : function(parentBranch, node) {
var totalMass = parentBranch.mass + node.mass; var totalMass = parentBranch.mass + node.mass;
var totalMassInv = 1/totalMass; var totalMassInv = 1/totalMass;
@ -11805,6 +11856,14 @@ var barnesHutMixin = {
}, },
/**
* determine in which branch the node will be placed.
*
* @param parentBranch
* @param node
* @param skipMassUpdate
* @private
*/
_placeInTree : function(parentBranch,node,skipMassUpdate) { _placeInTree : function(parentBranch,node,skipMassUpdate) {
if (skipMassUpdate != true || skipMassUpdate === undefined) { if (skipMassUpdate != true || skipMassUpdate === undefined) {
// update the mass of the branch. // update the mass of the branch.
@ -11830,6 +11889,14 @@ var barnesHutMixin = {
}, },
/**
* actually place the node in a region (or branch)
*
* @param parentBranch
* @param node
* @param region
* @private
*/
_placeInRegion : function(parentBranch,node,region) { _placeInRegion : function(parentBranch,node,region) {
switch (parentBranch.children[region].childrenCount) { switch (parentBranch.children[region].childrenCount) {
case 0: // place node here case 0: // place node here
@ -12196,7 +12263,7 @@ var HierarchicalLayoutMixin = {
*/ */
_getDistribution : function() { _getDistribution : function() {
var distribution = {}; var distribution = {};
var nodeId, node;
var nodeId, node, level;
// we fix Y because the hierarchy is vertical, we fix X so we do not give a node an x position for a second time. // we fix Y because the hierarchy is vertical, we fix X so we do not give a node an x position for a second time.
// the fix of X is removed after the x value has been set. // the fix of X is removed after the x value has been set.
@ -12221,7 +12288,7 @@ var HierarchicalLayoutMixin = {
// determine the largest amount of nodes of all levels // determine the largest amount of nodes of all levels
var maxCount = 0; var maxCount = 0;
for (var level in distribution) {
for (level in distribution) {
if (distribution.hasOwnProperty(level)) { if (distribution.hasOwnProperty(level)) {
if (maxCount < distribution[level].amount) { if (maxCount < distribution[level].amount) {
maxCount = distribution[level].amount; maxCount = distribution[level].amount;
@ -12230,7 +12297,7 @@ var HierarchicalLayoutMixin = {
} }
// set the initial position and spacing of each nodes accordingly // set the initial position and spacing of each nodes accordingly
for (var level in distribution) {
for (level in distribution) {
if (distribution.hasOwnProperty(level)) { if (distribution.hasOwnProperty(level)) {
distribution[level].nodeSpacing = (maxCount + 1) * this.constants.hierarchicalLayout.nodeSpacing; distribution[level].nodeSpacing = (maxCount + 1) * this.constants.hierarchicalLayout.nodeSpacing;
distribution[level].nodeSpacing /= (distribution[level].amount + 1); distribution[level].nodeSpacing /= (distribution[level].amount + 1);
@ -12672,8 +12739,6 @@ var manipulationMixin = {
/** /**
* Adds a node on the specified location * Adds a node on the specified location
*
* @param {Object} pointer
*/ */
_addNode : function() { _addNode : function() {
if (this._selectionIsEmpty() && this.editMode == true) { if (this._selectionIsEmpty() && this.editMode == true) {
@ -13508,6 +13573,7 @@ var ClusterMixin = {
* @param {Number} zoomDirection | -1 / 0 / +1 for zoomOut / determineByZoom / zoomIn * @param {Number} zoomDirection | -1 / 0 / +1 for zoomOut / determineByZoom / zoomIn
* @param {Boolean} recursive | enabled or disable recursive calling of the opening of clusters * @param {Boolean} recursive | enabled or disable recursive calling of the opening of clusters
* @param {Boolean} force | enabled or disable forcing * @param {Boolean} force | enabled or disable forcing
* @param {Boolean} doNotStart | if true do not call start
* *
*/ */
updateClusters : function(zoomDirection,recursive,force,doNotStart) { updateClusters : function(zoomDirection,recursive,force,doNotStart) {
@ -14358,9 +14424,10 @@ var ClusterMixin = {
var maxLevel = 0; var maxLevel = 0;
var minLevel = 1e9; var minLevel = 1e9;
var clusterLevel = 0; var clusterLevel = 0;
var nodeId;
// we loop over all nodes in the list // we loop over all nodes in the list
for (var nodeId in this.nodes) {
for (nodeId in this.nodes) {
if (this.nodes.hasOwnProperty(nodeId)) { if (this.nodes.hasOwnProperty(nodeId)) {
clusterLevel = this.nodes[nodeId].clusterSessions.length; clusterLevel = this.nodes[nodeId].clusterSessions.length;
if (maxLevel < clusterLevel) {maxLevel = clusterLevel;} if (maxLevel < clusterLevel) {maxLevel = clusterLevel;}
@ -14372,7 +14439,7 @@ var ClusterMixin = {
var amountOfNodes = this.nodeIndices.length; var amountOfNodes = this.nodeIndices.length;
var targetLevel = maxLevel - this.constants.clustering.clusterLevelDifference; var targetLevel = maxLevel - this.constants.clustering.clusterLevelDifference;
// we loop over all nodes in the list // we loop over all nodes in the list
for (var nodeId in this.nodes) {
for (nodeId in this.nodes) {
if (this.nodes.hasOwnProperty(nodeId)) { if (this.nodes.hasOwnProperty(nodeId)) {
if (this.nodes[nodeId].clusterSessions.length < targetLevel) { if (this.nodes[nodeId].clusterSessions.length < targetLevel) {
this._clusterToSmallestNeighbour(this.nodes[nodeId]); this._clusterToSmallestNeighbour(this.nodes[nodeId]);
@ -14687,7 +14754,7 @@ var SelectionMixin = {
} }
for(var edgeId in this.selectionObj.edges) { for(var edgeId in this.selectionObj.edges) {
if(this.selectionObj.edges.hasOwnProperty(edgeId)) { if(this.selectionObj.edges.hasOwnProperty(edgeId)) {
this.selectionObj.edges[edgeId].unselect();;
this.selectionObj.edges[edgeId].unselect();
} }
} }
@ -15357,15 +15424,15 @@ var graphMixinLoaders = {
* @private * @private
*/ */
_loadSectorSystem: function () { _loadSectorSystem: function () {
this.sectors = { },
this.activeSector = ["default"];
this.sectors["active"] = { },
this.sectors["active"]["default"] = {"nodes": {},
this.sectors = {};
this.activeSector = ["default"];
this.sectors["active"] = {};
this.sectors["active"]["default"] = {"nodes": {},
"edges": {}, "edges": {},
"nodeIndices": [], "nodeIndices": [],
"formationScale": 1.0, "formationScale": 1.0,
"drawingNode": undefined }; "drawingNode": undefined };
this.sectors["frozen"] = {},
this.sectors["frozen"] = {};
this.sectors["support"] = {"nodes": {}, this.sectors["support"] = {"nodes": {},
"edges": {}, "edges": {},
"nodeIndices": [], "nodeIndices": [],
@ -15398,7 +15465,7 @@ var graphMixinLoaders = {
_loadManipulationSystem: function () { _loadManipulationSystem: function () {
// reset global variables -- these are used by the selection of nodes and edges. // reset global variables -- these are used by the selection of nodes and edges.
this.blockConnectingEdgeSelection = false; this.blockConnectingEdgeSelection = false;
this.forceAppendSelection = false
this.forceAppendSelection = false;
if (this.constants.dataManipulation.enabled == true) { if (this.constants.dataManipulation.enabled == true) {
// load the manipulator HTML elements. All styling done in css. // load the manipulator HTML elements. All styling done in css.
@ -15862,6 +15929,7 @@ Graph.prototype._centerGraph = function(range) {
* 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 {Boolean} [initialZoom] | zoom based on fitted formula or range, true = fitted, default = false; * @param {Boolean} [initialZoom] | zoom based on fitted formula or range, true = fitted, default = false;
* @param {Boolean} [disableStart] | If true, start is not called.
*/ */
Graph.prototype.zoomExtent = function(initialZoom, disableStart) { Graph.prototype.zoomExtent = function(initialZoom, disableStart) {
if (initialZoom === undefined) { if (initialZoom === undefined) {
@ -16448,7 +16516,7 @@ Graph.prototype._handleOnDrag = function(event) {
this.drag.translation.x + diffX, this.drag.translation.x + diffX,
this.drag.translation.y + diffY); this.drag.translation.y + diffY);
this._redraw(); this._redraw();
this.moved = true;
this.moving = true;
} }
}; };
@ -17302,7 +17370,12 @@ Graph.prototype._stabilize = function() {
this.emit("stabilized",{iterations:count}); this.emit("stabilized",{iterations:count});
}; };
/**
* When initializing and stabilizing, we can freeze nodes with a predefined position. This greatly speeds up stabilization
* because only the supportnodes for the smoothCurves have to settle.
*
* @private
*/
Graph.prototype._freezeDefinedNodes = function() { Graph.prototype._freezeDefinedNodes = function() {
var nodes = this.nodes; var nodes = this.nodes;
for (var id in nodes) { for (var id in nodes) {
@ -17317,6 +17390,11 @@ Graph.prototype._freezeDefinedNodes = function() {
} }
}; };
/**
* Unfreezes the nodes that have been frozen by _freezeDefinedNodes.
*
* @private
*/
Graph.prototype._restoreFrozenNodes = function() { Graph.prototype._restoreFrozenNodes = function() {
var nodes = this.nodes; var nodes = this.nodes;
for (var id in nodes) { for (var id in nodes) {
@ -17387,7 +17465,11 @@ Graph.prototype._discreteStepNodes = function() {
} }
}; };
/**
* A single simulation step (or "tick") in the physics simulation
*
* @private
*/
Graph.prototype._physicsTick = function() { Graph.prototype._physicsTick = function() {
if (!this.freezeSimulation) { if (!this.freezeSimulation) {
if (this.moving) { if (this.moving) {
@ -17506,7 +17588,12 @@ Graph.prototype.toggleFreeze = function() {
}; };
/**
* This function cleans the support nodes if they are not needed and adds them when they are.
*
* @param {boolean} [disableStart]
* @private
*/
Graph.prototype._configureSmoothCurves = function(disableStart) { Graph.prototype._configureSmoothCurves = function(disableStart) {
if (disableStart === undefined) { if (disableStart === undefined) {
disableStart = true; disableStart = true;
@ -17532,6 +17619,13 @@ Graph.prototype._configureSmoothCurves = function(disableStart) {
} }
}; };
/**
* Bezier curves require an anchor point to calculate the smooth flow. These points are nodes. These nodes are invisible but
* are used for the force calculation.
*
* @private
*/
Graph.prototype._createBezierNodes = function() { Graph.prototype._createBezierNodes = function() {
if (this.constants.smoothCurves == true) { if (this.constants.smoothCurves == true) {
for (var edgeId in this.edges) { for (var edgeId in this.edges) {
@ -17556,7 +17650,11 @@ Graph.prototype._createBezierNodes = function() {
} }
}; };
/**
* load the functions that load the mixins into the prototype.
*
* @private
*/
Graph.prototype._initializeMixinLoaders = function () { Graph.prototype._initializeMixinLoaders = function () {
for (var mixinFunction in graphMixinLoaders) { for (var mixinFunction in graphMixinLoaders) {
if (graphMixinLoaders.hasOwnProperty(mixinFunction)) { if (graphMixinLoaders.hasOwnProperty(mixinFunction)) {

+ 1
- 1
src/graph/Edge.js View File

@ -97,7 +97,7 @@ Edge.prototype.setProperties = function(properties, constants) {
this.customLength = true;} this.customLength = true;}
// scale the arrow // scale the arrow
if (properties.arrowScaleFactor !== undefined) {this.arrowScaleFactor = properties.arrowScaleFactor};
if (properties.arrowScaleFactor !== undefined) {this.arrowScaleFactor = properties.arrowScaleFactor;}
// Added to support dashed lines // Added to support dashed lines
// David Jordan // David Jordan

+ 36
- 5
src/graph/Graph.js View File

@ -372,6 +372,7 @@ Graph.prototype._centerGraph = function(range) {
* 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 {Boolean} [initialZoom] | zoom based on fitted formula or range, true = fitted, default = false; * @param {Boolean} [initialZoom] | zoom based on fitted formula or range, true = fitted, default = false;
* @param {Boolean} [disableStart] | If true, start is not called.
*/ */
Graph.prototype.zoomExtent = function(initialZoom, disableStart) { Graph.prototype.zoomExtent = function(initialZoom, disableStart) {
if (initialZoom === undefined) { if (initialZoom === undefined) {
@ -958,7 +959,7 @@ Graph.prototype._handleOnDrag = function(event) {
this.drag.translation.x + diffX, this.drag.translation.x + diffX,
this.drag.translation.y + diffY); this.drag.translation.y + diffY);
this._redraw(); this._redraw();
this.moved = true;
this.moving = true;
} }
}; };
@ -1812,7 +1813,12 @@ Graph.prototype._stabilize = function() {
this.emit("stabilized",{iterations:count}); this.emit("stabilized",{iterations:count});
}; };
/**
* When initializing and stabilizing, we can freeze nodes with a predefined position. This greatly speeds up stabilization
* because only the supportnodes for the smoothCurves have to settle.
*
* @private
*/
Graph.prototype._freezeDefinedNodes = function() { Graph.prototype._freezeDefinedNodes = function() {
var nodes = this.nodes; var nodes = this.nodes;
for (var id in nodes) { for (var id in nodes) {
@ -1827,6 +1833,11 @@ Graph.prototype._freezeDefinedNodes = function() {
} }
}; };
/**
* Unfreezes the nodes that have been frozen by _freezeDefinedNodes.
*
* @private
*/
Graph.prototype._restoreFrozenNodes = function() { Graph.prototype._restoreFrozenNodes = function() {
var nodes = this.nodes; var nodes = this.nodes;
for (var id in nodes) { for (var id in nodes) {
@ -1897,7 +1908,11 @@ Graph.prototype._discreteStepNodes = function() {
} }
}; };
/**
* A single simulation step (or "tick") in the physics simulation
*
* @private
*/
Graph.prototype._physicsTick = function() { Graph.prototype._physicsTick = function() {
if (!this.freezeSimulation) { if (!this.freezeSimulation) {
if (this.moving) { if (this.moving) {
@ -2016,7 +2031,12 @@ Graph.prototype.toggleFreeze = function() {
}; };
/**
* This function cleans the support nodes if they are not needed and adds them when they are.
*
* @param {boolean} [disableStart]
* @private
*/
Graph.prototype._configureSmoothCurves = function(disableStart) { Graph.prototype._configureSmoothCurves = function(disableStart) {
if (disableStart === undefined) { if (disableStart === undefined) {
disableStart = true; disableStart = true;
@ -2042,6 +2062,13 @@ Graph.prototype._configureSmoothCurves = function(disableStart) {
} }
}; };
/**
* Bezier curves require an anchor point to calculate the smooth flow. These points are nodes. These nodes are invisible but
* are used for the force calculation.
*
* @private
*/
Graph.prototype._createBezierNodes = function() { Graph.prototype._createBezierNodes = function() {
if (this.constants.smoothCurves == true) { if (this.constants.smoothCurves == true) {
for (var edgeId in this.edges) { for (var edgeId in this.edges) {
@ -2066,7 +2093,11 @@ Graph.prototype._createBezierNodes = function() {
} }
}; };
/**
* load the functions that load the mixins into the prototype.
*
* @private
*/
Graph.prototype._initializeMixinLoaders = function () { Graph.prototype._initializeMixinLoaders = function () {
for (var mixinFunction in graphMixinLoaders) { for (var mixinFunction in graphMixinLoaders) {
if (graphMixinLoaders.hasOwnProperty(mixinFunction)) { if (graphMixinLoaders.hasOwnProperty(mixinFunction)) {

+ 1
- 0
src/graph/Node.js View File

@ -356,6 +356,7 @@ Node.prototype.discreteStep = function(interval) {
/** /**
* Perform one discrete step for the node * Perform one discrete step for the node
* @param {number} interval Time interval in seconds * @param {number} interval Time interval in seconds
* @param {number} maxVelocity The speed limit imposed on the velocity
*/ */
Node.prototype.discreteStepLimited = function(interval, maxVelocity) { Node.prototype.discreteStepLimited = function(interval, maxVelocity) {
if (!this.xFixed) { if (!this.xFixed) {

+ 4
- 2
src/graph/graphMixins/ClusterMixin.js View File

@ -137,6 +137,7 @@ var ClusterMixin = {
* @param {Number} zoomDirection | -1 / 0 / +1 for zoomOut / determineByZoom / zoomIn * @param {Number} zoomDirection | -1 / 0 / +1 for zoomOut / determineByZoom / zoomIn
* @param {Boolean} recursive | enabled or disable recursive calling of the opening of clusters * @param {Boolean} recursive | enabled or disable recursive calling of the opening of clusters
* @param {Boolean} force | enabled or disable forcing * @param {Boolean} force | enabled or disable forcing
* @param {Boolean} doNotStart | if true do not call start
* *
*/ */
updateClusters : function(zoomDirection,recursive,force,doNotStart) { updateClusters : function(zoomDirection,recursive,force,doNotStart) {
@ -987,9 +988,10 @@ var ClusterMixin = {
var maxLevel = 0; var maxLevel = 0;
var minLevel = 1e9; var minLevel = 1e9;
var clusterLevel = 0; var clusterLevel = 0;
var nodeId;
// we loop over all nodes in the list // we loop over all nodes in the list
for (var nodeId in this.nodes) {
for (nodeId in this.nodes) {
if (this.nodes.hasOwnProperty(nodeId)) { if (this.nodes.hasOwnProperty(nodeId)) {
clusterLevel = this.nodes[nodeId].clusterSessions.length; clusterLevel = this.nodes[nodeId].clusterSessions.length;
if (maxLevel < clusterLevel) {maxLevel = clusterLevel;} if (maxLevel < clusterLevel) {maxLevel = clusterLevel;}
@ -1001,7 +1003,7 @@ var ClusterMixin = {
var amountOfNodes = this.nodeIndices.length; var amountOfNodes = this.nodeIndices.length;
var targetLevel = maxLevel - this.constants.clustering.clusterLevelDifference; var targetLevel = maxLevel - this.constants.clustering.clusterLevelDifference;
// we loop over all nodes in the list // we loop over all nodes in the list
for (var nodeId in this.nodes) {
for (nodeId in this.nodes) {
if (this.nodes.hasOwnProperty(nodeId)) { if (this.nodes.hasOwnProperty(nodeId)) {
if (this.nodes[nodeId].clusterSessions.length < targetLevel) { if (this.nodes[nodeId].clusterSessions.length < targetLevel) {
this._clusterToSmallestNeighbour(this.nodes[nodeId]); this._clusterToSmallestNeighbour(this.nodes[nodeId]);

+ 3
- 3
src/graph/graphMixins/HierarchicalLayoutMixin.js View File

@ -123,7 +123,7 @@ var HierarchicalLayoutMixin = {
*/ */
_getDistribution : function() { _getDistribution : function() {
var distribution = {}; var distribution = {};
var nodeId, node;
var nodeId, node, level;
// we fix Y because the hierarchy is vertical, we fix X so we do not give a node an x position for a second time. // we fix Y because the hierarchy is vertical, we fix X so we do not give a node an x position for a second time.
// the fix of X is removed after the x value has been set. // the fix of X is removed after the x value has been set.
@ -148,7 +148,7 @@ var HierarchicalLayoutMixin = {
// determine the largest amount of nodes of all levels // determine the largest amount of nodes of all levels
var maxCount = 0; var maxCount = 0;
for (var level in distribution) {
for (level in distribution) {
if (distribution.hasOwnProperty(level)) { if (distribution.hasOwnProperty(level)) {
if (maxCount < distribution[level].amount) { if (maxCount < distribution[level].amount) {
maxCount = distribution[level].amount; maxCount = distribution[level].amount;
@ -157,7 +157,7 @@ var HierarchicalLayoutMixin = {
} }
// set the initial position and spacing of each nodes accordingly // set the initial position and spacing of each nodes accordingly
for (var level in distribution) {
for (level in distribution) {
if (distribution.hasOwnProperty(level)) { if (distribution.hasOwnProperty(level)) {
distribution[level].nodeSpacing = (maxCount + 1) * this.constants.hierarchicalLayout.nodeSpacing; distribution[level].nodeSpacing = (maxCount + 1) * this.constants.hierarchicalLayout.nodeSpacing;
distribution[level].nodeSpacing /= (distribution[level].amount + 1); distribution[level].nodeSpacing /= (distribution[level].amount + 1);

+ 0
- 2
src/graph/graphMixins/ManipulationMixin.js View File

@ -288,8 +288,6 @@ var manipulationMixin = {
/** /**
* Adds a node on the specified location * Adds a node on the specified location
*
* @param {Object} pointer
*/ */
_addNode : function() { _addNode : function() {
if (this._selectionIsEmpty() && this.editMode == true) { if (this._selectionIsEmpty() && this.editMode == true) {

+ 6
- 6
src/graph/graphMixins/MixinLoader.js View File

@ -67,15 +67,15 @@ var graphMixinLoaders = {
* @private * @private
*/ */
_loadSectorSystem: function () { _loadSectorSystem: function () {
this.sectors = { },
this.activeSector = ["default"];
this.sectors["active"] = { },
this.sectors["active"]["default"] = {"nodes": {},
this.sectors = {};
this.activeSector = ["default"];
this.sectors["active"] = {};
this.sectors["active"]["default"] = {"nodes": {},
"edges": {}, "edges": {},
"nodeIndices": [], "nodeIndices": [],
"formationScale": 1.0, "formationScale": 1.0,
"drawingNode": undefined }; "drawingNode": undefined };
this.sectors["frozen"] = {},
this.sectors["frozen"] = {};
this.sectors["support"] = {"nodes": {}, this.sectors["support"] = {"nodes": {},
"edges": {}, "edges": {},
"nodeIndices": [], "nodeIndices": [],
@ -108,7 +108,7 @@ var graphMixinLoaders = {
_loadManipulationSystem: function () { _loadManipulationSystem: function () {
// reset global variables -- these are used by the selection of nodes and edges. // reset global variables -- these are used by the selection of nodes and edges.
this.blockConnectingEdgeSelection = false; this.blockConnectingEdgeSelection = false;
this.forceAppendSelection = false
this.forceAppendSelection = false;
if (this.constants.dataManipulation.enabled == true) { if (this.constants.dataManipulation.enabled == true) {
// load the manipulator HTML elements. All styling done in css. // load the manipulator HTML elements. All styling done in css.

+ 1
- 1
src/graph/graphMixins/SelectionMixin.js View File

@ -174,7 +174,7 @@ var SelectionMixin = {
} }
for(var edgeId in this.selectionObj.edges) { for(var edgeId in this.selectionObj.edges) {
if(this.selectionObj.edges.hasOwnProperty(edgeId)) { if(this.selectionObj.edges.hasOwnProperty(edgeId)) {
this.selectionObj.edges[edgeId].unselect();;
this.selectionObj.edges[edgeId].unselect();
} }
} }

+ 23
- 0
src/graph/graphMixins/physics/BarnesHut.js View File

@ -156,6 +156,13 @@ var barnesHutMixin = {
}, },
/**
* this updates the mass of a branch. this is increased by adding a node.
*
* @param parentBranch
* @param node
* @private
*/
_updateBranchMass : function(parentBranch, node) { _updateBranchMass : function(parentBranch, node) {
var totalMass = parentBranch.mass + node.mass; var totalMass = parentBranch.mass + node.mass;
var totalMassInv = 1/totalMass; var totalMassInv = 1/totalMass;
@ -173,6 +180,14 @@ var barnesHutMixin = {
}, },
/**
* determine in which branch the node will be placed.
*
* @param parentBranch
* @param node
* @param skipMassUpdate
* @private
*/
_placeInTree : function(parentBranch,node,skipMassUpdate) { _placeInTree : function(parentBranch,node,skipMassUpdate) {
if (skipMassUpdate != true || skipMassUpdate === undefined) { if (skipMassUpdate != true || skipMassUpdate === undefined) {
// update the mass of the branch. // update the mass of the branch.
@ -198,6 +213,14 @@ var barnesHutMixin = {
}, },
/**
* actually place the node in a region (or branch)
*
* @param parentBranch
* @param node
* @param region
* @private
*/
_placeInRegion : function(parentBranch,node,region) { _placeInRegion : function(parentBranch,node,region) {
switch (parentBranch.children[region].childrenCount) { switch (parentBranch.children[region].childrenCount) {
case 0: // place node here case 0: // place node here

+ 29
- 1
src/graph/graphMixins/physics/PhysicsMixin.js View File

@ -464,6 +464,13 @@ var physicsMixin = {
} }
}, },
/**
* This overwrites the this.constants.
*
* @param constantsVariableName
* @param value
* @private
*/
_overWriteGraphConstants: function (constantsVariableName, value) { _overWriteGraphConstants: function (constantsVariableName, value) {
var nameArray = constantsVariableName.split("_"); var nameArray = constantsVariableName.split("_");
if (nameArray.length == 1) { if (nameArray.length == 1) {
@ -478,6 +485,9 @@ var physicsMixin = {
} }
}; };
/**
* this function is bound to the toggle smooth curves button. That is also why it is not in the prototype.
*/
function graphToggleSmoothCurves () { function graphToggleSmoothCurves () {
this.constants.smoothCurves = !this.constants.smoothCurves; this.constants.smoothCurves = !this.constants.smoothCurves;
var graph_toggleSmooth = document.getElementById("graph_toggleSmooth"); var graph_toggleSmooth = document.getElementById("graph_toggleSmooth");
@ -487,6 +497,10 @@ function graphToggleSmoothCurves () {
this._configureSmoothCurves(false); this._configureSmoothCurves(false);
}; };
/**
* this function is used to scramble the nodes
*
*/
function graphRepositionNodes () { function graphRepositionNodes () {
for (var nodeId in this.calculationNodes) { for (var nodeId in this.calculationNodes) {
if (this.calculationNodes.hasOwnProperty(nodeId)) { if (this.calculationNodes.hasOwnProperty(nodeId)) {
@ -504,6 +518,9 @@ function graphRepositionNodes () {
this.start(); this.start();
}; };
/**
* this is used to generate an options file from the playing with physics system.
*/
function graphGenerateOptions () { function graphGenerateOptions () {
var options = "No options are required, default values used."; var options = "No options are required, default values used.";
var optionsSpecific = []; var optionsSpecific = [];
@ -601,7 +618,10 @@ function graphGenerateOptions () {
}; };
/**
* this is used to switch between barnesHut, repulsion and hierarchical.
*
*/
function switchConfigurations () { function switchConfigurations () {
var ids = ["graph_BH_table", "graph_R_table", "graph_H_table"]; var ids = ["graph_BH_table", "graph_R_table", "graph_H_table"];
var radioButton = document.querySelector('input[name="graph_physicsMethod"]:checked').value; var radioButton = document.querySelector('input[name="graph_physicsMethod"]:checked').value;
@ -640,6 +660,14 @@ function switchConfigurations () {
} }
/**
* this generates the ranges depending on the iniital values.
*
* @param id
* @param map
* @param constantsVariableName
*/
function showValueOfRange (id,map,constantsVariableName) { function showValueOfRange (id,map,constantsVariableName) {
var valueId = id + "_value"; var valueId = id + "_value";
var rangeValue = document.getElementById(id).value; var rangeValue = document.getElementById(id).value;

+ 16
- 1
src/timeline/component/ItemSet.js View File

@ -305,7 +305,13 @@ ItemSet.prototype._binarySearch = function _binarySearch(byEnd) {
return guess; return guess;
} }
/**
* this function checks if an item is invisible. If it is NOT we make it visible and add it to the global visible items. If it is, return true.
*
* @param {itemRange | itemPoint | itemBox} item
* @returns {boolean}
* @private
*/
ItemSet.prototype._checkIfInvisible = function _checkIfInvisible(item) { ItemSet.prototype._checkIfInvisible = function _checkIfInvisible(item) {
if (item.isVisible(this.range)) { if (item.isVisible(this.range)) {
if (!item.displayed) item.show(); if (!item.displayed) item.show();
@ -320,6 +326,15 @@ ItemSet.prototype._checkIfInvisible = function _checkIfInvisible(item) {
} }
}; };
/**
* this function is very similar to the _checkIfInvisible() but it does not return booleans, hides the item if it should not be seen and always adds to the visibleItems.
* this one is for brute forcing and hiding.
*
* @param {itemRange | itemPoint | itemBox} item
* @param {array} visibleItems
* @private
*/
ItemSet.prototype._checkIfVisible = function _checkIfVisible(item, visibleItems) { ItemSet.prototype._checkIfVisible = function _checkIfVisible(item, visibleItems) {
if (item.isVisible(this.range)) { if (item.isVisible(this.range)) {
if (!item.displayed) item.show(); if (!item.displayed) item.show();

Loading…
Cancel
Save