@ -19,7 +19,7 @@ var locales = require('./locales');
// Load custom shapes into CanvasRenderingContext2D
// Load custom shapes into CanvasRenderingContext2D
require ( './shapes' ) ;
require ( './shapes' ) ;
import { PhysicsEngine } from './modules/PhysicsEngine'
import { ClusterEngine } from './modules/Clustering'
import { ClusterEngine } from './modules/Clustering'
/ * *
/ * *
@ -65,8 +65,6 @@ function Network (container, data, options) {
}
}
} ;
} ;
// set constant values
// set constant values
this . defaultOptions = {
this . defaultOptions = {
nodes : {
nodes : {
@ -142,7 +140,6 @@ function Network (container, data, options) {
configurePhysics : false ,
configurePhysics : false ,
physics : {
physics : {
barnesHut : {
barnesHut : {
enabled : true ,
thetaInverted : 1 / 0.5 , // inverted to save time during calculation
thetaInverted : 1 / 0.5 , // inverted to save time during calculation
gravitationalConstant : - 2000 ,
gravitationalConstant : - 2000 ,
centralGravity : 0.3 ,
centralGravity : 0.3 ,
@ -158,20 +155,13 @@ function Network (container, data, options) {
damping : 0.09
damping : 0.09
} ,
} ,
hierarchicalRepulsion : {
hierarchicalRepulsion : {
enabled : false ,
centralGravity : 0.0 ,
centralGravity : 0.0 ,
springLength : 100 ,
springLength : 100 ,
springConstant : 0.01 ,
springConstant : 0.01 ,
nodeDistance : 150 ,
nodeDistance : 150 ,
damping : 0.09
damping : 0.09
} ,
} ,
damping : null ,
centralGravity : null ,
springLength : null ,
springConstant : null
} ,
clustering : { // Per Node in Cluster = PNiC
enabled : false // (Boolean) | global on/off switch for clustering.
model : 'BarnesHut'
} ,
} ,
navigation : {
navigation : {
enabled : false
enabled : false
@ -232,9 +222,10 @@ function Network (container, data, options) {
// containers for nodes and edges
// containers for nodes and edges
this . body = {
this . body = {
sectors : { } ,
nodeIndices : [ ] ,
nodes : { } ,
nodes : { } ,
nodeIndices : [ ] ,
supportNodes : { } ,
supportNodeIndices : [ ] ,
edges : { } ,
edges : { } ,
data : {
data : {
nodes : null , // A DataSet or DataView
nodes : null , // A DataSet or DataView
@ -251,6 +242,10 @@ function Network (container, data, options) {
}
}
} ;
} ;
// modules
this . clustering = new ClusterEngine ( this . body ) ;
this . physics = new PhysicsEngine ( this . body ) ;
this . pixelRatio = 1 ;
this . pixelRatio = 1 ;
@ -288,11 +283,9 @@ function Network (container, data, options) {
// loading all the mixins:
// loading all the mixins:
// load the force calculation functions, grouped under the physics system.
// load the force calculation functions, grouped under the physics system.
this . _loadPhysicsSystem ( ) ;
//this._loadPhysicsSystem();
// create a frame and canvas
// create a frame and canvas
this . _create ( ) ;
this . _create ( ) ;
// load the sector system. (mandatory, fully integrated with Network)
this . _loadSectorSystem ( ) ;
// load the cluster system. (mandatory, even when not using the cluster system, there are function calls to it)
// load the cluster system. (mandatory, even when not using the cluster system, there are function calls to it)
this . _loadClusterSystem ( ) ;
this . _loadClusterSystem ( ) ;
// load the selection system. (mandatory, required by Network)
// load the selection system. (mandatory, required by Network)
@ -313,8 +306,6 @@ function Network (container, data, options) {
this . stabilizationIterations = null ;
this . stabilizationIterations = null ;
this . draggingNodes = false ;
this . draggingNodes = false ;
this . clustering = new ClusterEngine ( this . body ) ;
// position and scale variables and objects
// position and scale variables and objects
this . canvasTopLeft = { "x" : 0 , "y" : 0 } ; // coordinates of the top left of the canvas. they will be set during _redraw.
this . canvasTopLeft = { "x" : 0 , "y" : 0 } ; // coordinates of the top left of the canvas. they will be set during _redraw.
this . canvasBottomRight = { "x" : 0 , "y" : 0 } ; // coordinates of the bottom right of the canvas. they will be set during _redraw
this . canvasBottomRight = { "x" : 0 , "y" : 0 } ; // coordinates of the bottom right of the canvas. they will be set during _redraw
@ -351,6 +342,7 @@ function Network (container, data, options) {
}
}
} ;
} ;
// properties for the animation
// properties for the animation
this . moving = true ;
this . moving = true ;
this . timer = undefined ; // Scheduling function. Is definded in this.start();
this . timer = undefined ; // Scheduling function. Is definded in this.start();
@ -377,7 +369,7 @@ function Network (container, data, options) {
// this event will trigger a rebuilding of the cache of colors, nodes etc.
// this event will trigger a rebuilding of the cache of colors, nodes etc.
this . on ( "_dataChanged" , function ( ) {
this . on ( "_dataChanged" , function ( ) {
me . _updateNodeIndexList ( ) ;
me . _updateNodeIndexList ( ) ;
me . _updateCalculationNodes ( ) ;
me . physics . _updateCalculationNodes ( ) ;
me . _markAllEdgesAsDirty ( ) ;
me . _markAllEdgesAsDirty ( ) ;
if ( me . initializing !== true ) {
if ( me . initializing !== true ) {
me . moving = true ;
me . moving = true ;
@ -605,7 +597,7 @@ Network.prototype.zoomExtent = function(options, initialZoom, disableStart) {
* @ private
* @ private
* /
* /
Network . prototype . _updateNodeIndexList = function ( ) {
Network . prototype . _updateNodeIndexList = function ( ) {
this . _clearNodeIndexList ( ) ;
this . body . supportNodeIndices = Object . keys ( this . body . supportNodes )
this . body . nodeIndices = Object . keys ( this . body . nodes ) ;
this . body . nodeIndices = Object . keys ( this . body . nodes ) ;
} ;
} ;
@ -665,7 +657,6 @@ Network.prototype.setData = function(data, disableStart) {
this . _setNodes ( data && data . nodes ) ;
this . _setNodes ( data && data . nodes ) ;
this . _setEdges ( data && data . edges ) ;
this . _setEdges ( data && data . edges ) ;
}
}
this . _putDataInSector ( ) ;
if ( disableStart == false ) {
if ( disableStart == false ) {
if ( this . constants . hierarchicalLayout . enabled == true ) {
if ( this . constants . hierarchicalLayout . enabled == true ) {
@ -695,7 +686,7 @@ Network.prototype.setData = function(data, disableStart) {
Network . prototype . setOptions = function ( options ) {
Network . prototype . setOptions = function ( options ) {
if ( options ) {
if ( options ) {
var prop ;
var prop ;
var fields = [ 'nodes' , 'edges' , 'smoothCurves' , 'hierarchicalLayout' , 'clustering' , ' navigation' ,
var fields = [ 'nodes' , 'edges' , 'smoothCurves' , 'hierarchicalLayout' , 'navigation' ,
'keyboard' , 'dataManipulation' , 'onAdd' , 'onEdit' , 'onEditEdge' , 'onConnect' , 'onDelete' , 'clickToUse'
'keyboard' , 'dataManipulation' , 'onAdd' , 'onEdit' , 'onEditEdge' , 'onConnect' , 'onDelete' , 'clickToUse'
] ;
] ;
// extend all but the values in fields
// extend all but the values in fields
@ -707,24 +698,14 @@ Network.prototype.setOptions = function (options) {
if ( options . physics ) {
if ( options . physics ) {
util . mergeOptions ( this . constants . physics , options . physics , 'barnesHut' ) ;
util . mergeOptions ( this . constants . physics , options . physics , 'barnesHut' ) ;
util . mergeOptions ( this . constants . physics , options . physics , 'repulsion' ) ;
util . mergeOptions ( this . constants . physics , options . physics , 'repulsion' ) ;
if ( options . physics . hierarchicalRepulsion ) {
this . constants . hierarchicalLayout . enabled = true ;
this . constants . physics . hierarchicalRepulsion . enabled = true ;
this . constants . physics . barnesHut . enabled = false ;
for ( prop in options . physics . hierarchicalRepulsion ) {
if ( options . physics . hierarchicalRepulsion . hasOwnProperty ( prop ) ) {
this . constants . physics . hierarchicalRepulsion [ prop ] = options . physics . hierarchicalRepulsion [ prop ] ;
}
}
}
util . mergeOptions ( this . constants . physics , options . physics , 'hierarchicalRepulsion' ) ;
}
}
if ( options . onAdd ) { this . triggerFunctions . add = options . onAdd ; }
if ( options . onEdit ) { this . triggerFunctions . edit = options . onEdit ; }
if ( options . onAdd ) { this . triggerFunctions . add = options . onAdd ; }
if ( options . onEdit ) { this . triggerFunctions . edit = options . onEdit ; }
if ( options . onEditEdge ) { this . triggerFunctions . editEdge = options . onEditEdge ; }
if ( options . onEditEdge ) { this . triggerFunctions . editEdge = options . onEditEdge ; }
if ( options . onConnect ) { this . triggerFunctions . connect = options . onConnect ; }
if ( options . onDelete ) { this . triggerFunctions . del = options . onDelete ; }
if ( options . onConnect ) { this . triggerFunctions . connect = options . onConnect ; }
if ( options . onDelete ) { this . triggerFunctions . del = options . onDelete ; }
util . mergeOptions ( this . constants , options , 'smoothCurves' ) ;
util . mergeOptions ( this . constants , options , 'smoothCurves' ) ;
util . mergeOptions ( this . constants , options , 'hierarchicalLayout' ) ;
util . mergeOptions ( this . constants , options , 'hierarchicalLayout' ) ;
@ -816,7 +797,7 @@ Network.prototype.setOptions = function (options) {
// (Re)loading the mixins that can be enabled or disabled in the options.
// (Re)loading the mixins that can be enabled or disabled in the options.
// load the force calculation functions, grouped under the physics system.
// load the force calculation functions, grouped under the physics system.
this . _loadPhysicsSystem ( ) ;
this . physics . setOptions ( this . constants . physics ) ;
// load the navigation system.
// load the navigation system.
this . _loadNavigationControls ( ) ;
this . _loadNavigationControls ( ) ;
// load the data manipulation system
// load the data manipulation system
@ -1700,7 +1681,7 @@ Network.prototype._addNodes = function(ids) {
this . _resetLevels ( ) ;
this . _resetLevels ( ) ;
this . _setupHierarchicalLayout ( ) ;
this . _setupHierarchicalLayout ( ) ;
}
}
this . _updateCalculationNodes ( ) ;
this . physics . _updateCalculationNodes ( ) ;
this . _reconnectEdges ( ) ;
this . _reconnectEdges ( ) ;
this . _updateValueRange ( this . body . nodes ) ;
this . _updateValueRange ( this . body . nodes ) ;
} ;
} ;
@ -1771,7 +1752,7 @@ Network.prototype._removeNodes = function(ids) {
this . _resetLevels ( ) ;
this . _resetLevels ( ) ;
this . _setupHierarchicalLayout ( ) ;
this . _setupHierarchicalLayout ( ) ;
}
}
this . _updateCalculationNodes ( ) ;
this . physics . _updateCalculationNodes ( ) ;
this . _reconnectEdges ( ) ;
this . _reconnectEdges ( ) ;
this . _updateSelection ( ) ;
this . _updateSelection ( ) ;
this . _updateValueRange ( nodes ) ;
this . _updateValueRange ( nodes ) ;
@ -1848,7 +1829,7 @@ Network.prototype._addEdges = function (ids) {
this . moving = true ;
this . moving = true ;
this . _updateValueRange ( edges ) ;
this . _updateValueRange ( edges ) ;
this . _createBezierNodes ( ) ;
this . _createBezierNodes ( ) ;
this . _updateCalculationNodes ( ) ;
this . physics . _updateCalculationNodes ( ) ;
if ( this . constants . hierarchicalLayout . enabled == true && this . initializing == false ) {
if ( this . constants . hierarchicalLayout . enabled == true && this . initializing == false ) {
this . _resetLevels ( ) ;
this . _resetLevels ( ) ;
this . _setupHierarchicalLayout ( ) ;
this . _setupHierarchicalLayout ( ) ;
@ -1911,7 +1892,7 @@ Network.prototype._removeEdges = function (ids) {
var edge = edges [ id ] ;
var edge = edges [ id ] ;
if ( edge ) {
if ( edge ) {
if ( edge . via != null ) {
if ( edge . via != null ) {
delete this . body . sectors [ 'support' ] [ 'nodes' ] [ edge . via . id ] ;
delete this . body . supportNodes [ edge . via . id ] ;
}
}
edge . disconnect ( ) ;
edge . disconnect ( ) ;
delete edges [ id ] ;
delete edges [ id ] ;
@ -1924,7 +1905,7 @@ Network.prototype._removeEdges = function (ids) {
this . _resetLevels ( ) ;
this . _resetLevels ( ) ;
this . _setupHierarchicalLayout ( ) ;
this . _setupHierarchicalLayout ( ) ;
}
}
this . _updateCalculationNodes ( ) ;
this . physics . _updateCalculationNodes ( ) ;
} ;
} ;
/ * *
/ * *
@ -2013,10 +1994,7 @@ Network.prototype._requestRedraw = function(hidden) {
}
}
} ;
} ;
Network . prototype . _redraw = function ( hidden , requested ) {
if ( hidden === undefined ) {
hidden = false ;
}
Network . prototype . _redraw = function ( hidden = false ) {
this . redrawRequested = false ;
this . redrawRequested = false ;
var ctx = this . frame . canvas . getContext ( '2d' ) ;
var ctx = this . frame . canvas . getContext ( '2d' ) ;
@ -2042,24 +2020,23 @@ Network.prototype._redraw = function(hidden, requested) {
} ;
} ;
if ( hidden === false ) {
if ( hidden === false ) {
this . _doInAllSectors ( "_drawAllSectorNodes" , ctx ) ;
if ( this . drag . dragging == false || this . drag . dragging === undefined || this . constants . hideEdgesOnDrag == false ) {
if ( this . drag . dragging == false || this . drag . dragging === undefined || this . constants . hideEdgesOnDrag == false ) {
this . _doInAllSectors ( "_drawEdges" , ctx ) ;
this . _drawEdges ( ctx ) ;
}
}
}
}
if ( this . drag . dragging == false || this . drag . dragging === undefined || this . constants . hideNodesOnDrag == false ) {
if ( this . drag . dragging == false || this . drag . dragging === undefined || this . constants . hideNodesOnDrag == false ) {
this . _doInAllSectors ( "_drawNodes" , ctx , false ) ;
this . _drawNodes ( ctx , this . body . nodes , hidden ) ;
}
}
if ( hidden === false ) {
if ( hidden === false ) {
if ( this . controlNodesActive == true ) {
if ( this . controlNodesActive == true ) {
this . _doInAllSectors ( "_drawControlNodes" , ctx ) ;
this . _drawControlNodes ( ctx ) ;
}
}
}
}
//this._doInSupportSector("_drawNodes",ctx,true);
// this._drawTree (ctx,"#F00F0F");
this . _drawNodes ( ctx , this . body . supportNodes , true ) ;
// this.physics.nodesSolver._debug (ctx,"#F00F0F");
// restore original scaling and translation
// restore original scaling and translation
ctx . restore ( ) ;
ctx . restore ( ) ;
@ -2195,13 +2172,8 @@ Network.prototype.DOMtoCanvas = function (pos) {
* @ param { Boolean } [ alwaysShow ]
* @ param { Boolean } [ alwaysShow ]
* @ private
* @ private
* /
* /
Network . prototype . _drawNodes = function ( ctx , alwaysShow ) {
if ( alwaysShow === undefined ) {
alwaysShow = false ;
}
Network . prototype . _drawNodes = function ( ctx , nodes , alwaysShow = false ) {
// first draw the unselected nodes
// first draw the unselected nodes
var nodes = this . body . nodes ;
var selected = [ ] ;
var selected = [ ] ;
for ( var id in nodes ) {
for ( var id in nodes ) {
@ -2211,7 +2183,10 @@ Network.prototype._drawNodes = function(ctx,alwaysShow) {
selected . push ( id ) ;
selected . push ( id ) ;
}
}
else {
else {
if ( nodes [ id ] . inArea ( ) || alwaysShow ) {
if ( alwaysShow === true ) {
nodes [ id ] . draw ( ctx ) ;
}
else if ( nodes [ id ] . inArea ( ) === true ) {
nodes [ id ] . draw ( ctx ) ;
nodes [ id ] . draw ( ctx ) ;
}
}
}
}
@ -2346,13 +2321,11 @@ Network.prototype._restoreFrozenNodes = function() {
* @ return { boolean } true if moving , false if non of the nodes is moving
* @ return { boolean } true if moving , false if non of the nodes is moving
* @ private
* @ private
* /
* /
Network . prototype . _isMoving = function ( vmin ) {
var nodes = this . body . nodes ;
for ( var id in nodes ) {
if ( nodes [ id ] !== undefined ) {
if ( nodes [ id ] . isMoving ( vmin ) == true ) {
return true ;
}
Network . prototype . _isMoving = function ( nodes , nodeIndices , vmin ) {
for ( let i = 0 ; i < nodeIndices . length ; i ++ ) {
let node = nodes [ nodeIndices [ i ] ] ;
if ( node . isMoving ( vmin ) == true ) {
return true ;
}
}
}
}
return false ;
return false ;
@ -2365,44 +2338,40 @@ Network.prototype._isMoving = function(vmin) {
*
*
* @ private
* @ private
* /
* /
Network . prototype . _discreteStepNodes = function ( ) {
Network . prototype . _discreteStepNodes = function ( nodes , nodeIndices ) {
var interval = this . physicsDiscreteStepsize ;
var interval = this . physicsDiscreteStepsize ;
var nodes = this . body . nodes ;
var nodeId ;
var nodesPresent = false ;
var nodesPresent = false ;
if ( this . constants . maxVelocity > 0 ) {
if ( this . constants . maxVelocity > 0 ) {
for ( nodeId in nodes ) {
if ( nodes . hasOwnProperty ( nodeId ) ) {
nodes [ nodeId ] . discreteStepLimited ( interval , this . constants . maxVelocity ) ;
nodesPresent = true ;
}
for ( let i = 0 ; i < nodeIndices . length ; i ++ ) {
let node = nodes [ nodeIndices [ i ] ] ;
node . discreteStepLimited ( interval , this . constants . maxVelocity ) ;
nodesPresent = true ;
}
}
}
}
else {
else {
for ( nodeId in nodes ) {
if ( nodes . hasOwnProperty ( nodeId ) ) {
nodes [ nodeId ] . discreteStep ( interval ) ;
nodesPresent = true ;
}
for ( let i = 0 ; i < nodeIndices . length ; i ++ ) {
let node = nodes [ nodeIndices [ i ] ] ;
node . discreteStep ( interval ) ;
nodesPresent = true ;
}
}
}
}
if ( nodesPresent == true ) {
if ( nodesPresent == true ) {
var vminCorrected = this . constants . minVelocity / Math . max ( this . scale , 0.05 ) ;
var vminCorrected = this . constants . minVelocity / Math . max ( this . scale , 0.05 ) ;
if ( vminCorrected > 0.5 * this . constants . maxVelocity ) {
if ( vminCorrected > 0.5 * this . constants . maxVelocity ) {
return true ;
return true ;
}
}
else {
else {
return this . _isMoving ( vminCorrected ) ;
return this . _isMoving ( nodes , nodeIndices , vminCorrected ) ;
}
}
}
}
return false ;
return false ;
} ;
} ;
Network . prototype . _revertPhysicsState = function ( ) {
var nodes = this . body . nodes ;
Network . prototype . _revertPhysicsTick = function ( nodes ) {
for ( var nodeId in nodes ) {
for ( var nodeId in nodes ) {
if ( nodes . hasOwnProperty ( nodeId ) ) {
if ( nodes . hasOwnProperty ( nodeId ) ) {
nodes [ nodeId ] . revertPosition ( ) ;
nodes [ nodeId ] . revertPosition ( ) ;
@ -2410,13 +2379,6 @@ Network.prototype._revertPhysicsState = function() {
}
}
}
}
Network . prototype . _revertPhysicsTick = function ( ) {
this . _doInAllActiveSectors ( "_revertPhysicsState" ) ;
if ( this . constants . smoothCurves . enabled == true && this . constants . smoothCurves . dynamic == true ) {
this . _doInSupportSector ( "_revertPhysicsState" ) ;
}
}
/ * *
/ * *
* A single simulation step ( or "tick" ) in the physics simulation
* A single simulation step ( or "tick" ) in the physics simulation
*
*
@ -2425,24 +2387,16 @@ Network.prototype._revertPhysicsTick = function() {
Network . prototype . _physicsTick = function ( ) {
Network . prototype . _physicsTick = function ( ) {
if ( ! this . freezeSimulationEnabled ) {
if ( ! this . freezeSimulationEnabled ) {
if ( this . moving == true ) {
if ( this . moving == true ) {
var mainMovingStatus = false ;
var supportMovingStatus = false ;
this . physics . step ( ) ;
this . _doInAllActiveSectors ( "_initializeForceCalculation" ) ;
var mainMoving = this . _doInAllActiveSectors ( "_discreteStepNodes" ) ;
if ( this . constants . smoothCurves . enabled == true && this . constants . smoothCurves . dynamic == true ) {
supportMovingStatus = this . _doInSupportSector ( "_discreteStepNodes" ) ;
}
// gather movement data from all sectors, if one moves, we are NOT stabilzied
for ( var i = 0 ; i < mainMoving . length ; i ++ ) {
mainMovingStatus = mainMoving [ i ] || mainMovingStatus ;
}
var mainMovingStatus = this . _discreteStepNodes ( this . body . nodes , this . body . nodeIndices ) ;
var supportMovingStatus = this . _discreteStepNodes ( this . body . supportNodes , this . body . supportNodeIndices ) ;
// determine if the network has stabilzied
// determine if the network has stabilzied
this . moving = mainMovingStatus || supportMovingStatus ;
this . moving = mainMovingStatus || supportMovingStatus ;
if ( this . moving == false ) {
if ( this . moving == false ) {
this . _revertPhysicsTick ( ) ;
this . _revertPhysicsTick ( this . body . nodes ) ;
this . _revertPhysicsTick ( this . body . supportNodes ) ;
}
}
else {
else {
// this is here to ensure that there is no start event when the network is already stable.
// this is here to ensure that there is no start event when the network is already stable.
@ -2593,24 +2547,21 @@ Network.prototype.freezeSimulation = function(freeze) {
* @ param { boolean } [ disableStart ]
* @ param { boolean } [ disableStart ]
* @ private
* @ private
* /
* /
Network . prototype . _configureSmoothCurves = function ( disableStart ) {
if ( disableStart === undefined ) {
disableStart = true ;
}
Network . prototype . _configureSmoothCurves = function ( disableStart = true ) {
if ( this . constants . smoothCurves . enabled == true && this . constants . smoothCurves . dynamic == true ) {
if ( this . constants . smoothCurves . enabled == true && this . constants . smoothCurves . dynamic == true ) {
this . _createBezierNodes ( ) ;
this . _createBezierNodes ( ) ;
// cleanup unused support nodes
// cleanup unused support nodes
for ( var nodeId in this . body . sectors [ 'support' ] [ 'nodes' ] ) {
if ( this . body . sectors [ 'support' ] [ 'nodes' ] . hasOwnProperty ( nodeId ) ) {
if ( this . body . edges [ this . body . sectors [ 'support' ] [ 'nodes' ] [ nodeId ] . parentEdgeId ] === undefined ) {
delete this . body . sectors [ 'support' ] [ 'nodes' ] [ nodeId ] ;
}
for ( let i = 0 ; i < this . body . supportNodeIndices . length ; i ++ ) {
let nodeId = this . body . supportNodeIndices [ i ] ;
// delete support nodes for edges that have been deleted
if ( this . body . edges [ this . body . supportNodes [ nodeId ] . parentEdgeId ] === undefined ) {
delete this . body . supportNodes [ nodeId ] ;
}
}
}
}
}
}
else {
else {
// delete the support nodes
// delete the support nodes
this . body . sectors [ 'support' ] [ 'nodes' ] = { } ;
this . body . supportNodes = { } ;
for ( var edgeId in this . body . edges ) {
for ( var edgeId in this . body . edges ) {
if ( this . body . edges . hasOwnProperty ( edgeId ) ) {
if ( this . body . edges . hasOwnProperty ( edgeId ) ) {
this . body . edges [ edgeId ] . via = null ;
this . body . edges [ edgeId ] . via = null ;
@ -2619,7 +2570,8 @@ Network.prototype._configureSmoothCurves = function(disableStart) {
}
}
this . _updateCalculationNodes ( ) ;
this . _updateNodeIndexList ( ) ;
this . physics . _updateCalculationNodes ( ) ;
if ( ! disableStart ) {
if ( ! disableStart ) {
this . moving = true ;
this . moving = true ;
this . start ( ) ;
this . start ( ) ;
@ -2633,30 +2585,28 @@ Network.prototype._configureSmoothCurves = function(disableStart) {
*
*
* @ private
* @ private
* /
* /
Network . prototype . _createBezierNodes = function ( specificEdges ) {
console . log ( 'specifics' , specificEdges )
if ( specificEdges === undefined ) {
specificEdges = this . body . edges ;
}
Network . prototype . _createBezierNodes = function ( specificEdges = this . body . edges ) {
if ( this . constants . smoothCurves . enabled == true && this . constants . smoothCurves . dynamic == true ) {
if ( this . constants . smoothCurves . enabled == true && this . constants . smoothCurves . dynamic == true ) {
for ( var edgeId in specificEdges ) {
for ( var edgeId in specificEdges ) {
if ( specificEdges . hasOwnProperty ( edgeId ) ) {
if ( specificEdges . hasOwnProperty ( edgeId ) ) {
var edge = specificEdges [ edgeId ] ;
var edge = specificEdges [ edgeId ] ;
if ( edge . via == null ) {
if ( edge . via == null ) {
var nodeId = "edgeId:" . concat ( edge . id ) ;
var nodeId = "edgeId:" . concat ( edge . id ) ;
this . body . sectors [ 'support' ] [ 'nodes' ] [ nodeId ] = new Node (
var node = new Node (
{ id : nodeId ,
{ id : nodeId ,
mass : 1 ,
mass : 1 ,
shape : 'circle' ,
shape : 'circle' ,
image : "" ,
image : "" ,
internalMultiplier : 1
internalMultiplier : 1
} , { } , { } , this . constants ) ;
} , { } , { } , this . constants ) ;
edge . via = this . body . sectors [ 'support' ] [ 'nodes' ] [ nodeId ] ;
this . body . supportNodes [ nodeId ] = node ;
edge . via = node ;
edge . via . parentEdgeId = edge . id ;
edge . via . parentEdgeId = edge . id ;
edge . positionBezierNode ( ) ;
edge . positionBezierNode ( ) ;
}
}
}
}
}
}
this . _updateNodeIndexList ( ) ;
}
}
} ;
} ;