vis-rails 0.0.6 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vis/rails/version.rb +1 -1
- data/vendor/assets/javascripts/vis.js +2 -9
- data/vendor/assets/vis/DataSet.js +17 -9
- data/vendor/assets/vis/graph/Edge.js +49 -24
- data/vendor/assets/vis/graph/Graph.js +268 -64
- data/vendor/assets/vis/graph/Groups.js +1 -1
- data/vendor/assets/vis/graph/Node.js +18 -67
- data/vendor/assets/vis/graph/Popup.js +40 -13
- data/vendor/assets/vis/graph/css/graph-navigation.css +18 -14
- data/vendor/assets/vis/graph/graphMixins/ClusterMixin.js +7 -5
- data/vendor/assets/vis/graph/graphMixins/HierarchicalLayoutMixin.js +20 -5
- data/vendor/assets/vis/graph/graphMixins/ManipulationMixin.js +33 -33
- data/vendor/assets/vis/graph/graphMixins/MixinLoader.js +30 -32
- data/vendor/assets/vis/graph/graphMixins/NavigationMixin.js +33 -1
- data/vendor/assets/vis/graph/graphMixins/SectorsMixin.js +2 -2
- data/vendor/assets/vis/graph/graphMixins/SelectionMixin.js +72 -60
- data/vendor/assets/vis/graph/graphMixins/physics/BarnesHut.js +43 -18
- data/vendor/assets/vis/graph/graphMixins/physics/HierarchialRepulsion.js +8 -8
- data/vendor/assets/vis/graph/graphMixins/physics/PhysicsMixin.js +309 -129
- data/vendor/assets/vis/graph/graphMixins/physics/Repulsion.js +10 -10
- data/vendor/assets/vis/module/exports.js +1 -2
- data/vendor/assets/vis/module/header.js +2 -2
- data/vendor/assets/vis/timeline/Range.js +53 -93
- data/vendor/assets/vis/timeline/Timeline.js +328 -224
- data/vendor/assets/vis/timeline/component/Component.js +17 -95
- data/vendor/assets/vis/timeline/component/CurrentTime.js +54 -59
- data/vendor/assets/vis/timeline/component/CustomTime.js +55 -83
- data/vendor/assets/vis/timeline/component/Group.js +398 -75
- data/vendor/assets/vis/timeline/component/ItemSet.js +662 -403
- data/vendor/assets/vis/timeline/component/Panel.js +118 -60
- data/vendor/assets/vis/timeline/component/RootPanel.js +80 -132
- data/vendor/assets/vis/timeline/component/TimeAxis.js +191 -277
- data/vendor/assets/vis/timeline/component/css/item.css +16 -23
- data/vendor/assets/vis/timeline/component/css/itemset.css +25 -4
- data/vendor/assets/vis/timeline/component/css/labelset.css +34 -0
- data/vendor/assets/vis/timeline/component/css/panel.css +15 -1
- data/vendor/assets/vis/timeline/component/css/timeaxis.css +8 -8
- data/vendor/assets/vis/timeline/component/item/Item.js +48 -26
- data/vendor/assets/vis/timeline/component/item/ItemBox.js +156 -230
- data/vendor/assets/vis/timeline/component/item/ItemPoint.js +118 -166
- data/vendor/assets/vis/timeline/component/item/ItemRange.js +135 -187
- data/vendor/assets/vis/timeline/component/item/ItemRangeOverflow.js +29 -92
- data/vendor/assets/vis/timeline/stack.js +112 -0
- data/vendor/assets/vis/util.js +136 -38
- metadata +4 -18
- data/vendor/assets/vis/.gitignore +0 -1
- data/vendor/assets/vis/EventBus.js +0 -89
- data/vendor/assets/vis/events.js +0 -116
- data/vendor/assets/vis/graph/ClusterMixin.js +0 -1019
- data/vendor/assets/vis/graph/NavigationMixin.js +0 -245
- data/vendor/assets/vis/graph/SectorsMixin.js +0 -547
- data/vendor/assets/vis/graph/SelectionMixin.js +0 -515
- data/vendor/assets/vis/graph/img/downarrow.png +0 -0
- data/vendor/assets/vis/graph/img/leftarrow.png +0 -0
- data/vendor/assets/vis/graph/img/rightarrow.png +0 -0
- data/vendor/assets/vis/graph/img/uparrow.png +0 -0
- data/vendor/assets/vis/timeline/Controller.js +0 -183
- data/vendor/assets/vis/timeline/Stack.js +0 -190
- data/vendor/assets/vis/timeline/component/ContentPanel.js +0 -113
- data/vendor/assets/vis/timeline/component/GroupSet.js +0 -580
- data/vendor/assets/vis/timeline/component/css/groupset.css +0 -59
@@ -11,23 +11,25 @@ var barnesHutMixin = {
|
|
11
11
|
* @private
|
12
12
|
*/
|
13
13
|
_calculateNodeForces : function() {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
14
|
+
if (this.constants.physics.barnesHut.gravitationalConstant != 0) {
|
15
|
+
var node;
|
16
|
+
var nodes = this.calculationNodes;
|
17
|
+
var nodeIndices = this.calculationNodeIndices;
|
18
|
+
var nodeCount = nodeIndices.length;
|
19
|
+
|
20
|
+
this._formBarnesHutTree(nodes,nodeIndices);
|
21
|
+
|
22
|
+
var barnesHutTree = this.barnesHutTree;
|
23
|
+
|
24
|
+
// place the nodes one by one recursively
|
25
|
+
for (var i = 0; i < nodeCount; i++) {
|
26
|
+
node = nodes[nodeIndices[i]];
|
27
|
+
// starting with root is irrelevant, it never passes the BarnesHut condition
|
28
|
+
this._getForceContribution(barnesHutTree.root.children.NW,node);
|
29
|
+
this._getForceContribution(barnesHutTree.root.children.NE,node);
|
30
|
+
this._getForceContribution(barnesHutTree.root.children.SW,node);
|
31
|
+
this._getForceContribution(barnesHutTree.root.children.SE,node);
|
32
|
+
}
|
31
33
|
}
|
32
34
|
},
|
33
35
|
|
@@ -133,6 +135,7 @@ var barnesHutMixin = {
|
|
133
135
|
mass:0,
|
134
136
|
range: {minX:centerX-halfRootSize,maxX:centerX+halfRootSize,
|
135
137
|
minY:centerY-halfRootSize,maxY:centerY+halfRootSize},
|
138
|
+
|
136
139
|
size: rootSize,
|
137
140
|
calcSize: 1 / rootSize,
|
138
141
|
children: {data:null},
|
@@ -153,6 +156,13 @@ var barnesHutMixin = {
|
|
153
156
|
},
|
154
157
|
|
155
158
|
|
159
|
+
/**
|
160
|
+
* this updates the mass of a branch. this is increased by adding a node.
|
161
|
+
*
|
162
|
+
* @param parentBranch
|
163
|
+
* @param node
|
164
|
+
* @private
|
165
|
+
*/
|
156
166
|
_updateBranchMass : function(parentBranch, node) {
|
157
167
|
var totalMass = parentBranch.mass + node.mass;
|
158
168
|
var totalMassInv = 1/totalMass;
|
@@ -170,6 +180,14 @@ var barnesHutMixin = {
|
|
170
180
|
},
|
171
181
|
|
172
182
|
|
183
|
+
/**
|
184
|
+
* determine in which branch the node will be placed.
|
185
|
+
*
|
186
|
+
* @param parentBranch
|
187
|
+
* @param node
|
188
|
+
* @param skipMassUpdate
|
189
|
+
* @private
|
190
|
+
*/
|
173
191
|
_placeInTree : function(parentBranch,node,skipMassUpdate) {
|
174
192
|
if (skipMassUpdate != true || skipMassUpdate === undefined) {
|
175
193
|
// update the mass of the branch.
|
@@ -195,6 +213,14 @@ var barnesHutMixin = {
|
|
195
213
|
},
|
196
214
|
|
197
215
|
|
216
|
+
/**
|
217
|
+
* actually place the node in a region (or branch)
|
218
|
+
*
|
219
|
+
* @param parentBranch
|
220
|
+
* @param node
|
221
|
+
* @param region
|
222
|
+
* @private
|
223
|
+
*/
|
198
224
|
_placeInRegion : function(parentBranch,node,region) {
|
199
225
|
switch (parentBranch.children[region].childrenCount) {
|
200
226
|
case 0: // place node here
|
@@ -209,7 +235,6 @@ var barnesHutMixin = {
|
|
209
235
|
parentBranch.children[region].children.data.y == node.y) {
|
210
236
|
node.x += Math.random();
|
211
237
|
node.y += Math.random();
|
212
|
-
this._placeInTree(parentBranch,node, true);
|
213
238
|
}
|
214
239
|
else {
|
215
240
|
this._splitBranch(parentBranch.children[region]);
|
@@ -10,8 +10,8 @@ var hierarchalRepulsionMixin = {
|
|
10
10
|
* This field is linearly approximated.
|
11
11
|
*
|
12
12
|
* @private
|
13
|
-
|
14
|
-
_calculateNodeForces
|
13
|
+
*/
|
14
|
+
_calculateNodeForces: function () {
|
15
15
|
var dx, dy, distance, fx, fy, combinedClusterSize,
|
16
16
|
repulsingForce, node1, node2, i, j;
|
17
17
|
|
@@ -20,7 +20,7 @@ var hierarchalRepulsionMixin = {
|
|
20
20
|
|
21
21
|
// approximation constants
|
22
22
|
var b = 5;
|
23
|
-
var a_base = 0.5
|
23
|
+
var a_base = 0.5 * -b;
|
24
24
|
|
25
25
|
|
26
26
|
// repulsing forces between nodes
|
@@ -29,10 +29,10 @@ var hierarchalRepulsionMixin = {
|
|
29
29
|
|
30
30
|
// we loop from i over all but the last entree in the array
|
31
31
|
// j loops from i+1 to the last. This way we do not double count any of the indices, nor i == j
|
32
|
-
for (i = 0; i < nodeIndices.length-1; i++) {
|
32
|
+
for (i = 0; i < nodeIndices.length - 1; i++) {
|
33
33
|
|
34
34
|
node1 = nodes[nodeIndices[i]];
|
35
|
-
for (j = i+1; j < nodeIndices.length; j++) {
|
35
|
+
for (j = i + 1; j < nodeIndices.length; j++) {
|
36
36
|
node2 = nodes[nodeIndices[j]];
|
37
37
|
|
38
38
|
dx = node2.x - node1.x;
|
@@ -40,7 +40,7 @@ var hierarchalRepulsionMixin = {
|
|
40
40
|
distance = Math.sqrt(dx * dx + dy * dy);
|
41
41
|
|
42
42
|
var a = a_base / minimumDistance;
|
43
|
-
if (distance < 2*minimumDistance) {
|
43
|
+
if (distance < 2 * minimumDistance) {
|
44
44
|
repulsingForce = a * distance + b; // linear approx of 1 / (1 + Math.exp((distance / minimumDistance - 1) * steepness))
|
45
45
|
|
46
46
|
// normalize force with
|
@@ -48,7 +48,7 @@ var hierarchalRepulsionMixin = {
|
|
48
48
|
distance = 0.01;
|
49
49
|
}
|
50
50
|
else {
|
51
|
-
repulsingForce = repulsingForce/distance;
|
51
|
+
repulsingForce = repulsingForce / distance;
|
52
52
|
}
|
53
53
|
fx = dx * repulsingForce;
|
54
54
|
fy = dy * repulsingForce;
|
@@ -61,4 +61,4 @@ var hierarchalRepulsionMixin = {
|
|
61
61
|
}
|
62
62
|
}
|
63
63
|
}
|
64
|
-
}
|
64
|
+
};
|
@@ -10,7 +10,7 @@ var physicsMixin = {
|
|
10
10
|
*
|
11
11
|
* @private
|
12
12
|
*/
|
13
|
-
_toggleBarnesHut
|
13
|
+
_toggleBarnesHut: function () {
|
14
14
|
this.constants.physics.barnesHut.enabled = !this.constants.physics.barnesHut.enabled;
|
15
15
|
this._loadSelectedForceSolver();
|
16
16
|
this.moving = true;
|
@@ -18,22 +18,21 @@ var physicsMixin = {
|
|
18
18
|
},
|
19
19
|
|
20
20
|
|
21
|
-
|
22
21
|
/**
|
23
22
|
* This loads the node force solver based on the barnes hut or repulsion algorithm
|
24
23
|
*
|
25
24
|
* @private
|
26
25
|
*/
|
27
|
-
_loadSelectedForceSolver
|
26
|
+
_loadSelectedForceSolver: function () {
|
28
27
|
// this overloads the this._calculateNodeForces
|
29
28
|
if (this.constants.physics.barnesHut.enabled == true) {
|
30
29
|
this._clearMixin(repulsionMixin);
|
31
30
|
this._clearMixin(hierarchalRepulsionMixin);
|
32
31
|
|
33
32
|
this.constants.physics.centralGravity = this.constants.physics.barnesHut.centralGravity;
|
34
|
-
this.constants.physics.springLength
|
33
|
+
this.constants.physics.springLength = this.constants.physics.barnesHut.springLength;
|
35
34
|
this.constants.physics.springConstant = this.constants.physics.barnesHut.springConstant;
|
36
|
-
this.constants.physics.damping
|
35
|
+
this.constants.physics.damping = this.constants.physics.barnesHut.damping;
|
37
36
|
|
38
37
|
this._loadMixin(barnesHutMixin);
|
39
38
|
}
|
@@ -42,9 +41,9 @@ var physicsMixin = {
|
|
42
41
|
this._clearMixin(repulsionMixin);
|
43
42
|
|
44
43
|
this.constants.physics.centralGravity = this.constants.physics.hierarchicalRepulsion.centralGravity;
|
45
|
-
this.constants.physics.springLength
|
44
|
+
this.constants.physics.springLength = this.constants.physics.hierarchicalRepulsion.springLength;
|
46
45
|
this.constants.physics.springConstant = this.constants.physics.hierarchicalRepulsion.springConstant;
|
47
|
-
this.constants.physics.damping
|
46
|
+
this.constants.physics.damping = this.constants.physics.hierarchicalRepulsion.damping;
|
48
47
|
|
49
48
|
this._loadMixin(hierarchalRepulsionMixin);
|
50
49
|
}
|
@@ -54,9 +53,9 @@ var physicsMixin = {
|
|
54
53
|
this.barnesHutTree = undefined;
|
55
54
|
|
56
55
|
this.constants.physics.centralGravity = this.constants.physics.repulsion.centralGravity;
|
57
|
-
this.constants.physics.springLength
|
56
|
+
this.constants.physics.springLength = this.constants.physics.repulsion.springLength;
|
58
57
|
this.constants.physics.springConstant = this.constants.physics.repulsion.springConstant;
|
59
|
-
this.constants.physics.damping
|
58
|
+
this.constants.physics.damping = this.constants.physics.repulsion.damping;
|
60
59
|
|
61
60
|
this._loadMixin(repulsionMixin);
|
62
61
|
}
|
@@ -68,10 +67,10 @@ var physicsMixin = {
|
|
68
67
|
*
|
69
68
|
* @private
|
70
69
|
*/
|
71
|
-
_initializeForceCalculation
|
70
|
+
_initializeForceCalculation: function () {
|
72
71
|
// stop calculation if there is only one node
|
73
72
|
if (this.nodeIndices.length == 1) {
|
74
|
-
this.nodes[this.nodeIndices[0]]._setForce(0,0);
|
73
|
+
this.nodes[this.nodeIndices[0]]._setForce(0, 0);
|
75
74
|
}
|
76
75
|
else {
|
77
76
|
// if there are too many nodes on screen, we cluster without repositioning
|
@@ -90,7 +89,7 @@ var physicsMixin = {
|
|
90
89
|
* Forces are caused by: edges, repulsing forces between nodes, gravity
|
91
90
|
* @private
|
92
91
|
*/
|
93
|
-
_calculateForces
|
92
|
+
_calculateForces: function () {
|
94
93
|
// Gravity is required to keep separated groups from floating off
|
95
94
|
// the forces are reset to zero in this loop by using _setForce instead
|
96
95
|
// of _addForce
|
@@ -98,7 +97,6 @@ var physicsMixin = {
|
|
98
97
|
this._calculateGravitationalForces();
|
99
98
|
this._calculateNodeForces();
|
100
99
|
|
101
|
-
|
102
100
|
if (this.constants.smoothCurves == true) {
|
103
101
|
this._calculateSpringForcesWithSupport();
|
104
102
|
}
|
@@ -116,7 +114,7 @@ var physicsMixin = {
|
|
116
114
|
*
|
117
115
|
* @private
|
118
116
|
*/
|
119
|
-
_updateCalculationNodes
|
117
|
+
_updateCalculationNodes: function () {
|
120
118
|
if (this.constants.smoothCurves == true) {
|
121
119
|
this.calculationNodes = {};
|
122
120
|
this.calculationNodeIndices = [];
|
@@ -133,7 +131,7 @@ var physicsMixin = {
|
|
133
131
|
this.calculationNodes[supportNodeId] = supportNodes[supportNodeId];
|
134
132
|
}
|
135
133
|
else {
|
136
|
-
supportNodes[supportNodeId]._setForce(0,0);
|
134
|
+
supportNodes[supportNodeId]._setForce(0, 0);
|
137
135
|
}
|
138
136
|
}
|
139
137
|
}
|
@@ -156,7 +154,7 @@ var physicsMixin = {
|
|
156
154
|
*
|
157
155
|
* @private
|
158
156
|
*/
|
159
|
-
_calculateGravitationalForces
|
157
|
+
_calculateGravitationalForces: function () {
|
160
158
|
var dx, dy, distance, node, i;
|
161
159
|
var nodes = this.calculationNodes;
|
162
160
|
var gravity = this.constants.physics.centralGravity;
|
@@ -169,9 +167,9 @@ var physicsMixin = {
|
|
169
167
|
if (this._sector() == "default" && gravity != 0) {
|
170
168
|
dx = -node.x;
|
171
169
|
dy = -node.y;
|
172
|
-
distance = Math.sqrt(dx*dx + dy*dy);
|
173
|
-
gravityForce = gravity / distance;
|
170
|
+
distance = Math.sqrt(dx * dx + dy * dy);
|
174
171
|
|
172
|
+
gravityForce = (distance == 0) ? 0 : (gravity / distance);
|
175
173
|
node.fx = dx * gravityForce;
|
176
174
|
node.fy = dy * gravityForce;
|
177
175
|
}
|
@@ -188,7 +186,7 @@ var physicsMixin = {
|
|
188
186
|
*
|
189
187
|
* @private
|
190
188
|
*/
|
191
|
-
_calculateSpringForces
|
189
|
+
_calculateSpringForces: function () {
|
192
190
|
var edgeLength, edge, edgeId;
|
193
191
|
var dx, dy, fx, fy, springForce, length;
|
194
192
|
var edges = this.edges;
|
@@ -206,7 +204,7 @@ var physicsMixin = {
|
|
206
204
|
|
207
205
|
dx = (edge.from.x - edge.to.x);
|
208
206
|
dy = (edge.from.y - edge.to.y);
|
209
|
-
length =
|
207
|
+
length = Math.sqrt(dx * dx + dy * dy);
|
210
208
|
|
211
209
|
if (length == 0) {
|
212
210
|
length = 0.01;
|
@@ -233,7 +231,7 @@ var physicsMixin = {
|
|
233
231
|
*
|
234
232
|
* @private
|
235
233
|
*/
|
236
|
-
_calculateSpringForcesWithSupport
|
234
|
+
_calculateSpringForcesWithSupport: function () {
|
237
235
|
var edgeLength, edge, edgeId, combinedClusterSize;
|
238
236
|
var edges = this.edges;
|
239
237
|
|
@@ -255,8 +253,8 @@ var physicsMixin = {
|
|
255
253
|
|
256
254
|
// this implies that the edges between big clusters are longer
|
257
255
|
edgeLength += combinedClusterSize * this.constants.clustering.edgeGrowth;
|
258
|
-
this._calculateSpringForce(node1,node2,0.5*edgeLength);
|
259
|
-
this._calculateSpringForce(node2,node3,0.5*edgeLength);
|
256
|
+
this._calculateSpringForce(node1, node2, 0.5 * edgeLength);
|
257
|
+
this._calculateSpringForce(node2, node3, 0.5 * edgeLength);
|
260
258
|
}
|
261
259
|
}
|
262
260
|
}
|
@@ -273,19 +271,19 @@ var physicsMixin = {
|
|
273
271
|
* @param edgeLength
|
274
272
|
* @private
|
275
273
|
*/
|
276
|
-
_calculateSpringForce
|
274
|
+
_calculateSpringForce: function (node1, node2, edgeLength) {
|
277
275
|
var dx, dy, fx, fy, springForce, length;
|
278
276
|
|
279
277
|
dx = (node1.x - node2.x);
|
280
278
|
dy = (node1.y - node2.y);
|
281
|
-
length =
|
282
|
-
|
283
|
-
springForce = this.constants.physics.springConstant * (edgeLength - length) / length;
|
279
|
+
length = Math.sqrt(dx * dx + dy * dy);
|
284
280
|
|
285
281
|
if (length == 0) {
|
286
282
|
length = 0.01;
|
287
283
|
}
|
288
284
|
|
285
|
+
springForce = this.constants.physics.springConstant * (edgeLength - length) / length;
|
286
|
+
|
289
287
|
fx = dx * springForce;
|
290
288
|
fy = dy * springForce;
|
291
289
|
|
@@ -300,131 +298,141 @@ var physicsMixin = {
|
|
300
298
|
* Load the HTML for the physics config and bind it
|
301
299
|
* @private
|
302
300
|
*/
|
303
|
-
_loadPhysicsConfiguration
|
301
|
+
_loadPhysicsConfiguration: function () {
|
304
302
|
if (this.physicsConfiguration === undefined) {
|
305
|
-
|
303
|
+
this.backupConstants = {};
|
304
|
+
util.copyObject(this.constants, this.backupConstants);
|
305
|
+
|
306
|
+
var hierarchicalLayoutDirections = ["LR", "RL", "UD", "DU"];
|
306
307
|
this.physicsConfiguration = document.createElement('div');
|
307
308
|
this.physicsConfiguration.className = "PhysicsConfiguration";
|
308
309
|
this.physicsConfiguration.innerHTML = '' +
|
309
310
|
'<table><tr><td><b>Simulation Mode:</b></td></tr>' +
|
310
311
|
'<tr>' +
|
311
312
|
'<td width="120px"><input type="radio" name="graph_physicsMethod" id="graph_physicsMethod1" value="BH" checked="checked">Barnes Hut</td>' +
|
312
|
-
'<td width="120px"><input type="radio" name="graph_physicsMethod" id="graph_physicsMethod2" value="R">Repulsion</td>'+
|
313
|
+
'<td width="120px"><input type="radio" name="graph_physicsMethod" id="graph_physicsMethod2" value="R">Repulsion</td>' +
|
313
314
|
'<td width="120px"><input type="radio" name="graph_physicsMethod" id="graph_physicsMethod3" value="H">Hierarchical</td>' +
|
314
|
-
'</tr>'+
|
315
|
+
'</tr>' +
|
316
|
+
'</table>' +
|
317
|
+
'<table id="graph_BH_table" style="display:none">' +
|
318
|
+
'<tr><td><b>Barnes Hut</b></td></tr>' +
|
319
|
+
'<tr>' +
|
320
|
+
'<td width="150px">gravitationalConstant</td><td>0</td><td><input type="range" min="500" max="20000" value="' + (-1 * this.constants.physics.barnesHut.gravitationalConstant) + '" step="25" style="width:300px" id="graph_BH_gc"></td><td width="50px">-20000</td><td><input value="' + (-1 * this.constants.physics.barnesHut.gravitationalConstant) + '" id="graph_BH_gc_value" style="width:60px"></td>' +
|
321
|
+
'</tr>' +
|
322
|
+
'<tr>' +
|
323
|
+
'<td width="150px">centralGravity</td><td>0</td><td><input type="range" min="0" max="3" value="' + this.constants.physics.barnesHut.centralGravity + '" step="0.05" style="width:300px" id="graph_BH_cg"></td><td>3</td><td><input value="' + this.constants.physics.barnesHut.centralGravity + '" id="graph_BH_cg_value" style="width:60px"></td>' +
|
324
|
+
'</tr>' +
|
325
|
+
'<tr>' +
|
326
|
+
'<td width="150px">springLength</td><td>0</td><td><input type="range" min="0" max="500" value="' + this.constants.physics.barnesHut.springLength + '" step="1" style="width:300px" id="graph_BH_sl"></td><td>500</td><td><input value="' + this.constants.physics.barnesHut.springLength + '" id="graph_BH_sl_value" style="width:60px"></td>' +
|
327
|
+
'</tr>' +
|
328
|
+
'<tr>' +
|
329
|
+
'<td width="150px">springConstant</td><td>0</td><td><input type="range" min="0" max="0.5" value="' + this.constants.physics.barnesHut.springConstant + '" step="0.001" style="width:300px" id="graph_BH_sc"></td><td>0.5</td><td><input value="' + this.constants.physics.barnesHut.springConstant + '" id="graph_BH_sc_value" style="width:60px"></td>' +
|
330
|
+
'</tr>' +
|
331
|
+
'<tr>' +
|
332
|
+
'<td width="150px">damping</td><td>0</td><td><input type="range" min="0" max="0.3" value="' + this.constants.physics.barnesHut.damping + '" step="0.005" style="width:300px" id="graph_BH_damp"></td><td>0.3</td><td><input value="' + this.constants.physics.barnesHut.damping + '" id="graph_BH_damp_value" style="width:60px"></td>' +
|
333
|
+
'</tr>' +
|
334
|
+
'</table>' +
|
335
|
+
'<table id="graph_R_table" style="display:none">' +
|
336
|
+
'<tr><td><b>Repulsion</b></td></tr>' +
|
337
|
+
'<tr>' +
|
338
|
+
'<td width="150px">nodeDistance</td><td>0</td><td><input type="range" min="0" max="300" value="' + this.constants.physics.repulsion.nodeDistance + '" step="1" style="width:300px" id="graph_R_nd"></td><td width="50px">300</td><td><input value="' + this.constants.physics.repulsion.nodeDistance + '" id="graph_R_nd_value" style="width:60px"></td>' +
|
339
|
+
'</tr>' +
|
340
|
+
'<tr>' +
|
341
|
+
'<td width="150px">centralGravity</td><td>0</td><td><input type="range" min="0" max="3" value="' + this.constants.physics.repulsion.centralGravity + '" step="0.05" style="width:300px" id="graph_R_cg"></td><td>3</td><td><input value="' + this.constants.physics.repulsion.centralGravity + '" id="graph_R_cg_value" style="width:60px"></td>' +
|
342
|
+
'</tr>' +
|
343
|
+
'<tr>' +
|
344
|
+
'<td width="150px">springLength</td><td>0</td><td><input type="range" min="0" max="500" value="' + this.constants.physics.repulsion.springLength + '" step="1" style="width:300px" id="graph_R_sl"></td><td>500</td><td><input value="' + this.constants.physics.repulsion.springLength + '" id="graph_R_sl_value" style="width:60px"></td>' +
|
345
|
+
'</tr>' +
|
346
|
+
'<tr>' +
|
347
|
+
'<td width="150px">springConstant</td><td>0</td><td><input type="range" min="0" max="0.5" value="' + this.constants.physics.repulsion.springConstant + '" step="0.001" style="width:300px" id="graph_R_sc"></td><td>0.5</td><td><input value="' + this.constants.physics.repulsion.springConstant + '" id="graph_R_sc_value" style="width:60px"></td>' +
|
348
|
+
'</tr>' +
|
349
|
+
'<tr>' +
|
350
|
+
'<td width="150px">damping</td><td>0</td><td><input type="range" min="0" max="0.3" value="' + this.constants.physics.repulsion.damping + '" step="0.005" style="width:300px" id="graph_R_damp"></td><td>0.3</td><td><input value="' + this.constants.physics.repulsion.damping + '" id="graph_R_damp_value" style="width:60px"></td>' +
|
351
|
+
'</tr>' +
|
352
|
+
'</table>' +
|
353
|
+
'<table id="graph_H_table" style="display:none">' +
|
354
|
+
'<tr><td width="150"><b>Hierarchical</b></td></tr>' +
|
355
|
+
'<tr>' +
|
356
|
+
'<td width="150px">nodeDistance</td><td>0</td><td><input type="range" min="0" max="300" value="' + this.constants.physics.hierarchicalRepulsion.nodeDistance + '" step="1" style="width:300px" id="graph_H_nd"></td><td width="50px">300</td><td><input value="' + this.constants.physics.hierarchicalRepulsion.nodeDistance + '" id="graph_H_nd_value" style="width:60px"></td>' +
|
357
|
+
'</tr>' +
|
358
|
+
'<tr>' +
|
359
|
+
'<td width="150px">centralGravity</td><td>0</td><td><input type="range" min="0" max="3" value="' + this.constants.physics.hierarchicalRepulsion.centralGravity + '" step="0.05" style="width:300px" id="graph_H_cg"></td><td>3</td><td><input value="' + this.constants.physics.hierarchicalRepulsion.centralGravity + '" id="graph_H_cg_value" style="width:60px"></td>' +
|
360
|
+
'</tr>' +
|
361
|
+
'<tr>' +
|
362
|
+
'<td width="150px">springLength</td><td>0</td><td><input type="range" min="0" max="500" value="' + this.constants.physics.hierarchicalRepulsion.springLength + '" step="1" style="width:300px" id="graph_H_sl"></td><td>500</td><td><input value="' + this.constants.physics.hierarchicalRepulsion.springLength + '" id="graph_H_sl_value" style="width:60px"></td>' +
|
363
|
+
'</tr>' +
|
364
|
+
'<tr>' +
|
365
|
+
'<td width="150px">springConstant</td><td>0</td><td><input type="range" min="0" max="0.5" value="' + this.constants.physics.hierarchicalRepulsion.springConstant + '" step="0.001" style="width:300px" id="graph_H_sc"></td><td>0.5</td><td><input value="' + this.constants.physics.hierarchicalRepulsion.springConstant + '" id="graph_H_sc_value" style="width:60px"></td>' +
|
366
|
+
'</tr>' +
|
367
|
+
'<tr>' +
|
368
|
+
'<td width="150px">damping</td><td>0</td><td><input type="range" min="0" max="0.3" value="' + this.constants.physics.hierarchicalRepulsion.damping + '" step="0.005" style="width:300px" id="graph_H_damp"></td><td>0.3</td><td><input value="' + this.constants.physics.hierarchicalRepulsion.damping + '" id="graph_H_damp_value" style="width:60px"></td>' +
|
369
|
+
'</tr>' +
|
370
|
+
'<tr>' +
|
371
|
+
'<td width="150px">direction</td><td>1</td><td><input type="range" min="0" max="3" value="' + hierarchicalLayoutDirections.indexOf(this.constants.hierarchicalLayout.direction) + '" step="1" style="width:300px" id="graph_H_direction"></td><td>4</td><td><input value="' + this.constants.hierarchicalLayout.direction + '" id="graph_H_direction_value" style="width:60px"></td>' +
|
372
|
+
'</tr>' +
|
373
|
+
'<tr>' +
|
374
|
+
'<td width="150px">levelSeparation</td><td>1</td><td><input type="range" min="0" max="500" value="' + this.constants.hierarchicalLayout.levelSeparation + '" step="1" style="width:300px" id="graph_H_levsep"></td><td>500</td><td><input value="' + this.constants.hierarchicalLayout.levelSeparation + '" id="graph_H_levsep_value" style="width:60px"></td>' +
|
375
|
+
'</tr>' +
|
376
|
+
'<tr>' +
|
377
|
+
'<td width="150px">nodeSpacing</td><td>1</td><td><input type="range" min="0" max="500" value="' + this.constants.hierarchicalLayout.nodeSpacing + '" step="1" style="width:300px" id="graph_H_nspac"></td><td>500</td><td><input value="' + this.constants.hierarchicalLayout.nodeSpacing + '" id="graph_H_nspac_value" style="width:60px"></td>' +
|
378
|
+
'</tr>' +
|
315
379
|
'</table>' +
|
316
|
-
'<table
|
317
|
-
'<tr
|
318
|
-
'<
|
319
|
-
'<td width="
|
320
|
-
'
|
321
|
-
'
|
322
|
-
'<td width="150px">centralGravity</td><td>0</td><td><input type="range" min="0" max="3" value="' + this.constants.physics.barnesHut.centralGravity + '" step="0.05" style="width:300px" id="graph_BH_cg"></td><td>3</td><td><input value="' + this.constants.physics.barnesHut.centralGravity + '" id="graph_BH_cg_value" style="width:60px"></td>'+
|
323
|
-
'</tr>'+
|
324
|
-
'<tr>'+
|
325
|
-
'<td width="150px">springLength</td><td>0</td><td><input type="range" min="0" max="500" value="' + this.constants.physics.barnesHut.springLength + '" step="1" style="width:300px" id="graph_BH_sl"></td><td>500</td><td><input value="' + this.constants.physics.barnesHut.springLength + '" id="graph_BH_sl_value" style="width:60px"></td>'+
|
326
|
-
'</tr>'+
|
327
|
-
'<tr>'+
|
328
|
-
'<td width="150px">springConstant</td><td>0</td><td><input type="range" min="0" max="0.5" value="' + this.constants.physics.barnesHut.springConstant + '" step="0.001" style="width:300px" id="graph_BH_sc"></td><td>0.5</td><td><input value="' + this.constants.physics.barnesHut.springConstant + '" id="graph_BH_sc_value" style="width:60px"></td>'+
|
329
|
-
'</tr>'+
|
330
|
-
'<tr>'+
|
331
|
-
'<td width="150px">damping</td><td>0</td><td><input type="range" min="0" max="0.3" value="' + this.constants.physics.barnesHut.damping + '" step="0.005" style="width:300px" id="graph_BH_damp"></td><td>0.3</td><td><input value="' + this.constants.physics.barnesHut.damping + '" id="graph_BH_damp_value" style="width:60px"></td>'+
|
332
|
-
'</tr>'+
|
333
|
-
'</table>'+
|
334
|
-
'<table id="graph_R_table" style="display:none">'+
|
335
|
-
'<tr><td><b>Repulsion</b></td></tr>'+
|
336
|
-
'<tr>'+
|
337
|
-
'<td width="150px">nodeDistance</td><td>0</td><td><input type="range" min="0" max="300" value="' + this.constants.physics.repulsion.nodeDistance + '" step="1" style="width:300px" id="graph_R_nd"></td><td width="50px">300</td><td><input value="' + this.constants.physics.repulsion.nodeDistance + '" id="graph_R_nd_value" style="width:60px"></td>'+
|
338
|
-
'</tr>'+
|
339
|
-
'<tr>'+
|
340
|
-
'<td width="150px">centralGravity</td><td>0</td><td><input type="range" min="0" max="3" value="' + this.constants.physics.repulsion.centralGravity + '" step="0.05" style="width:300px" id="graph_R_cg"></td><td>3</td><td><input value="' + this.constants.physics.repulsion.centralGravity + '" id="graph_R_cg_value" style="width:60px"></td>'+
|
341
|
-
'</tr>'+
|
342
|
-
'<tr>'+
|
343
|
-
'<td width="150px">springLength</td><td>0</td><td><input type="range" min="0" max="500" value="' + this.constants.physics.repulsion.springLength + '" step="1" style="width:300px" id="graph_R_sl"></td><td>500</td><td><input value="' + this.constants.physics.repulsion.springLength + '" id="graph_R_sl_value" style="width:60px"></td>'+
|
344
|
-
'</tr>'+
|
345
|
-
'<tr>'+
|
346
|
-
'<td width="150px">springConstant</td><td>0</td><td><input type="range" min="0" max="0.5" value="' + this.constants.physics.repulsion.springConstant + '" step="0.001" style="width:300px" id="graph_R_sc"></td><td>0.5</td><td><input value="' + this.constants.physics.repulsion.springConstant + '" id="graph_R_sc_value" style="width:60px"></td>'+
|
347
|
-
'</tr>'+
|
348
|
-
'<tr>'+
|
349
|
-
'<td width="150px">damping</td><td>0</td><td><input type="range" min="0" max="0.3" value="' + this.constants.physics.repulsion.damping + '" step="0.005" style="width:300px" id="graph_R_damp"></td><td>0.3</td><td><input value="' + this.constants.physics.repulsion.damping + '" id="graph_R_damp_value" style="width:60px"></td>'+
|
350
|
-
'</tr>'+
|
351
|
-
'</table>'+
|
352
|
-
'<table id="graph_H_table" style="display:none">'+
|
353
|
-
'<tr><td width="150"><b>Hierarchical</b></td></tr>'+
|
354
|
-
'<tr>'+
|
355
|
-
'<td width="150px">nodeDistance</td><td>0</td><td><input type="range" min="0" max="300" value="' + this.constants.physics.hierarchicalRepulsion.nodeDistance + '" step="1" style="width:300px" id="graph_H_nd"></td><td width="50px">300</td><td><input value="' + this.constants.physics.hierarchicalRepulsion.nodeDistance + '" id="graph_H_nd_value" style="width:60px"></td>'+
|
356
|
-
'</tr>'+
|
357
|
-
'<tr>'+
|
358
|
-
'<td width="150px">centralGravity</td><td>0</td><td><input type="range" min="0" max="3" value="' + this.constants.physics.hierarchicalRepulsion.centralGravity + '" step="0.05" style="width:300px" id="graph_H_cg"></td><td>3</td><td><input value="' + this.constants.physics.hierarchicalRepulsion.centralGravity + '" id="graph_H_cg_value" style="width:60px"></td>'+
|
359
|
-
'</tr>'+
|
360
|
-
'<tr>'+
|
361
|
-
'<td width="150px">springLength</td><td>0</td><td><input type="range" min="0" max="500" value="' + this.constants.physics.hierarchicalRepulsion.springLength + '" step="1" style="width:300px" id="graph_H_sl"></td><td>500</td><td><input value="' + this.constants.physics.hierarchicalRepulsion.springLength + '" id="graph_H_sl_value" style="width:60px"></td>'+
|
362
|
-
'</tr>'+
|
363
|
-
'<tr>'+
|
364
|
-
'<td width="150px">springConstant</td><td>0</td><td><input type="range" min="0" max="0.5" value="' + this.constants.physics.hierarchicalRepulsion.springConstant + '" step="0.001" style="width:300px" id="graph_H_sc"></td><td>0.5</td><td><input value="' + this.constants.physics.hierarchicalRepulsion.springConstant + '" id="graph_H_sc_value" style="width:60px"></td>'+
|
365
|
-
'</tr>'+
|
366
|
-
'<tr>'+
|
367
|
-
'<td width="150px">damping</td><td>0</td><td><input type="range" min="0" max="0.3" value="' + this.constants.physics.hierarchicalRepulsion.damping + '" step="0.005" style="width:300px" id="graph_H_damp"></td><td>0.3</td><td><input value="' + this.constants.physics.hierarchicalRepulsion.damping + '" id="graph_H_damp_value" style="width:60px"></td>'+
|
368
|
-
'</tr>'+
|
369
|
-
'<tr>'+
|
370
|
-
'<td width="150px">direction</td><td>1</td><td><input type="range" min="0" max="3" value="' + hierarchicalLayoutDirections.indexOf(this.constants.hierarchicalLayout.direction) + '" step="1" style="width:300px" id="graph_H_direction"></td><td>4</td><td><input value="' + this.constants.hierarchicalLayout.direction + '" id="graph_H_direction_value" style="width:60px"></td>'+
|
371
|
-
'</tr>'+
|
372
|
-
'<tr>'+
|
373
|
-
'<td width="150px">levelSeparation</td><td>1</td><td><input type="range" min="0" max="' + this.constants.hierarchicalLayout.levelSeparation + '" value="150" step="1" style="width:300px" id="graph_H_levsep"></td><td>500</td><td><input value="' + this.constants.hierarchicalLayout.levelSeparation + '" id="graph_H_levsep_value" style="width:60px"></td>'+
|
374
|
-
'</tr>'+
|
375
|
-
'<tr>'+
|
376
|
-
'<td width="150px">nodeSpacing</td><td>1</td><td><input type="range" min="0" max="' + this.constants.hierarchicalLayout.nodeSpacing + '" value="100" step="1" style="width:300px" id="graph_H_nspac"></td><td>500</td><td><input value="' + this.constants.hierarchicalLayout.nodeSpacing + '" id="graph_H_nspac_value" style="width:60px"></td>'+
|
377
|
-
'</tr>'+
|
380
|
+
'<table><tr><td><b>Options:</b></td></tr>' +
|
381
|
+
'<tr>' +
|
382
|
+
'<td width="180px"><input type="button" id="graph_toggleSmooth" value="Toggle smoothCurves" style="width:150px"></td>' +
|
383
|
+
'<td width="180px"><input type="button" id="graph_repositionNodes" value="Reinitialize" style="width:150px"></td>' +
|
384
|
+
'<td width="180px"><input type="button" id="graph_generateOptions" value="Generate Options" style="width:150px"></td>' +
|
385
|
+
'</tr>' +
|
378
386
|
'</table>'
|
379
|
-
this.containerElement.parentElement.insertBefore(this.physicsConfiguration,this.containerElement);
|
380
|
-
|
381
|
-
|
387
|
+
this.containerElement.parentElement.insertBefore(this.physicsConfiguration, this.containerElement);
|
388
|
+
this.optionsDiv = document.createElement("div");
|
389
|
+
this.optionsDiv.style.fontSize = "14px";
|
390
|
+
this.optionsDiv.style.fontFamily = "verdana";
|
391
|
+
this.containerElement.parentElement.insertBefore(this.optionsDiv, this.containerElement);
|
382
392
|
|
383
393
|
var rangeElement;
|
384
394
|
rangeElement = document.getElementById('graph_BH_gc');
|
385
|
-
rangeElement.onchange = showValueOfRange.bind(this,'graph_BH_gc'
|
395
|
+
rangeElement.onchange = showValueOfRange.bind(this, 'graph_BH_gc', -1, "physics_barnesHut_gravitationalConstant");
|
386
396
|
rangeElement = document.getElementById('graph_BH_cg');
|
387
|
-
rangeElement.onchange = showValueOfRange.bind(this,'graph_BH_cg',1,"physics_centralGravity");
|
397
|
+
rangeElement.onchange = showValueOfRange.bind(this, 'graph_BH_cg', 1, "physics_centralGravity");
|
388
398
|
rangeElement = document.getElementById('graph_BH_sc');
|
389
|
-
rangeElement.onchange = showValueOfRange.bind(this,'graph_BH_sc',1,"physics_springConstant");
|
399
|
+
rangeElement.onchange = showValueOfRange.bind(this, 'graph_BH_sc', 1, "physics_springConstant");
|
390
400
|
rangeElement = document.getElementById('graph_BH_sl');
|
391
|
-
rangeElement.onchange = showValueOfRange.bind(this,'graph_BH_sl',1,"physics_springLength");
|
401
|
+
rangeElement.onchange = showValueOfRange.bind(this, 'graph_BH_sl', 1, "physics_springLength");
|
392
402
|
rangeElement = document.getElementById('graph_BH_damp');
|
393
|
-
rangeElement.onchange = showValueOfRange.bind(this,'graph_BH_damp',1,"physics_damping");
|
394
|
-
|
403
|
+
rangeElement.onchange = showValueOfRange.bind(this, 'graph_BH_damp', 1, "physics_damping");
|
395
404
|
|
396
405
|
rangeElement = document.getElementById('graph_R_nd');
|
397
|
-
rangeElement.onchange = showValueOfRange.bind(this,'graph_R_nd',1,"physics_repulsion_nodeDistance");
|
406
|
+
rangeElement.onchange = showValueOfRange.bind(this, 'graph_R_nd', 1, "physics_repulsion_nodeDistance");
|
398
407
|
rangeElement = document.getElementById('graph_R_cg');
|
399
|
-
rangeElement.onchange = showValueOfRange.bind(this,'graph_R_cg',1,"physics_centralGravity");
|
408
|
+
rangeElement.onchange = showValueOfRange.bind(this, 'graph_R_cg', 1, "physics_centralGravity");
|
400
409
|
rangeElement = document.getElementById('graph_R_sc');
|
401
|
-
rangeElement.onchange = showValueOfRange.bind(this,'graph_R_sc',1,"physics_springConstant");
|
410
|
+
rangeElement.onchange = showValueOfRange.bind(this, 'graph_R_sc', 1, "physics_springConstant");
|
402
411
|
rangeElement = document.getElementById('graph_R_sl');
|
403
|
-
rangeElement.onchange = showValueOfRange.bind(this,'graph_R_sl',1,"physics_springLength");
|
412
|
+
rangeElement.onchange = showValueOfRange.bind(this, 'graph_R_sl', 1, "physics_springLength");
|
404
413
|
rangeElement = document.getElementById('graph_R_damp');
|
405
|
-
rangeElement.onchange = showValueOfRange.bind(this,'graph_R_damp',1,"physics_damping");
|
414
|
+
rangeElement.onchange = showValueOfRange.bind(this, 'graph_R_damp', 1, "physics_damping");
|
406
415
|
|
407
416
|
rangeElement = document.getElementById('graph_H_nd');
|
408
|
-
rangeElement.onchange = showValueOfRange.bind(this,'graph_H_nd',1,"physics_hierarchicalRepulsion_nodeDistance");
|
417
|
+
rangeElement.onchange = showValueOfRange.bind(this, 'graph_H_nd', 1, "physics_hierarchicalRepulsion_nodeDistance");
|
409
418
|
rangeElement = document.getElementById('graph_H_cg');
|
410
|
-
rangeElement.onchange = showValueOfRange.bind(this,'graph_H_cg',1,"physics_centralGravity");
|
419
|
+
rangeElement.onchange = showValueOfRange.bind(this, 'graph_H_cg', 1, "physics_centralGravity");
|
411
420
|
rangeElement = document.getElementById('graph_H_sc');
|
412
|
-
rangeElement.onchange = showValueOfRange.bind(this,'graph_H_sc',1,"physics_springConstant");
|
421
|
+
rangeElement.onchange = showValueOfRange.bind(this, 'graph_H_sc', 1, "physics_springConstant");
|
413
422
|
rangeElement = document.getElementById('graph_H_sl');
|
414
|
-
rangeElement.onchange = showValueOfRange.bind(this,'graph_H_sl',1,"physics_springLength");
|
423
|
+
rangeElement.onchange = showValueOfRange.bind(this, 'graph_H_sl', 1, "physics_springLength");
|
415
424
|
rangeElement = document.getElementById('graph_H_damp');
|
416
|
-
rangeElement.onchange = showValueOfRange.bind(this,'graph_H_damp',1,"physics_damping");
|
425
|
+
rangeElement.onchange = showValueOfRange.bind(this, 'graph_H_damp', 1, "physics_damping");
|
417
426
|
rangeElement = document.getElementById('graph_H_direction');
|
418
|
-
rangeElement.onchange = showValueOfRange.bind(this,'graph_H_direction',hierarchicalLayoutDirections,"hierarchicalLayout_direction");
|
427
|
+
rangeElement.onchange = showValueOfRange.bind(this, 'graph_H_direction', hierarchicalLayoutDirections, "hierarchicalLayout_direction");
|
419
428
|
rangeElement = document.getElementById('graph_H_levsep');
|
420
|
-
rangeElement.onchange = showValueOfRange.bind(this,'graph_H_levsep',1,"hierarchicalLayout_levelSeparation");
|
429
|
+
rangeElement.onchange = showValueOfRange.bind(this, 'graph_H_levsep', 1, "hierarchicalLayout_levelSeparation");
|
421
430
|
rangeElement = document.getElementById('graph_H_nspac');
|
422
|
-
rangeElement.onchange = showValueOfRange.bind(this,'graph_H_nspac',1,"hierarchicalLayout_nodeSpacing");
|
431
|
+
rangeElement.onchange = showValueOfRange.bind(this, 'graph_H_nspac', 1, "hierarchicalLayout_nodeSpacing");
|
423
432
|
|
424
433
|
var radioButton1 = document.getElementById("graph_physicsMethod1");
|
425
434
|
var radioButton2 = document.getElementById("graph_physicsMethod2");
|
426
435
|
var radioButton3 = document.getElementById("graph_physicsMethod3");
|
427
|
-
|
428
436
|
radioButton2.checked = true;
|
429
437
|
if (this.constants.physics.barnesHut.enabled) {
|
430
438
|
radioButton1.checked = true;
|
@@ -433,6 +441,21 @@ var physicsMixin = {
|
|
433
441
|
radioButton3.checked = true;
|
434
442
|
}
|
435
443
|
|
444
|
+
var graph_toggleSmooth = document.getElementById("graph_toggleSmooth");
|
445
|
+
var graph_repositionNodes = document.getElementById("graph_repositionNodes");
|
446
|
+
var graph_generateOptions = document.getElementById("graph_generateOptions");
|
447
|
+
|
448
|
+
graph_toggleSmooth.onclick = graphToggleSmoothCurves.bind(this);
|
449
|
+
graph_repositionNodes.onclick = graphRepositionNodes.bind(this);
|
450
|
+
graph_generateOptions.onclick = graphGenerateOptions.bind(this);
|
451
|
+
if (this.constants.smoothCurves == true) {
|
452
|
+
graph_toggleSmooth.style.background = "#A4FF56";
|
453
|
+
}
|
454
|
+
else {
|
455
|
+
graph_toggleSmooth.style.background = "#FF8532";
|
456
|
+
}
|
457
|
+
|
458
|
+
|
436
459
|
switchConfigurations.apply(this);
|
437
460
|
|
438
461
|
radioButton1.onchange = switchConfigurations.bind(this);
|
@@ -441,7 +464,14 @@ var physicsMixin = {
|
|
441
464
|
}
|
442
465
|
},
|
443
466
|
|
444
|
-
|
467
|
+
/**
|
468
|
+
* This overwrites the this.constants.
|
469
|
+
*
|
470
|
+
* @param constantsVariableName
|
471
|
+
* @param value
|
472
|
+
* @private
|
473
|
+
*/
|
474
|
+
_overWriteGraphConstants: function (constantsVariableName, value) {
|
445
475
|
var nameArray = constantsVariableName.split("_");
|
446
476
|
if (nameArray.length == 1) {
|
447
477
|
this.constants[nameArray[0]] = value;
|
@@ -453,11 +483,147 @@ var physicsMixin = {
|
|
453
483
|
this.constants[nameArray[0]][nameArray[1]][nameArray[2]] = value;
|
454
484
|
}
|
455
485
|
}
|
456
|
-
}
|
486
|
+
};
|
457
487
|
|
488
|
+
/**
|
489
|
+
* this function is bound to the toggle smooth curves button. That is also why it is not in the prototype.
|
490
|
+
*/
|
491
|
+
function graphToggleSmoothCurves () {
|
492
|
+
this.constants.smoothCurves = !this.constants.smoothCurves;
|
493
|
+
var graph_toggleSmooth = document.getElementById("graph_toggleSmooth");
|
494
|
+
if (this.constants.smoothCurves == true) {graph_toggleSmooth.style.background = "#A4FF56";}
|
495
|
+
else {graph_toggleSmooth.style.background = "#FF8532";}
|
496
|
+
|
497
|
+
this._configureSmoothCurves(false);
|
498
|
+
};
|
458
499
|
|
500
|
+
/**
|
501
|
+
* this function is used to scramble the nodes
|
502
|
+
*
|
503
|
+
*/
|
504
|
+
function graphRepositionNodes () {
|
505
|
+
for (var nodeId in this.calculationNodes) {
|
506
|
+
if (this.calculationNodes.hasOwnProperty(nodeId)) {
|
507
|
+
this.calculationNodes[nodeId].vx = 0; this.calculationNodes[nodeId].vy = 0;
|
508
|
+
this.calculationNodes[nodeId].fx = 0; this.calculationNodes[nodeId].fy = 0;
|
509
|
+
}
|
510
|
+
}
|
511
|
+
if (this.constants.hierarchicalLayout.enabled == true) {
|
512
|
+
this._setupHierarchicalLayout();
|
513
|
+
}
|
514
|
+
else {
|
515
|
+
this.repositionNodes();
|
516
|
+
}
|
517
|
+
this.moving = true;
|
518
|
+
this.start();
|
519
|
+
};
|
520
|
+
|
521
|
+
/**
|
522
|
+
* this is used to generate an options file from the playing with physics system.
|
523
|
+
*/
|
524
|
+
function graphGenerateOptions () {
|
525
|
+
var options = "No options are required, default values used.";
|
526
|
+
var optionsSpecific = [];
|
527
|
+
var radioButton1 = document.getElementById("graph_physicsMethod1");
|
528
|
+
var radioButton2 = document.getElementById("graph_physicsMethod2");
|
529
|
+
if (radioButton1.checked == true) {
|
530
|
+
if (this.constants.physics.barnesHut.gravitationalConstant != this.backupConstants.physics.barnesHut.gravitationalConstant) {optionsSpecific.push("gravitationalConstant: " + this.constants.physics.barnesHut.gravitationalConstant);}
|
531
|
+
if (this.constants.physics.centralGravity != this.backupConstants.physics.barnesHut.centralGravity) {optionsSpecific.push("centralGravity: " + this.constants.physics.centralGravity);}
|
532
|
+
if (this.constants.physics.springLength != this.backupConstants.physics.barnesHut.springLength) {optionsSpecific.push("springLength: " + this.constants.physics.springLength);}
|
533
|
+
if (this.constants.physics.springConstant != this.backupConstants.physics.barnesHut.springConstant) {optionsSpecific.push("springConstant: " + this.constants.physics.springConstant);}
|
534
|
+
if (this.constants.physics.damping != this.backupConstants.physics.barnesHut.damping) {optionsSpecific.push("damping: " + this.constants.physics.damping);}
|
535
|
+
if (optionsSpecific.length != 0) {
|
536
|
+
options = "var options = {";
|
537
|
+
options += "physics: {barnesHut: {";
|
538
|
+
for (var i = 0; i < optionsSpecific.length; i++) {
|
539
|
+
options += optionsSpecific[i];
|
540
|
+
if (i < optionsSpecific.length - 1) {
|
541
|
+
options += ", "
|
542
|
+
}
|
543
|
+
}
|
544
|
+
options += '}}'
|
545
|
+
}
|
546
|
+
if (this.constants.smoothCurves != this.backupConstants.smoothCurves) {
|
547
|
+
if (optionsSpecific.length == 0) {options = "var options = {";}
|
548
|
+
else {options += ", "}
|
549
|
+
options += "smoothCurves: " + this.constants.smoothCurves;
|
550
|
+
}
|
551
|
+
if (options != "No options are required, default values used.") {
|
552
|
+
options += '};'
|
553
|
+
}
|
554
|
+
}
|
555
|
+
else if (radioButton2.checked == true) {
|
556
|
+
options = "var options = {";
|
557
|
+
options += "physics: {barnesHut: {enabled: false}";
|
558
|
+
if (this.constants.physics.repulsion.nodeDistance != this.backupConstants.physics.repulsion.nodeDistance) {optionsSpecific.push("nodeDistance: " + this.constants.physics.repulsion.nodeDistance);}
|
559
|
+
if (this.constants.physics.centralGravity != this.backupConstants.physics.repulsion.centralGravity) {optionsSpecific.push("centralGravity: " + this.constants.physics.centralGravity);}
|
560
|
+
if (this.constants.physics.springLength != this.backupConstants.physics.repulsion.springLength) {optionsSpecific.push("springLength: " + this.constants.physics.springLength);}
|
561
|
+
if (this.constants.physics.springConstant != this.backupConstants.physics.repulsion.springConstant) {optionsSpecific.push("springConstant: " + this.constants.physics.springConstant);}
|
562
|
+
if (this.constants.physics.damping != this.backupConstants.physics.repulsion.damping) {optionsSpecific.push("damping: " + this.constants.physics.damping);}
|
563
|
+
if (optionsSpecific.length != 0) {
|
564
|
+
options += ", repulsion: {";
|
565
|
+
for (var i = 0; i < optionsSpecific.length; i++) {
|
566
|
+
options += optionsSpecific[i];
|
567
|
+
if (i < optionsSpecific.length - 1) {
|
568
|
+
options += ", "
|
569
|
+
}
|
570
|
+
}
|
571
|
+
options += '}}'
|
572
|
+
}
|
573
|
+
if (optionsSpecific.length == 0) {options += "}"}
|
574
|
+
if (this.constants.smoothCurves != this.backupConstants.smoothCurves) {
|
575
|
+
options += ", smoothCurves: " + this.constants.smoothCurves;
|
576
|
+
}
|
577
|
+
options += '};'
|
578
|
+
}
|
579
|
+
else {
|
580
|
+
options = "var options = {";
|
581
|
+
if (this.constants.physics.hierarchicalRepulsion.nodeDistance != this.backupConstants.physics.hierarchicalRepulsion.nodeDistance) {optionsSpecific.push("nodeDistance: " + this.constants.physics.hierarchicalRepulsion.nodeDistance);}
|
582
|
+
if (this.constants.physics.centralGravity != this.backupConstants.physics.hierarchicalRepulsion.centralGravity) {optionsSpecific.push("centralGravity: " + this.constants.physics.centralGravity);}
|
583
|
+
if (this.constants.physics.springLength != this.backupConstants.physics.hierarchicalRepulsion.springLength) {optionsSpecific.push("springLength: " + this.constants.physics.springLength);}
|
584
|
+
if (this.constants.physics.springConstant != this.backupConstants.physics.hierarchicalRepulsion.springConstant) {optionsSpecific.push("springConstant: " + this.constants.physics.springConstant);}
|
585
|
+
if (this.constants.physics.damping != this.backupConstants.physics.hierarchicalRepulsion.damping) {optionsSpecific.push("damping: " + this.constants.physics.damping);}
|
586
|
+
if (optionsSpecific.length != 0) {
|
587
|
+
options += "physics: {hierarchicalRepulsion: {";
|
588
|
+
for (var i = 0; i < optionsSpecific.length; i++) {
|
589
|
+
options += optionsSpecific[i];
|
590
|
+
if (i < optionsSpecific.length - 1) {
|
591
|
+
options += ", ";
|
592
|
+
}
|
593
|
+
}
|
594
|
+
options += '}},';
|
595
|
+
}
|
596
|
+
options += 'hierarchicalLayout: {';
|
597
|
+
optionsSpecific = [];
|
598
|
+
if (this.constants.hierarchicalLayout.direction != this.backupConstants.hierarchicalLayout.direction) {optionsSpecific.push("direction: " + this.constants.hierarchicalLayout.direction);}
|
599
|
+
if (Math.abs(this.constants.hierarchicalLayout.levelSeparation) != this.backupConstants.hierarchicalLayout.levelSeparation) {optionsSpecific.push("levelSeparation: " + this.constants.hierarchicalLayout.levelSeparation);}
|
600
|
+
if (this.constants.hierarchicalLayout.nodeSpacing != this.backupConstants.hierarchicalLayout.nodeSpacing) {optionsSpecific.push("nodeSpacing: " + this.constants.hierarchicalLayout.nodeSpacing);}
|
601
|
+
if (optionsSpecific.length != 0) {
|
602
|
+
for (var i = 0; i < optionsSpecific.length; i++) {
|
603
|
+
options += optionsSpecific[i];
|
604
|
+
if (i < optionsSpecific.length - 1) {
|
605
|
+
options += ", "
|
606
|
+
}
|
607
|
+
}
|
608
|
+
options += '}'
|
609
|
+
}
|
610
|
+
else {
|
611
|
+
options += "enabled:true}";
|
612
|
+
}
|
613
|
+
options += '};'
|
614
|
+
}
|
615
|
+
|
616
|
+
|
617
|
+
this.optionsDiv.innerHTML = options;
|
618
|
+
|
619
|
+
};
|
620
|
+
|
621
|
+
/**
|
622
|
+
* this is used to switch between barnesHut, repulsion and hierarchical.
|
623
|
+
*
|
624
|
+
*/
|
459
625
|
function switchConfigurations () {
|
460
|
-
var ids = ["graph_BH_table","graph_R_table","graph_H_table"]
|
626
|
+
var ids = ["graph_BH_table", "graph_R_table", "graph_H_table"];
|
461
627
|
var radioButton = document.querySelector('input[name="graph_physicsMethod"]:checked').value;
|
462
628
|
var tableId = "graph_" + radioButton + "_table";
|
463
629
|
var table = document.getElementById(tableId);
|
@@ -471,43 +637,57 @@ function switchConfigurations () {
|
|
471
637
|
this._restoreNodes();
|
472
638
|
if (radioButton == "R") {
|
473
639
|
this.constants.hierarchicalLayout.enabled = false;
|
474
|
-
this.constants.physics.hierarchicalRepulsion.
|
640
|
+
this.constants.physics.hierarchicalRepulsion.enabled = false;
|
475
641
|
this.constants.physics.barnesHut.enabled = false;
|
476
642
|
}
|
477
643
|
else if (radioButton == "H") {
|
478
644
|
this.constants.hierarchicalLayout.enabled = true;
|
479
|
-
this.constants.physics.hierarchicalRepulsion.
|
645
|
+
this.constants.physics.hierarchicalRepulsion.enabled = true;
|
480
646
|
this.constants.physics.barnesHut.enabled = false;
|
481
647
|
this._setupHierarchicalLayout();
|
482
648
|
}
|
483
649
|
else {
|
484
650
|
this.constants.hierarchicalLayout.enabled = false;
|
485
|
-
this.constants.physics.hierarchicalRepulsion.
|
651
|
+
this.constants.physics.hierarchicalRepulsion.enabled = false;
|
486
652
|
this.constants.physics.barnesHut.enabled = true;
|
487
653
|
}
|
488
654
|
this._loadSelectedForceSolver();
|
655
|
+
var graph_toggleSmooth = document.getElementById("graph_toggleSmooth");
|
656
|
+
if (this.constants.smoothCurves == true) {graph_toggleSmooth.style.background = "#A4FF56";}
|
657
|
+
else {graph_toggleSmooth.style.background = "#FF8532";}
|
489
658
|
this.moving = true;
|
490
659
|
this.start();
|
660
|
+
|
491
661
|
}
|
492
662
|
|
663
|
+
|
664
|
+
/**
|
665
|
+
* this generates the ranges depending on the iniital values.
|
666
|
+
*
|
667
|
+
* @param id
|
668
|
+
* @param map
|
669
|
+
* @param constantsVariableName
|
670
|
+
*/
|
493
671
|
function showValueOfRange (id,map,constantsVariableName) {
|
494
672
|
var valueId = id + "_value";
|
495
673
|
var rangeValue = document.getElementById(id).value;
|
496
|
-
if (constantsVariableName == "hierarchicalLayout_direction" ||
|
497
|
-
constantsVariableName == "hierarchicalLayout_levelSeparation" ||
|
498
|
-
constantsVariableName == "hierarchicalLayout_nodeSpacing") {
|
499
|
-
this._setupHierarchicalLayout();
|
500
|
-
}
|
501
674
|
|
502
675
|
if (map instanceof Array) {
|
503
676
|
document.getElementById(valueId).value = map[parseInt(rangeValue)];
|
504
677
|
this._overWriteGraphConstants(constantsVariableName,map[parseInt(rangeValue)]);
|
505
678
|
}
|
506
679
|
else {
|
507
|
-
document.getElementById(valueId).value = map * parseFloat(rangeValue);
|
508
|
-
this._overWriteGraphConstants(constantsVariableName,map * parseFloat(rangeValue));
|
680
|
+
document.getElementById(valueId).value = parseInt(map) * parseFloat(rangeValue);
|
681
|
+
this._overWriteGraphConstants(constantsVariableName, parseInt(map) * parseFloat(rangeValue));
|
682
|
+
}
|
683
|
+
|
684
|
+
if (constantsVariableName == "hierarchicalLayout_direction" ||
|
685
|
+
constantsVariableName == "hierarchicalLayout_levelSeparation" ||
|
686
|
+
constantsVariableName == "hierarchicalLayout_nodeSpacing") {
|
687
|
+
this._setupHierarchicalLayout();
|
509
688
|
}
|
510
689
|
this.moving = true;
|
511
690
|
this.start();
|
512
691
|
};
|
513
692
|
|
693
|
+
|