vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

530 lines
23 KiB

  1. /**
  2. * Created by Alex on 2/6/14.
  3. */
  4. var physicsMixin = {
  5. /**
  6. * Toggling barnes Hut calculation on and off.
  7. *
  8. * @private
  9. */
  10. _toggleBarnesHut : function() {
  11. this.constants.physics.barnesHut.enabled = !this.constants.physics.barnesHut.enabled;
  12. this._loadSelectedForceSolver();
  13. this.moving = true;
  14. this.start();
  15. },
  16. /**
  17. * This loads the node force solver based on the barnes hut or repulsion algorithm
  18. *
  19. * @private
  20. */
  21. _loadSelectedForceSolver : function() {
  22. // this overloads the this._calculateNodeForces
  23. if (this.constants.physics.barnesHut.enabled == true) {
  24. this._clearMixin(repulsionMixin);
  25. this._clearMixin(hierarchalRepulsionMixin);
  26. this.constants.physics.centralGravity = this.constants.physics.barnesHut.centralGravity;
  27. this.constants.physics.springLength = this.constants.physics.barnesHut.springLength;
  28. this.constants.physics.springConstant = this.constants.physics.barnesHut.springConstant;
  29. this.constants.physics.damping = this.constants.physics.barnesHut.damping;
  30. this._loadMixin(barnesHutMixin);
  31. }
  32. else if (this.constants.physics.hierarchicalRepulsion.enabled == true) {
  33. this._clearMixin(barnesHutMixin);
  34. this._clearMixin(repulsionMixin);
  35. this.constants.physics.centralGravity = this.constants.physics.hierarchicalRepulsion.centralGravity;
  36. this.constants.physics.springLength = this.constants.physics.hierarchicalRepulsion.springLength;
  37. this.constants.physics.springConstant = this.constants.physics.hierarchicalRepulsion.springConstant;
  38. this.constants.physics.damping = this.constants.physics.hierarchicalRepulsion.damping;
  39. this._loadMixin(hierarchalRepulsionMixin);
  40. }
  41. else {
  42. this._clearMixin(barnesHutMixin);
  43. this._clearMixin(hierarchalRepulsionMixin);
  44. this.barnesHutTree = undefined;
  45. this.constants.physics.centralGravity = this.constants.physics.repulsion.centralGravity;
  46. this.constants.physics.springLength = this.constants.physics.repulsion.springLength;
  47. this.constants.physics.springConstant = this.constants.physics.repulsion.springConstant;
  48. this.constants.physics.damping = this.constants.physics.repulsion.damping;
  49. this._loadMixin(repulsionMixin);
  50. }
  51. },
  52. /**
  53. * Before calculating the forces, we check if we need to cluster to keep up performance and we check
  54. * if there is more than one node. If it is just one node, we dont calculate anything.
  55. *
  56. * @private
  57. */
  58. _initializeForceCalculation : function() {
  59. // stop calculation if there is only one node
  60. if (this.nodeIndices.length == 1) {
  61. this.nodes[this.nodeIndices[0]]._setForce(0,0);
  62. }
  63. else {
  64. // if there are too many nodes on screen, we cluster without repositioning
  65. if (this.nodeIndices.length > this.constants.clustering.clusterThreshold && this.constants.clustering.enabled == true) {
  66. this.clusterToFit(this.constants.clustering.reduceToNodes, false);
  67. }
  68. // we now start the force calculation
  69. this._calculateForces();
  70. }
  71. },
  72. /**
  73. * Calculate the external forces acting on the nodes
  74. * Forces are caused by: edges, repulsing forces between nodes, gravity
  75. * @private
  76. */
  77. _calculateForces : function() {
  78. // Gravity is required to keep separated groups from floating off
  79. // the forces are reset to zero in this loop by using _setForce instead
  80. // of _addForce
  81. this._calculateGravitationalForces();
  82. this._calculateNodeForces();
  83. if (this.constants.smoothCurves == true) {
  84. this._calculateSpringForcesWithSupport();
  85. }
  86. else {
  87. this._calculateSpringForces();
  88. }
  89. },
  90. /**
  91. * Smooth curves are created by adding invisible nodes in the center of the edges. These nodes are also
  92. * handled in the calculateForces function. We then use a quadratic curve with the center node as control.
  93. * This function joins the datanodes and invisible (called support) nodes into one object.
  94. * We do this so we do not contaminate this.nodes with the support nodes.
  95. *
  96. * @private
  97. */
  98. _updateCalculationNodes : function() {
  99. if (this.constants.smoothCurves == true) {
  100. this.calculationNodes = {};
  101. this.calculationNodeIndices = [];
  102. for (var nodeId in this.nodes) {
  103. if (this.nodes.hasOwnProperty(nodeId)) {
  104. this.calculationNodes[nodeId] = this.nodes[nodeId];
  105. }
  106. }
  107. var supportNodes = this.sectors['support']['nodes'];
  108. for (var supportNodeId in supportNodes) {
  109. if (supportNodes.hasOwnProperty(supportNodeId)) {
  110. if (this.edges.hasOwnProperty(supportNodes[supportNodeId].parentEdgeId)) {
  111. this.calculationNodes[supportNodeId] = supportNodes[supportNodeId];
  112. }
  113. else {
  114. supportNodes[supportNodeId]._setForce(0,0);
  115. }
  116. }
  117. }
  118. for (var idx in this.calculationNodes) {
  119. if (this.calculationNodes.hasOwnProperty(idx)) {
  120. this.calculationNodeIndices.push(idx);
  121. }
  122. }
  123. }
  124. else {
  125. this.calculationNodes = this.nodes;
  126. this.calculationNodeIndices = this.nodeIndices;
  127. }
  128. },
  129. /**
  130. * this function applies the central gravity effect to keep groups from floating off
  131. *
  132. * @private
  133. */
  134. _calculateGravitationalForces : function() {
  135. var dx, dy, distance, node, i;
  136. var nodes = this.calculationNodes;
  137. var gravity = this.constants.physics.centralGravity;
  138. var gravityForce = 0;
  139. for (i = 0; i < this.calculationNodeIndices.length; i++) {
  140. node = nodes[this.calculationNodeIndices[i]];
  141. node.damping = this.constants.physics.damping; // possibly add function to alter damping properties of clusters.
  142. // gravity does not apply when we are in a pocket sector
  143. if (this._sector() == "default" && gravity != 0) {
  144. dx = -node.x;
  145. dy = -node.y;
  146. distance = Math.sqrt(dx*dx + dy*dy);
  147. gravityForce = gravity / distance;
  148. node.fx = dx * gravityForce;
  149. node.fy = dy * gravityForce;
  150. }
  151. else {
  152. node.fx = 0;
  153. node.fy = 0;
  154. }
  155. }
  156. },
  157. /**
  158. * this function calculates the effects of the springs in the case of unsmooth curves.
  159. *
  160. * @private
  161. */
  162. _calculateSpringForces : function() {
  163. var edgeLength, edge, edgeId;
  164. var dx, dy, fx, fy, springForce, length;
  165. var edges = this.edges;
  166. // forces caused by the edges, modelled as springs
  167. for (edgeId in edges) {
  168. if (edges.hasOwnProperty(edgeId)) {
  169. edge = edges[edgeId];
  170. if (edge.connected) {
  171. // only calculate forces if nodes are in the same sector
  172. if (this.nodes.hasOwnProperty(edge.toId) && this.nodes.hasOwnProperty(edge.fromId)) {
  173. edgeLength = edge.customLength ? edge.length : this.constants.physics.springLength;
  174. // this implies that the edges between big clusters are longer
  175. edgeLength += (edge.to.clusterSize + edge.from.clusterSize - 2) * this.constants.clustering.edgeGrowth;
  176. dx = (edge.from.x - edge.to.x);
  177. dy = (edge.from.y - edge.to.y);
  178. length = Math.sqrt(dx * dx + dy * dy);
  179. if (length == 0) {
  180. length = 0.01;
  181. }
  182. springForce = this.constants.physics.springConstant * (edgeLength - length) / length;
  183. fx = dx * springForce;
  184. fy = dy * springForce;
  185. edge.from.fx += fx;
  186. edge.from.fy += fy;
  187. edge.to.fx -= fx;
  188. edge.to.fy -= fy;
  189. }
  190. }
  191. }
  192. }
  193. },
  194. /**
  195. * This function calculates the springforces on the nodes, accounting for the support nodes.
  196. *
  197. * @private
  198. */
  199. _calculateSpringForcesWithSupport : function() {
  200. var edgeLength, edge, edgeId, combinedClusterSize;
  201. var edges = this.edges;
  202. // forces caused by the edges, modelled as springs
  203. for (edgeId in edges) {
  204. if (edges.hasOwnProperty(edgeId)) {
  205. edge = edges[edgeId];
  206. if (edge.connected) {
  207. // only calculate forces if nodes are in the same sector
  208. if (this.nodes.hasOwnProperty(edge.toId) && this.nodes.hasOwnProperty(edge.fromId)) {
  209. if (edge.via != null) {
  210. var node1 = edge.to;
  211. var node2 = edge.via;
  212. var node3 = edge.from;
  213. edgeLength = edge.customLength ? edge.length : this.constants.physics.springLength;
  214. combinedClusterSize = node1.clusterSize + node3.clusterSize - 2;
  215. // this implies that the edges between big clusters are longer
  216. edgeLength += combinedClusterSize * this.constants.clustering.edgeGrowth;
  217. this._calculateSpringForce(node1,node2,0.5*edgeLength);
  218. this._calculateSpringForce(node2,node3,0.5*edgeLength);
  219. }
  220. }
  221. }
  222. }
  223. }
  224. },
  225. /**
  226. * This is the code actually performing the calculation for the function above. It is split out to avoid repetition.
  227. *
  228. * @param node1
  229. * @param node2
  230. * @param edgeLength
  231. * @private
  232. */
  233. _calculateSpringForce : function(node1,node2,edgeLength) {
  234. var dx, dy, fx, fy, springForce, length;
  235. dx = (node1.x - node2.x);
  236. dy = (node1.y - node2.y);
  237. length = Math.sqrt(dx * dx + dy * dy);
  238. springForce = this.constants.physics.springConstant * (edgeLength - length) / length;
  239. if (length == 0) {
  240. length = 0.01;
  241. }
  242. fx = dx * springForce;
  243. fy = dy * springForce;
  244. node1.fx += fx;
  245. node1.fy += fy;
  246. node2.fx -= fx;
  247. node2.fy -= fy;
  248. },
  249. /**
  250. * Load the HTML for the physics config and bind it
  251. * @private
  252. */
  253. _loadPhysicsConfiguration : function() {
  254. if (this.physicsConfiguration === undefined) {
  255. this.physicsConfiguration = document.createElement('div');
  256. this.physicsConfiguration.className = "PhysicsConfiguration";
  257. this.physicsConfiguration.innerHTML = '' +
  258. '<table><tr><td><b>Simulation Mode:</b></td></tr>' +
  259. '<tr>' +
  260. '<td width="120px"><input type="radio" name="graph_physicsMethod" id="graph_physicsMethod1" value="BH" checked="checked">Barnes Hut</td>' +
  261. '<td width="120px"><input type="radio" name="graph_physicsMethod" id="graph_physicsMethod2" value="R">Repulsion</td>'+
  262. '<td width="120px"><input type="radio" name="graph_physicsMethod" id="graph_physicsMethod3" value="H">Hierarchical</td>' +
  263. '</tr>'+
  264. '</table>' +
  265. '<table id="graph_BH_table" style="display:none">'+
  266. '<tr><td><b>Barnes Hut</b></td></tr>'+
  267. '<tr>'+
  268. '<td width="150px">gravitationalConstant</td><td>0</td><td><input type="range" min="500" max="20000" value="2000" step="25" style="width:300px" id="graph_BH_gc"></td><td width="50px">-20000</td><td><input value="-2000" id="graph_BH_gc_value" style="width:60px"></td>'+
  269. '</tr>'+
  270. '<tr>'+
  271. '<td width="150px">centralGravity</td><td>0</td><td><input type="range" min="0" max="3" value="0.3" step="0.05" style="width:300px" id="graph_BH_cg"></td><td>3</td><td><input value="0.03" id="graph_BH_cg_value" style="width:60px"></td>'+
  272. '</tr>'+
  273. '<tr>'+
  274. '<td width="150px">springLength</td><td>0</td><td><input type="range" min="0" max="500" value="100" step="1" style="width:300px" id="graph_BH_sl"></td><td>500</td><td><input value="100" id="graph_BH_sl_value" style="width:60px"></td>'+
  275. '</tr>'+
  276. '<tr>'+
  277. '<td width="150px">springConstant</td><td>0</td><td><input type="range" min="0" max="0.5" value="0.05" step="0.005" style="width:300px" id="graph_BH_sc"></td><td>0.5</td><td><input value="0.05" id="graph_BH_sc_value" style="width:60px"></td>'+
  278. '</tr>'+
  279. '<tr>'+
  280. '<td width="150px">damping</td><td>0</td><td><input type="range" min="0" max="0.3" value="0.09" step="0.005" style="width:300px" id="graph_BH_damp"></td><td>0.3</td><td><input value="0.09" id="graph_BH_damp_value" style="width:60px"></td>'+
  281. '</tr>'+
  282. '</table>'+
  283. '<table id="graph_R_table" style="display:none">'+
  284. '<tr><td><b>Repulsion</b></td></tr>'+
  285. '<tr>'+
  286. '<td width="150px">nodeDistance</td><td>0</td><td><input type="range" min="0" max="300" value="100" step="1" style="width:300px" id="graph_R_nd"></td><td width="50px">300</td><td><input value="100" id="graph_R_nd_value" style="width:60px"></td>'+
  287. '</tr>'+
  288. '<tr>'+
  289. '<td width="150px">centralGravity</td><td>0</td><td><input type="range" min="0" max="3" value="0.1" step="0.05" style="width:300px" id="graph_R_cg"></td><td>3</td><td><input value="0.01" id="graph_R_cg_value" style="width:60px"></td>'+
  290. '</tr>'+
  291. '<tr>'+
  292. '<td width="150px">springLength</td><td>0</td><td><input type="range" min="0" max="500" value="200" step="1" style="width:300px" id="graph_R_sl"></td><td>500</td><td><input value="200" id="graph_R_sl_value" style="width:60px"></td>'+
  293. '</tr>'+
  294. '<tr>'+
  295. '<td width="150px">springConstant</td><td>0</td><td><input type="range" min="0" max="0.5" value="0.05" step="0.005" style="width:300px" id="graph_R_sc"></td><td>0.5</td><td><input value="0.05" id="graph_R_sc_value" style="width:60px"></td>'+
  296. '</tr>'+
  297. '<tr>'+
  298. '<td width="150px">damping</td><td>0</td><td><input type="range" min="0" max="0.3" value="0.09" step="0.005" style="width:300px" id="graph_R_damp"></td><td>0.3</td><td><input value="0.09" id="graph_R_damp_value" style="width:60px"></td>'+
  299. '</tr>'+
  300. '</table>'+
  301. '<table id="graph_H_table" style="display:none">'+
  302. '<tr><td width="150"><b>Hierarchical</b></td></tr>'+
  303. '<tr>'+
  304. '<td width="150px">nodeDistance</td><td>0</td><td><input type="range" min="0" max="300" value="60" step="1" style="width:300px" id="graph_H_nd"></td><td width="50px">300</td><td><input value="60" id="graph_H_nd_value" style="width:60px"></td>'+
  305. '</tr>'+
  306. '<tr>'+
  307. '<td width="150px">centralGravity</td><td>0</td><td><input type="range" min="0" max="3" value="0" step="0.05" style="width:300px" id="graph_H_cg"></td><td>3</td><td><input value="0" id="graph_H_cg_value" style="width:60px"></td>'+
  308. '</tr>'+
  309. '<tr>'+
  310. '<td width="150px">springLength</td><td>0</td><td><input type="range" min="0" max="500" value="100" step="1" style="width:300px" id="graph_H_sl"></td><td>500</td><td><input value="100" id="graph_H_sl_value" style="width:60px"></td>'+
  311. '</tr>'+
  312. '<tr>'+
  313. '<td width="150px">springConstant</td><td>0</td><td><input type="range" min="0" max="0.5" value="0.01" step="0.005" style="width:300px" id="graph_H_sc"></td><td>0.5</td><td><input value="0.01" id="graph_H_sc_value" style="width:60px"></td>'+
  314. '</tr>'+
  315. '<tr>'+
  316. '<td width="150px">damping</td><td>0</td><td><input type="range" min="0" max="0.3" value="0.09" step="0.005" style="width:300px" id="graph_H_damp"></td><td>0.3</td><td><input value="0.09" id="graph_H_damp_value" style="width:60px"></td>'+
  317. '</tr>'+
  318. '<tr>'+
  319. '<td width="150px">direction</td><td>1</td><td><input type="range" min="0" max="3" value="0" step="1" style="width:300px" id="graph_H_direction"></td><td>4</td><td><input value="LR" id="graph_H_direction_value" style="width:60px"></td>'+
  320. '</tr>'+
  321. '<tr>'+
  322. '<td width="150px">levelSeparation</td><td>1</td><td><input type="range" min="0" max="500" value="150" step="1" style="width:300px" id="graph_H_levsep"></td><td>500</td><td><input value="150" id="graph_H_levsep_value" style="width:60px"></td>'+
  323. '</tr>'+
  324. '<tr>'+
  325. '<td width="150px">nodeSpacing</td><td>1</td><td><input type="range" min="0" max="500" value="100" step="1" style="width:300px" id="graph_H_nspac"></td><td>500</td><td><input value="100" id="graph_H_nspac_value" style="width:60px"></td>'+
  326. '</tr>'+
  327. '</table>'
  328. this.containerElement.parentElement.insertBefore(this.physicsConfiguration,this.containerElement);
  329. var hierarchicalLayoutDirections = ["LR","RL","UD","DU"];
  330. var rangeElement;
  331. rangeElement = document.getElementById('graph_BH_gc');
  332. rangeElement.innerHTML = this.constants.physics.barnesHut.gravitationalConstant;
  333. rangeElement.onchange = showValueOfRange.bind(this,'graph_BH_gc',-1,"physics_barnesHut_gravitationalConstant");
  334. rangeElement = document.getElementById('graph_BH_cg');
  335. rangeElement.innerHTML = this.constants.physics.barnesHut.centralGravity;
  336. rangeElement.onchange = showValueOfRange.bind(this,'graph_BH_cg',1,"physics_centralGravity");
  337. rangeElement = document.getElementById('graph_BH_sc');
  338. rangeElement.innerHTML = this.constants.physics.barnesHut.springConstant;
  339. rangeElement.onchange = showValueOfRange.bind(this,'graph_BH_sc',1,"physics_springConstant");
  340. rangeElement = document.getElementById('graph_BH_sl');
  341. rangeElement.innerHTML = this.constants.physics.barnesHut.springLength;
  342. rangeElement.onchange = showValueOfRange.bind(this,'graph_BH_sl',1,"physics_springLength");
  343. rangeElement = document.getElementById('graph_BH_damp');
  344. rangeElement.innerHTML = this.constants.physics.barnesHut.damping;
  345. rangeElement.onchange = showValueOfRange.bind(this,'graph_BH_damp',1,"physics_damping");
  346. rangeElement = document.getElementById('graph_R_nd');
  347. rangeElement.innerHTML = this.constants.physics.repulsion.nodeDistance;
  348. rangeElement.onchange = showValueOfRange.bind(this,'graph_R_nd',1,"physics_repulsion_nodeDistance");
  349. rangeElement = document.getElementById('graph_R_cg');
  350. rangeElement.innerHTML = this.constants.physics.repulsion.centralGravity;
  351. rangeElement.onchange = showValueOfRange.bind(this,'graph_R_cg',1,"physics_centralGravity");
  352. rangeElement = document.getElementById('graph_R_sc');
  353. rangeElement.innerHTML = this.constants.physics.repulsion.springConstant;
  354. rangeElement.onchange = showValueOfRange.bind(this,'graph_R_sc',1,"physics_springConstant");
  355. rangeElement = document.getElementById('graph_R_sl');
  356. rangeElement.innerHTML = this.constants.physics.repulsion.springLength;
  357. rangeElement.onchange = showValueOfRange.bind(this,'graph_R_sl',1,"physics_springLength");
  358. rangeElement = document.getElementById('graph_R_damp');
  359. rangeElement.innerHTML = this.constants.physics.repulsion.damping;
  360. rangeElement.onchange = showValueOfRange.bind(this,'graph_R_damp',1,"physics_damping");
  361. rangeElement = document.getElementById('graph_H_nd');
  362. rangeElement.innerHTML = this.constants.physics.hierarchicalRepulsion.nodeDistance;
  363. rangeElement.onchange = showValueOfRange.bind(this,'graph_H_nd',1,"physics_hierarchicalRepulsion_nodeDistance");
  364. rangeElement = document.getElementById('graph_H_cg');
  365. rangeElement.innerHTML = this.constants.physics.hierarchicalRepulsion.centralGravity;
  366. rangeElement.onchange = showValueOfRange.bind(this,'graph_H_cg',1,"physics_centralGravity");
  367. rangeElement = document.getElementById('graph_H_sc');
  368. rangeElement.innerHTML = this.constants.physics.hierarchicalRepulsion.springConstant;
  369. rangeElement.onchange = showValueOfRange.bind(this,'graph_H_sc',1,"physics_springConstant");
  370. rangeElement = document.getElementById('graph_H_sl');
  371. rangeElement.innerHTML = this.constants.physics.hierarchicalRepulsion.springLength;
  372. rangeElement.onchange = showValueOfRange.bind(this,'graph_H_sl',1,"physics_springLength");
  373. rangeElement = document.getElementById('graph_H_damp');
  374. rangeElement.innerHTML = this.constants.physics.hierarchicalRepulsion.damping;
  375. rangeElement.onchange = showValueOfRange.bind(this,'graph_H_damp',1,"physics_damping");
  376. rangeElement = document.getElementById('graph_H_direction');
  377. rangeElement.innerHTML = hierarchicalLayoutDirections.indexOf(this.constants.hierarchicalLayout.direction);
  378. rangeElement.onchange = showValueOfRange.bind(this,'graph_H_direction',hierarchicalLayoutDirections,"hierarchicalLayout_direction");
  379. rangeElement = document.getElementById('graph_H_levsep');
  380. rangeElement.innerHTML = this.constants.hierarchicalLayout.levelSeparation;
  381. rangeElement.onchange = showValueOfRange.bind(this,'graph_H_levsep',1,"hierarchicalLayout_levelSeparation");
  382. rangeElement = document.getElementById('graph_H_nspac');
  383. rangeElement.innerHTML = this.constants.hierarchicalLayout.nodeSpacing;
  384. rangeElement.onchange = showValueOfRange.bind(this,'graph_H_nspac',1,"hierarchicalLayout_nodeSpacing");
  385. var radioButton1 = document.getElementById("graph_physicsMethod1");
  386. var radioButton2 = document.getElementById("graph_physicsMethod2");
  387. var radioButton3 = document.getElementById("graph_physicsMethod3");
  388. radioButton2.checked = true;
  389. if (this.constants.physics.barnesHut.enabled) {
  390. radioButton1.checked = true;
  391. }
  392. if (this.constants.hierarchicalLayout.enabled) {
  393. radioButton3.checked = true;
  394. }
  395. switchConfigurations.apply(this);
  396. radioButton1.onchange = switchConfigurations.bind(this);
  397. radioButton2.onchange = switchConfigurations.bind(this);
  398. radioButton3.onchange = switchConfigurations.bind(this);
  399. }
  400. },
  401. _overWriteGraphConstants : function(constantsVariableName, value) {
  402. var nameArray = constantsVariableName.split("_");
  403. if (nameArray.length == 1) {
  404. this.constants[nameArray[0]] = value;
  405. }
  406. else if (nameArray.length == 2) {
  407. this.constants[nameArray[0]][nameArray[1]] = value;
  408. }
  409. else if (nameArray.length == 3) {
  410. this.constants[nameArray[0]][nameArray[1]][nameArray[2]] = value;
  411. }
  412. }
  413. }
  414. function switchConfigurations () {
  415. var ids = ["graph_BH_table","graph_R_table","graph_H_table"]
  416. var radioButton = document.querySelector('input[name="graph_physicsMethod"]:checked').value;
  417. var tableId = "graph_" + radioButton + "_table";
  418. var table = document.getElementById(tableId);
  419. table.style.display = "block";
  420. for (var i = 0; i < ids.length; i++) {
  421. if (ids[i] != tableId) {
  422. table = document.getElementById(ids[i]);
  423. table.style.display = "none";
  424. }
  425. }
  426. this._restoreNodes();
  427. if (radioButton == "R") {
  428. this.constants.hierarchicalLayout.enabled = false;
  429. this.constants.physics.hierarchicalRepulsion.enabeled = false;
  430. this.constants.physics.barnesHut.enabled = false;
  431. }
  432. else if (radioButton == "H") {
  433. this.constants.hierarchicalLayout.enabled = true;
  434. this.constants.physics.hierarchicalRepulsion.enabeled = true;
  435. this.constants.physics.barnesHut.enabled = false;
  436. this._setupHierarchicalLayout();
  437. }
  438. else {
  439. this.constants.hierarchicalLayout.enabled = false;
  440. this.constants.physics.hierarchicalRepulsion.enabeled = false;
  441. this.constants.physics.barnesHut.enabled = true;
  442. }
  443. this._loadSelectedForceSolver();
  444. this.moving = true;
  445. this.start();
  446. }
  447. function showValueOfRange (id,map,constantsVariableName) {
  448. var valueId = id + "_value";
  449. var rangeValue = document.getElementById(id).value;
  450. if (constantsVariableName == "hierarchicalLayout_direction" ||
  451. constantsVariableName == "hierarchicalLayout_levelSeparation" ||
  452. constantsVariableName == "hierarchicalLayout_nodeSpacing") {
  453. this._setupHierarchicalLayout();
  454. }
  455. if (map instanceof Array) {
  456. document.getElementById(valueId).value = map[parseInt(rangeValue)];
  457. this._overWriteGraphConstants(constantsVariableName,map[parseInt(rangeValue)]);
  458. }
  459. else {
  460. document.getElementById(valueId).value = map * parseFloat(rangeValue);
  461. this._overWriteGraphConstants(constantsVariableName,map * parseFloat(rangeValue));
  462. }
  463. this.moving = true;
  464. this.start();
  465. };