Browse Source

bughunt 4, going back commits

css_transitions
Alex de Mulder 10 years ago
parent
commit
c34d9697b2
5 changed files with 22 additions and 21082 deletions
  1. +0
    -21055
      dist/vis.js
  2. +3
    -3
      src/graph/ClusterMixin.js
  3. +3
    -1
      src/graph/Edge.js
  4. +2
    -3
      src/graph/Graph.js
  5. +14
    -20
      src/graph/physicsMixin.js

+ 0
- 21055
dist/vis.js
File diff suppressed because it is too large
View File


+ 3
- 3
src/graph/ClusterMixin.js View File

@ -359,9 +359,9 @@ var ClusterMixin = {
parentNode.dynamicEdgesLength = parentNode.dynamicEdges.length;
// place the child node near the parent, not at the exact same location to avoid chaos in the system
childNode.x = parentNode.x + this.constants.physics.springLength * (0.1 * (0.5 - Math.random()) * parentNode.clusterSize);
childNode.y = parentNode.y + this.constants.physics.springLength * (0.1 * (0.5 - Math.random()) * parentNode.clusterSize);
console.log(childNode.x,childNode.y,parentNode.x,parentNode.y);
childNode.x = parentNode.x + this.constants.edges.length * 0.3 * (0.5 - Math.random()) * parentNode.clusterSize;
childNode.y = parentNode.y + this.constants.edges.length * 0.3 * (0.5 - Math.random()) * parentNode.clusterSize;
// remove node from the list
delete parentNode.containedNodes[containedNodeId];

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

@ -31,7 +31,7 @@ function Edge (properties, graph, constants) {
this.title = undefined;
this.width = constants.edges.width;
this.value = undefined;
this.length = constants.physics.springLength;
this.length = constants.edges.length;
this.selected = false;
this.from = null; // a node
@ -55,6 +55,7 @@ function Edge (properties, graph, constants) {
this.lengthFixed = false;
this.setProperties(properties, constants);
}
/**
@ -102,6 +103,7 @@ Edge.prototype.setProperties = function(properties, constants) {
this.widthFixed = this.widthFixed || (properties.width !== undefined);
this.lengthFixed = this.lengthFixed || (properties.length !== undefined);
this.stiffness = 1 / this.length;
// set draw method based on style
switch (this.style) {

+ 2
- 3
src/graph/Graph.js View File

@ -450,7 +450,7 @@ Graph.prototype.setOptions = function (options) {
if (options.edges.length !== undefined &&
options.nodes && options.nodes.distance === undefined) {
this.constants.physics.springLength = options.edges.length;
this.constants.edges.length = options.edges.length;
this.constants.nodes.distance = options.edges.length * 1.25;
}
@ -1770,7 +1770,6 @@ Graph.prototype.start = function() {
}
graph.start();
graph.start();
graph._redraw();
@ -1792,7 +1791,7 @@ Graph.prototype.start = function() {
*/
Graph.prototype.singleStep = function() {
if (this.moving) {
this._initializeForceCalculation(true);
this._initializeForceCalculation();
this._discreteStepNodes();
var vmin = this.constants.minVelocity;

+ 14
- 20
src/graph/physicsMixin.js View File

@ -11,7 +11,7 @@ var physicsMixin = {
*
* @private
*/
_initializeForceCalculation : function(useBarnesHut) {
_initializeForceCalculation : function() {
// stop calculation if there is only one node
if (this.nodeIndices.length == 1) {
this.nodes[this.nodeIndices[0]]._setForce(0,0);
@ -22,15 +22,9 @@ var physicsMixin = {
this.clusterToFit(this.constants.clustering.reduceToNodes, false);
}
this._calculateForcesRepulsion();
// // we now start the force calculation
// if (useBarnesHut == true) {
// this._calculateForcesBarnesHut();
// }
// else {
// this._calculateForcesRepulsion();
// }
// we now start the force calculation
// this._calculateForcesBarnesHut();
this._calculateForcesOriginal();
}
},
@ -40,23 +34,23 @@ var physicsMixin = {
* Forces are caused by: edges, repulsing forces between nodes, gravity
* @private
*/
_calculateForcesRepulsion : function() {
_calculateForcesOriginal : function() {
// Gravity is required to keep separated groups from floating off
// the forces are reset to zero in this loop by using _setForce instead
// of _addForce
// var startTimeAll = Date.now();
this._applyCentralGravity();
this._calculateGravitationalForces(1);
// var startTimeRepulsion = Date.now();
// All nodes repel eachother.
this._applyNodeRepulsion();
this._calculateRepulsionForces();
// var endTimeRepulsion = Date.now();
// the edges are strings
this._applySpringForces();
this._calculateSpringForces(1);
// var endTimeAll = Date.now();
@ -76,7 +70,7 @@ var physicsMixin = {
// var startTimeAll = Date.now();
this._applyCentralGravity();
this._clearForces();
// var startTimeRepulsion = Date.now();
// All nodes repel eachother.
@ -85,7 +79,7 @@ var physicsMixin = {
// var endTimeRepulsion = Date.now();
// the edges are strings
this._applySpringForces();
this._calculateSpringForces(1);
// var endTimeAll = Date.now();
@ -105,7 +99,7 @@ var physicsMixin = {
}
},
_applyCentralGravity : function() {
_calculateGravitationalForces : function(boost) {
var dx, dy, angle, fx, fy, node, i;
var nodes = this.nodes;
var gravity = this.constants.physics.centralGravity;
@ -130,7 +124,7 @@ var physicsMixin = {
}
},
_applyNodeRepulsion : function() {
_calculateRepulsionForces : function() {
var dx, dy, angle, distance, fx, fy, clusterSize,
repulsingForce, node1, node2, i, j;
var nodes = this.nodes;
@ -180,7 +174,7 @@ var physicsMixin = {
}
},
_applySpringForces : function() {
_calculateSpringForces : function(boost) {
var dx, dy, angle, fx, fy, springForce, length, edgeLength, edge, edgeId, clusterSize;
var edges = this.edges;
@ -206,7 +200,7 @@ var physicsMixin = {
fx = Math.cos(angle) * springForce;
fy = Math.sin(angle) * springForce;
//console.log(edge.length,dx,dy,edge.springConstant,angle)
edge.from._addForce(-fx, -fy);
edge.to._addForce(fx, fy);
}

Loading…
Cancel
Save