vis-rails 0.0.6 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vis/rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/vis.js +2 -9
  4. data/vendor/assets/vis/DataSet.js +17 -9
  5. data/vendor/assets/vis/graph/Edge.js +49 -24
  6. data/vendor/assets/vis/graph/Graph.js +268 -64
  7. data/vendor/assets/vis/graph/Groups.js +1 -1
  8. data/vendor/assets/vis/graph/Node.js +18 -67
  9. data/vendor/assets/vis/graph/Popup.js +40 -13
  10. data/vendor/assets/vis/graph/css/graph-navigation.css +18 -14
  11. data/vendor/assets/vis/graph/graphMixins/ClusterMixin.js +7 -5
  12. data/vendor/assets/vis/graph/graphMixins/HierarchicalLayoutMixin.js +20 -5
  13. data/vendor/assets/vis/graph/graphMixins/ManipulationMixin.js +33 -33
  14. data/vendor/assets/vis/graph/graphMixins/MixinLoader.js +30 -32
  15. data/vendor/assets/vis/graph/graphMixins/NavigationMixin.js +33 -1
  16. data/vendor/assets/vis/graph/graphMixins/SectorsMixin.js +2 -2
  17. data/vendor/assets/vis/graph/graphMixins/SelectionMixin.js +72 -60
  18. data/vendor/assets/vis/graph/graphMixins/physics/BarnesHut.js +43 -18
  19. data/vendor/assets/vis/graph/graphMixins/physics/HierarchialRepulsion.js +8 -8
  20. data/vendor/assets/vis/graph/graphMixins/physics/PhysicsMixin.js +309 -129
  21. data/vendor/assets/vis/graph/graphMixins/physics/Repulsion.js +10 -10
  22. data/vendor/assets/vis/module/exports.js +1 -2
  23. data/vendor/assets/vis/module/header.js +2 -2
  24. data/vendor/assets/vis/timeline/Range.js +53 -93
  25. data/vendor/assets/vis/timeline/Timeline.js +328 -224
  26. data/vendor/assets/vis/timeline/component/Component.js +17 -95
  27. data/vendor/assets/vis/timeline/component/CurrentTime.js +54 -59
  28. data/vendor/assets/vis/timeline/component/CustomTime.js +55 -83
  29. data/vendor/assets/vis/timeline/component/Group.js +398 -75
  30. data/vendor/assets/vis/timeline/component/ItemSet.js +662 -403
  31. data/vendor/assets/vis/timeline/component/Panel.js +118 -60
  32. data/vendor/assets/vis/timeline/component/RootPanel.js +80 -132
  33. data/vendor/assets/vis/timeline/component/TimeAxis.js +191 -277
  34. data/vendor/assets/vis/timeline/component/css/item.css +16 -23
  35. data/vendor/assets/vis/timeline/component/css/itemset.css +25 -4
  36. data/vendor/assets/vis/timeline/component/css/labelset.css +34 -0
  37. data/vendor/assets/vis/timeline/component/css/panel.css +15 -1
  38. data/vendor/assets/vis/timeline/component/css/timeaxis.css +8 -8
  39. data/vendor/assets/vis/timeline/component/item/Item.js +48 -26
  40. data/vendor/assets/vis/timeline/component/item/ItemBox.js +156 -230
  41. data/vendor/assets/vis/timeline/component/item/ItemPoint.js +118 -166
  42. data/vendor/assets/vis/timeline/component/item/ItemRange.js +135 -187
  43. data/vendor/assets/vis/timeline/component/item/ItemRangeOverflow.js +29 -92
  44. data/vendor/assets/vis/timeline/stack.js +112 -0
  45. data/vendor/assets/vis/util.js +136 -38
  46. metadata +4 -18
  47. data/vendor/assets/vis/.gitignore +0 -1
  48. data/vendor/assets/vis/EventBus.js +0 -89
  49. data/vendor/assets/vis/events.js +0 -116
  50. data/vendor/assets/vis/graph/ClusterMixin.js +0 -1019
  51. data/vendor/assets/vis/graph/NavigationMixin.js +0 -245
  52. data/vendor/assets/vis/graph/SectorsMixin.js +0 -547
  53. data/vendor/assets/vis/graph/SelectionMixin.js +0 -515
  54. data/vendor/assets/vis/graph/img/downarrow.png +0 -0
  55. data/vendor/assets/vis/graph/img/leftarrow.png +0 -0
  56. data/vendor/assets/vis/graph/img/rightarrow.png +0 -0
  57. data/vendor/assets/vis/graph/img/uparrow.png +0 -0
  58. data/vendor/assets/vis/timeline/Controller.js +0 -183
  59. data/vendor/assets/vis/timeline/Stack.js +0 -190
  60. data/vendor/assets/vis/timeline/component/ContentPanel.js +0 -113
  61. data/vendor/assets/vis/timeline/component/GroupSet.js +0 -580
  62. data/vendor/assets/vis/timeline/component/css/groupset.css +0 -59
@@ -1,245 +0,0 @@
1
- /**
2
- * Created by Alex on 1/22/14.
3
- */
4
-
5
- var NavigationMixin = {
6
-
7
- /**
8
- * This function moves the navigation controls if the canvas size has been changed. If the arugments
9
- * verticaAlignTop and horizontalAlignLeft are false, the correction will be made
10
- *
11
- * @private
12
- */
13
- _relocateNavigation : function() {
14
- if (this.sectors !== undefined) {
15
- var xOffset = this.navigationClientWidth - this.frame.canvas.clientWidth;
16
- var yOffset = this.navigationClientHeight - this.frame.canvas.clientHeight;
17
- this.navigationClientWidth = this.frame.canvas.clientWidth;
18
- this.navigationClientHeight = this.frame.canvas.clientHeight;
19
- var node = null;
20
-
21
- for (var nodeId in this.sectors["navigation"]["nodes"]) {
22
- if (this.sectors["navigation"]["nodes"].hasOwnProperty(nodeId)) {
23
- node = this.sectors["navigation"]["nodes"][nodeId];
24
- if (!node.horizontalAlignLeft) {
25
- node.x -= xOffset;
26
- }
27
- if (!node.verticalAlignTop) {
28
- node.y -= yOffset;
29
- }
30
- }
31
- }
32
- }
33
- },
34
-
35
-
36
- /**
37
- * Creation of the navigation controls nodes. They are drawn over the rest of the nodes and are not affected by scale and translation
38
- * they have a triggerFunction which is called on click. If the position of the navigation controls is dependent
39
- * on this.frame.canvas.clientWidth or this.frame.canvas.clientHeight, we flag horizontalAlignLeft and verticalAlignTop false.
40
- * This means that the location will be corrected by the _relocateNavigation function on a size change of the canvas.
41
- *
42
- * @private
43
- */
44
- _loadNavigationElements : function() {
45
- var DIR = this.constants.navigation.iconPath;
46
- this.navigationClientWidth = this.frame.canvas.clientWidth;
47
- this.navigationClientHeight = this.frame.canvas.clientHeight;
48
- if (this.navigationClientWidth === undefined) {
49
- this.navigationClientWidth = 0;
50
- this.navigationClientHeight = 0;
51
- }
52
- var offset = 15;
53
- var intermediateOffset = 7;
54
- var navigationNodes = [
55
- {id: 'navigation_up', shape: 'image', image: DIR + '/uparrow.png', triggerFunction: "_moveUp",
56
- verticalAlignTop: false, x: 45 + offset + intermediateOffset, y: this.navigationClientHeight - 45 - offset - intermediateOffset},
57
- {id: 'navigation_down', shape: 'image', image: DIR + '/downarrow.png', triggerFunction: "_moveDown",
58
- verticalAlignTop: false, x: 45 + offset + intermediateOffset, y: this.navigationClientHeight - 15 - offset},
59
- {id: 'navigation_left', shape: 'image', image: DIR + '/leftarrow.png', triggerFunction: "_moveLeft",
60
- verticalAlignTop: false, x: 15 + offset, y: this.navigationClientHeight - 15 - offset},
61
- {id: 'navigation_right', shape: 'image', image: DIR + '/rightarrow.png',triggerFunction: "_moveRight",
62
- verticalAlignTop: false, x: 75 + offset + 2 * intermediateOffset, y: this.navigationClientHeight - 15 - offset},
63
-
64
- {id: 'navigation_plus', shape: 'image', image: DIR + '/plus.png', triggerFunction: "_zoomIn",
65
- verticalAlignTop: false, horizontalAlignLeft: false,
66
- x: this.navigationClientWidth - 45 - offset - intermediateOffset, y: this.navigationClientHeight - 15 - offset},
67
- {id: 'navigation_min', shape: 'image', image: DIR + '/minus.png', triggerFunction: "_zoomOut",
68
- verticalAlignTop: false, horizontalAlignLeft: false,
69
- x: this.navigationClientWidth - 15 - offset, y: this.navigationClientHeight - 15 - offset},
70
- {id: 'navigation_zoomExtends', shape: 'image', image: DIR + '/zoomExtends.png', triggerFunction: "zoomToFit",
71
- verticalAlignTop: false, horizontalAlignLeft: false,
72
- x: this.navigationClientWidth - 15 - offset, y: this.navigationClientHeight - 45 - offset - intermediateOffset}
73
- ];
74
-
75
- var nodeObj = null;
76
- for (var i = 0; i < navigationNodes.length; i++) {
77
- nodeObj = this.sectors["navigation"]['nodes'];
78
- nodeObj[navigationNodes[i]['id']] = new Node(navigationNodes[i], this.images, this.groups, this.constants);
79
- }
80
- },
81
-
82
-
83
- /**
84
- * By setting the clustersize to be larger than 1, we use the clustering drawing method
85
- * to illustrate the buttons are presed. We call this highlighting.
86
- *
87
- * @param {String} elementId
88
- * @private
89
- */
90
- _highlightNavigationElement : function(elementId) {
91
- if (this.sectors["navigation"]["nodes"].hasOwnProperty(elementId)) {
92
- this.sectors["navigation"]["nodes"][elementId].clusterSize = 2;
93
- }
94
- },
95
-
96
-
97
- /**
98
- * Reverting back to a normal button
99
- *
100
- * @param {String} elementId
101
- * @private
102
- */
103
- _unHighlightNavigationElement : function(elementId) {
104
- if (this.sectors["navigation"]["nodes"].hasOwnProperty(elementId)) {
105
- this.sectors["navigation"]["nodes"][elementId].clusterSize = 1;
106
- }
107
- },
108
-
109
- /**
110
- * un-highlight (for lack of a better term) all navigation controls elements
111
- * @private
112
- */
113
- _unHighlightAll : function() {
114
- for (var nodeId in this.sectors['navigation']['nodes']) {
115
- if (this.sectors['navigation']['nodes'].hasOwnProperty(nodeId)) {
116
- this._unHighlightNavigationElement(nodeId);
117
- }
118
- }
119
- },
120
-
121
-
122
- _preventDefault : function(event) {
123
- if (event !== undefined) {
124
- if (event.preventDefault) {
125
- event.preventDefault();
126
- } else {
127
- event.returnValue = false;
128
- }
129
- }
130
- },
131
-
132
-
133
- /**
134
- * move the screen up
135
- * By using the increments, instead of adding a fixed number to the translation, we keep fluent and
136
- * instant movement. The onKeypress event triggers immediately, then pauses, then triggers frequently
137
- * To avoid this behaviour, we do the translation in the start loop.
138
- *
139
- * @private
140
- */
141
- _moveUp : function(event) {
142
- this._highlightNavigationElement("navigation_up");
143
- this.yIncrement = this.constants.keyboard.speed.y;
144
- this.start(); // if there is no node movement, the calculation wont be done
145
- this._preventDefault(event);
146
- },
147
-
148
-
149
- /**
150
- * move the screen down
151
- * @private
152
- */
153
- _moveDown : function(event) {
154
- this._highlightNavigationElement("navigation_down");
155
- this.yIncrement = -this.constants.keyboard.speed.y;
156
- this.start(); // if there is no node movement, the calculation wont be done
157
- this._preventDefault(event);
158
- },
159
-
160
-
161
- /**
162
- * move the screen left
163
- * @private
164
- */
165
- _moveLeft : function(event) {
166
- this._highlightNavigationElement("navigation_left");
167
- this.xIncrement = this.constants.keyboard.speed.x;
168
- this.start(); // if there is no node movement, the calculation wont be done
169
- this._preventDefault(event);
170
- },
171
-
172
-
173
- /**
174
- * move the screen right
175
- * @private
176
- */
177
- _moveRight : function(event) {
178
- this._highlightNavigationElement("navigation_right");
179
- this.xIncrement = -this.constants.keyboard.speed.y;
180
- this.start(); // if there is no node movement, the calculation wont be done
181
- this._preventDefault(event);
182
- },
183
-
184
-
185
- /**
186
- * Zoom in, using the same method as the movement.
187
- * @private
188
- */
189
- _zoomIn : function(event) {
190
- this._highlightNavigationElement("navigation_plus");
191
- this.zoomIncrement = this.constants.keyboard.speed.zoom;
192
- this.start(); // if there is no node movement, the calculation wont be done
193
- this._preventDefault(event);
194
- },
195
-
196
-
197
- /**
198
- * Zoom out
199
- * @private
200
- */
201
- _zoomOut : function() {
202
- this._highlightNavigationElement("navigation_min");
203
- this.zoomIncrement = -this.constants.keyboard.speed.zoom;
204
- this.start(); // if there is no node movement, the calculation wont be done
205
- this._preventDefault(event);
206
- },
207
-
208
-
209
- /**
210
- * Stop zooming and unhighlight the zoom controls
211
- * @private
212
- */
213
- _stopZoom : function() {
214
- this._unHighlightNavigationElement("navigation_plus");
215
- this._unHighlightNavigationElement("navigation_min");
216
-
217
- this.zoomIncrement = 0;
218
- },
219
-
220
-
221
- /**
222
- * Stop moving in the Y direction and unHighlight the up and down
223
- * @private
224
- */
225
- _yStopMoving : function() {
226
- this._unHighlightNavigationElement("navigation_up");
227
- this._unHighlightNavigationElement("navigation_down");
228
-
229
- this.yIncrement = 0;
230
- },
231
-
232
-
233
- /**
234
- * Stop moving in the X direction and unHighlight left and right.
235
- * @private
236
- */
237
- _xStopMoving : function() {
238
- this._unHighlightNavigationElement("navigation_left");
239
- this._unHighlightNavigationElement("navigation_right");
240
-
241
- this.xIncrement = 0;
242
- }
243
-
244
-
245
- };
@@ -1,547 +0,0 @@
1
- /**
2
- * Creation of the SectorMixin var.
3
- *
4
- * This contains all the functions the Graph object can use to employ the sector system.
5
- * The sector system is always used by Graph, though the benefits only apply to the use of clustering.
6
- * If clustering is not used, there is no overhead except for a duplicate object with references to nodes and edges.
7
- *
8
- * Alex de Mulder
9
- * 21-01-2013
10
- */
11
- var SectorMixin = {
12
-
13
- /**
14
- * This function is only called by the setData function of the Graph object.
15
- * This loads the global references into the active sector. This initializes the sector.
16
- *
17
- * @private
18
- */
19
- _putDataInSector : function() {
20
- this.sectors["active"][this._sector()].nodes = this.nodes;
21
- this.sectors["active"][this._sector()].edges = this.edges;
22
- this.sectors["active"][this._sector()].nodeIndices = this.nodeIndices;
23
- },
24
-
25
-
26
- /**
27
- * /**
28
- * This function sets the global references to nodes, edges and nodeIndices back to
29
- * those of the supplied (active) sector. If a type is defined, do the specific type
30
- *
31
- * @param {String} sectorId
32
- * @param {String} [sectorType] | "active" or "frozen"
33
- * @private
34
- */
35
- _switchToSector : function(sectorId, sectorType) {
36
- if (sectorType === undefined || sectorType == "active") {
37
- this._switchToActiveSector(sectorId);
38
- }
39
- else {
40
- this._switchToFrozenSector(sectorId);
41
- }
42
- },
43
-
44
-
45
- /**
46
- * This function sets the global references to nodes, edges and nodeIndices back to
47
- * those of the supplied active sector.
48
- *
49
- * @param sectorId
50
- * @private
51
- */
52
- _switchToActiveSector : function(sectorId) {
53
- this.nodeIndices = this.sectors["active"][sectorId]["nodeIndices"];
54
- this.nodes = this.sectors["active"][sectorId]["nodes"];
55
- this.edges = this.sectors["active"][sectorId]["edges"];
56
- },
57
-
58
-
59
- /**
60
- * This function sets the global references to nodes, edges and nodeIndices back to
61
- * those of the supplied frozen sector.
62
- *
63
- * @param sectorId
64
- * @private
65
- */
66
- _switchToFrozenSector : function(sectorId) {
67
- this.nodeIndices = this.sectors["frozen"][sectorId]["nodeIndices"];
68
- this.nodes = this.sectors["frozen"][sectorId]["nodes"];
69
- this.edges = this.sectors["frozen"][sectorId]["edges"];
70
- },
71
-
72
-
73
- /**
74
- * This function sets the global references to nodes, edges and nodeIndices to
75
- * those of the navigation controls sector.
76
- *
77
- * @private
78
- */
79
- _switchToNavigationSector : function() {
80
- this.nodeIndices = this.sectors["navigation"]["nodeIndices"];
81
- this.nodes = this.sectors["navigation"]["nodes"];
82
- this.edges = this.sectors["navigation"]["edges"];
83
- },
84
-
85
-
86
- /**
87
- * This function sets the global references to nodes, edges and nodeIndices back to
88
- * those of the currently active sector.
89
- *
90
- * @private
91
- */
92
- _loadLatestSector : function() {
93
- this._switchToSector(this._sector());
94
- },
95
-
96
-
97
- /**
98
- * This function returns the currently active sector Id
99
- *
100
- * @returns {String}
101
- * @private
102
- */
103
- _sector : function() {
104
- return this.activeSector[this.activeSector.length-1];
105
- },
106
-
107
-
108
- /**
109
- * This function returns the previously active sector Id
110
- *
111
- * @returns {String}
112
- * @private
113
- */
114
- _previousSector : function() {
115
- if (this.activeSector.length > 1) {
116
- return this.activeSector[this.activeSector.length-2];
117
- }
118
- else {
119
- throw new TypeError('there are not enough sectors in the this.activeSector array.');
120
- }
121
- },
122
-
123
-
124
- /**
125
- * We add the active sector at the end of the this.activeSector array
126
- * This ensures it is the currently active sector returned by _sector() and it reaches the top
127
- * of the activeSector stack. When we reverse our steps we move from the end to the beginning of this stack.
128
- *
129
- * @param newId
130
- * @private
131
- */
132
- _setActiveSector : function(newId) {
133
- this.activeSector.push(newId);
134
- },
135
-
136
-
137
- /**
138
- * We remove the currently active sector id from the active sector stack. This happens when
139
- * we reactivate the previously active sector
140
- *
141
- * @private
142
- */
143
- _forgetLastSector : function() {
144
- this.activeSector.pop();
145
- },
146
-
147
-
148
- /**
149
- * This function creates a new active sector with the supplied newId. This newId
150
- * is the expanding node id.
151
- *
152
- * @param {String} newId | Id of the new active sector
153
- * @private
154
- */
155
- _createNewSector : function(newId) {
156
- // create the new sector
157
- this.sectors["active"][newId] = {"nodes":{},
158
- "edges":{},
159
- "nodeIndices":[],
160
- "formationScale": this.scale,
161
- "drawingNode": undefined};
162
-
163
- // create the new sector render node. This gives visual feedback that you are in a new sector.
164
- this.sectors["active"][newId]['drawingNode'] = new Node(
165
- {id:newId,
166
- color: {
167
- background: "#eaefef",
168
- border: "495c5e"
169
- }
170
- },{},{},this.constants);
171
- this.sectors["active"][newId]['drawingNode'].clusterSize = 2;
172
- },
173
-
174
-
175
- /**
176
- * This function removes the currently active sector. This is called when we create a new
177
- * active sector.
178
- *
179
- * @param {String} sectorId | Id of the active sector that will be removed
180
- * @private
181
- */
182
- _deleteActiveSector : function(sectorId) {
183
- delete this.sectors["active"][sectorId];
184
- },
185
-
186
-
187
- /**
188
- * This function removes the currently active sector. This is called when we reactivate
189
- * the previously active sector.
190
- *
191
- * @param {String} sectorId | Id of the active sector that will be removed
192
- * @private
193
- */
194
- _deleteFrozenSector : function(sectorId) {
195
- delete this.sectors["frozen"][sectorId];
196
- },
197
-
198
-
199
- /**
200
- * Freezing an active sector means moving it from the "active" object to the "frozen" object.
201
- * We copy the references, then delete the active entree.
202
- *
203
- * @param sectorId
204
- * @private
205
- */
206
- _freezeSector : function(sectorId) {
207
- // we move the set references from the active to the frozen stack.
208
- this.sectors["frozen"][sectorId] = this.sectors["active"][sectorId];
209
-
210
- // we have moved the sector data into the frozen set, we now remove it from the active set
211
- this._deleteActiveSector(sectorId);
212
- },
213
-
214
-
215
- /**
216
- * This is the reverse operation of _freezeSector. Activating means moving the sector from the "frozen"
217
- * object to the "active" object.
218
- *
219
- * @param sectorId
220
- * @private
221
- */
222
- _activateSector : function(sectorId) {
223
- // we move the set references from the frozen to the active stack.
224
- this.sectors["active"][sectorId] = this.sectors["frozen"][sectorId];
225
-
226
- // we have moved the sector data into the active set, we now remove it from the frozen stack
227
- this._deleteFrozenSector(sectorId);
228
- },
229
-
230
-
231
- /**
232
- * This function merges the data from the currently active sector with a frozen sector. This is used
233
- * in the process of reverting back to the previously active sector.
234
- * The data that is placed in the frozen (the previously active) sector is the node that has been removed from it
235
- * upon the creation of a new active sector.
236
- *
237
- * @param sectorId
238
- * @private
239
- */
240
- _mergeThisWithFrozen : function(sectorId) {
241
- // copy all nodes
242
- for (var nodeId in this.nodes) {
243
- if (this.nodes.hasOwnProperty(nodeId)) {
244
- this.sectors["frozen"][sectorId]["nodes"][nodeId] = this.nodes[nodeId];
245
- }
246
- }
247
-
248
- // copy all edges (if not fully clustered, else there are no edges)
249
- for (var edgeId in this.edges) {
250
- if (this.edges.hasOwnProperty(edgeId)) {
251
- this.sectors["frozen"][sectorId]["edges"][edgeId] = this.edges[edgeId];
252
- }
253
- }
254
-
255
- // merge the nodeIndices
256
- for (var i = 0; i < this.nodeIndices.length; i++) {
257
- this.sectors["frozen"][sectorId]["nodeIndices"].push(this.nodeIndices[i]);
258
- }
259
- },
260
-
261
-
262
- /**
263
- * This clusters the sector to one cluster. It was a single cluster before this process started so
264
- * we revert to that state. The clusterToFit function with a maximum size of 1 node does this.
265
- *
266
- * @private
267
- */
268
- _collapseThisToSingleCluster : function() {
269
- this.clusterToFit(1,false);
270
- },
271
-
272
-
273
- /**
274
- * We create a new active sector from the node that we want to open.
275
- *
276
- * @param node
277
- * @private
278
- */
279
- _addSector : function(node) {
280
- // this is the currently active sector
281
- var sector = this._sector();
282
-
283
- // // this should allow me to select nodes from a frozen set.
284
- // if (this.sectors['active'][sector]["nodes"].hasOwnProperty(node.id)) {
285
- // console.log("the node is part of the active sector");
286
- // }
287
- // else {
288
- // console.log("I dont know what the fuck happened!!");
289
- // }
290
-
291
- // when we switch to a new sector, we remove the node that will be expanded from the current nodes list.
292
- delete this.nodes[node.id];
293
-
294
- var unqiueIdentifier = util.randomUUID();
295
-
296
- // we fully freeze the currently active sector
297
- this._freezeSector(sector);
298
-
299
- // we create a new active sector. This sector has the Id of the node to ensure uniqueness
300
- this._createNewSector(unqiueIdentifier);
301
-
302
- // we add the active sector to the sectors array to be able to revert these steps later on
303
- this._setActiveSector(unqiueIdentifier);
304
-
305
- // we redirect the global references to the new sector's references. this._sector() now returns unqiueIdentifier
306
- this._switchToSector(this._sector());
307
-
308
- // finally we add the node we removed from our previous active sector to the new active sector
309
- this.nodes[node.id] = node;
310
- },
311
-
312
-
313
- /**
314
- * We close the sector that is currently open and revert back to the one before.
315
- * If the active sector is the "default" sector, nothing happens.
316
- *
317
- * @private
318
- */
319
- _collapseSector : function() {
320
- // the currently active sector
321
- var sector = this._sector();
322
-
323
- // we cannot collapse the default sector
324
- if (sector != "default") {
325
- if ((this.nodeIndices.length == 1) ||
326
- (this.sectors["active"][sector]["drawingNode"].width*this.scale < this.constants.clustering.screenSizeThreshold * this.frame.canvas.clientWidth) ||
327
- (this.sectors["active"][sector]["drawingNode"].height*this.scale < this.constants.clustering.screenSizeThreshold * this.frame.canvas.clientHeight)) {
328
- var previousSector = this._previousSector();
329
-
330
- // we collapse the sector back to a single cluster
331
- this._collapseThisToSingleCluster();
332
-
333
- // we move the remaining nodes, edges and nodeIndices to the previous sector.
334
- // This previous sector is the one we will reactivate
335
- this._mergeThisWithFrozen(previousSector);
336
-
337
- // the previously active (frozen) sector now has all the data from the currently active sector.
338
- // we can now delete the active sector.
339
- this._deleteActiveSector(sector);
340
-
341
- // we activate the previously active (and currently frozen) sector.
342
- this._activateSector(previousSector);
343
-
344
- // we load the references from the newly active sector into the global references
345
- this._switchToSector(previousSector);
346
-
347
- // we forget the previously active sector because we reverted to the one before
348
- this._forgetLastSector();
349
-
350
- // finally, we update the node index list.
351
- this._updateNodeIndexList();
352
- }
353
- }
354
- },
355
-
356
-
357
- /**
358
- * This runs a function in all active sectors. This is used in _redraw() and the _initializeForceCalculation().
359
- *
360
- * @param {String} runFunction | This is the NAME of a function we want to call in all active sectors
361
- * | we dont pass the function itself because then the "this" is the window object
362
- * | instead of the Graph object
363
- * @param {*} [argument] | Optional: arguments to pass to the runFunction
364
- * @private
365
- */
366
- _doInAllActiveSectors : function(runFunction,argument) {
367
- if (argument === undefined) {
368
- for (var sector in this.sectors["active"]) {
369
- if (this.sectors["active"].hasOwnProperty(sector)) {
370
- // switch the global references to those of this sector
371
- this._switchToActiveSector(sector);
372
- this[runFunction]();
373
- }
374
- }
375
- }
376
- else {
377
- for (var sector in this.sectors["active"]) {
378
- if (this.sectors["active"].hasOwnProperty(sector)) {
379
- // switch the global references to those of this sector
380
- this._switchToActiveSector(sector);
381
- var args = Array.prototype.splice.call(arguments, 1);
382
- if (args.length > 1) {
383
- this[runFunction](args[0],args[1]);
384
- }
385
- else {
386
- this[runFunction](argument);
387
- }
388
- }
389
- }
390
- }
391
- // we revert the global references back to our active sector
392
- this._loadLatestSector();
393
- },
394
-
395
-
396
- /**
397
- * This runs a function in all frozen sectors. This is used in the _redraw().
398
- *
399
- * @param {String} runFunction | This is the NAME of a function we want to call in all active sectors
400
- * | we don't pass the function itself because then the "this" is the window object
401
- * | instead of the Graph object
402
- * @param {*} [argument] | Optional: arguments to pass to the runFunction
403
- * @private
404
- */
405
- _doInAllFrozenSectors : function(runFunction,argument) {
406
- if (argument === undefined) {
407
- for (var sector in this.sectors["frozen"]) {
408
- if (this.sectors["frozen"].hasOwnProperty(sector)) {
409
- // switch the global references to those of this sector
410
- this._switchToFrozenSector(sector);
411
- this[runFunction]();
412
- }
413
- }
414
- }
415
- else {
416
- for (var sector in this.sectors["frozen"]) {
417
- if (this.sectors["frozen"].hasOwnProperty(sector)) {
418
- // switch the global references to those of this sector
419
- this._switchToFrozenSector(sector);
420
- var args = Array.prototype.splice.call(arguments, 1);
421
- if (args.length > 1) {
422
- this[runFunction](args[0],args[1]);
423
- }
424
- else {
425
- this[runFunction](argument);
426
- }
427
- }
428
- }
429
- }
430
- this._loadLatestSector();
431
- },
432
-
433
-
434
- /**
435
- * This runs a function in the navigation controls sector.
436
- *
437
- * @param {String} runFunction | This is the NAME of a function we want to call in all active sectors
438
- * | we don't pass the function itself because then the "this" is the window object
439
- * | instead of the Graph object
440
- * @param {*} [argument] | Optional: arguments to pass to the runFunction
441
- * @private
442
- */
443
- _doInNavigationSector : function(runFunction,argument) {
444
- this._switchToNavigationSector();
445
- if (argument === undefined) {
446
- this[runFunction]();
447
- }
448
- else {
449
- var args = Array.prototype.splice.call(arguments, 1);
450
- if (args.length > 1) {
451
- this[runFunction](args[0],args[1]);
452
- }
453
- else {
454
- this[runFunction](argument);
455
- }
456
- }
457
- this._loadLatestSector();
458
- },
459
-
460
-
461
- /**
462
- * This runs a function in all sectors. This is used in the _redraw().
463
- *
464
- * @param {String} runFunction | This is the NAME of a function we want to call in all active sectors
465
- * | we don't pass the function itself because then the "this" is the window object
466
- * | instead of the Graph object
467
- * @param {*} [argument] | Optional: arguments to pass to the runFunction
468
- * @private
469
- */
470
- _doInAllSectors : function(runFunction,argument) {
471
- var args = Array.prototype.splice.call(arguments, 1);
472
- if (argument === undefined) {
473
- this._doInAllActiveSectors(runFunction);
474
- this._doInAllFrozenSectors(runFunction);
475
- }
476
- else {
477
- if (args.length > 1) {
478
- this._doInAllActiveSectors(runFunction,args[0],args[1]);
479
- this._doInAllFrozenSectors(runFunction,args[0],args[1]);
480
- }
481
- else {
482
- this._doInAllActiveSectors(runFunction,argument);
483
- this._doInAllFrozenSectors(runFunction,argument);
484
- }
485
- }
486
-
487
- },
488
-
489
-
490
- /**
491
- * This clears the nodeIndices list. We cannot use this.nodeIndices = [] because we would break the link with the
492
- * active sector. Thus we clear the nodeIndices in the active sector, then reconnect the this.nodeIndices to it.
493
- *
494
- * @private
495
- */
496
- _clearNodeIndexList : function() {
497
- var sector = this._sector();
498
- this.sectors["active"][sector]["nodeIndices"] = [];
499
- this.nodeIndices = this.sectors["active"][sector]["nodeIndices"];
500
- },
501
-
502
-
503
- /**
504
- * Draw the encompassing sector node
505
- *
506
- * @param ctx
507
- * @param sectorType
508
- * @private
509
- */
510
- _drawSectorNodes : function(ctx,sectorType) {
511
- var minY = 1e9, maxY = -1e9, minX = 1e9, maxX = -1e9, node;
512
- for (var sector in this.sectors[sectorType]) {
513
- if (this.sectors[sectorType].hasOwnProperty(sector)) {
514
- if (this.sectors[sectorType][sector]["drawingNode"] !== undefined) {
515
-
516
- this._switchToSector(sector,sectorType);
517
-
518
- minY = 1e9; maxY = -1e9; minX = 1e9; maxX = -1e9;
519
- for (var nodeId in this.nodes) {
520
- if (this.nodes.hasOwnProperty(nodeId)) {
521
- node = this.nodes[nodeId];
522
- node.resize(ctx);
523
- if (minX > node.x - 0.5 * node.width) {minX = node.x - 0.5 * node.width;}
524
- if (maxX < node.x + 0.5 * node.width) {maxX = node.x + 0.5 * node.width;}
525
- if (minY > node.y - 0.5 * node.height) {minY = node.y - 0.5 * node.height;}
526
- if (maxY < node.y + 0.5 * node.height) {maxY = node.y + 0.5 * node.height;}
527
- }
528
- }
529
- node = this.sectors[sectorType][sector]["drawingNode"];
530
- node.x = 0.5 * (maxX + minX);
531
- node.y = 0.5 * (maxY + minY);
532
- node.width = 2 * (node.x - minX);
533
- node.height = 2 * (node.y - minY);
534
- node.radius = Math.sqrt(Math.pow(0.5*node.width,2) + Math.pow(0.5*node.height,2));
535
- node.setScale(this.scale);
536
- node._drawCircle(ctx);
537
- }
538
- }
539
- }
540
- },
541
-
542
- _drawAllSectorNodes : function(ctx) {
543
- this._drawSectorNodes(ctx,"frozen");
544
- this._drawSectorNodes(ctx,"active");
545
- this._loadLatestSector();
546
- }
547
- };