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.

1196 lines
42 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. var util = require('../util');
  2. /**
  3. * @class Node
  4. * A node. A node can be connected to other nodes via one or multiple edges.
  5. * @param {object} properties An object containing properties for the node. All
  6. * properties are optional, except for the id.
  7. * {number} id Id of the node. Required
  8. * {string} label Text label for the node
  9. * {number} x Horizontal position of the node
  10. * {number} y Vertical position of the node
  11. * {string} shape Node shape, available:
  12. * "database", "circle", "ellipse",
  13. * "box", "image", "text", "dot",
  14. * "star", "triangle", "triangleDown",
  15. * "square"
  16. * {string} image An image url
  17. * {string} title An title text, can be HTML
  18. * {anytype} group A group name or number
  19. * @param {Network.Images} imagelist A list with images. Only needed
  20. * when the node has an image
  21. * @param {Network.Groups} grouplist A list with groups. Needed for
  22. * retrieving group properties
  23. * @param {Object} constants An object with default values for
  24. * example for the color
  25. *
  26. */
  27. function Node(properties, imagelist, grouplist, networkConstants) {
  28. var constants = util.selectiveBridgeObject(['nodes'],networkConstants);
  29. this.options = constants.nodes;
  30. this.selected = false;
  31. this.hover = false;
  32. this.edges = []; // all edges connected to this node
  33. this.dynamicEdges = [];
  34. this.reroutedEdges = {};
  35. // set defaults for the properties
  36. this.id = undefined;
  37. this.allowedToMoveX = false;
  38. this.allowedToMoveY = false;
  39. this.xFixed = false;
  40. this.yFixed = false;
  41. this.horizontalAlignLeft = true; // these are for the navigation controls
  42. this.verticalAlignTop = true; // these are for the navigation controls
  43. this.baseRadiusValue = networkConstants.nodes.radius;
  44. this.radiusFixed = false;
  45. this.level = -1;
  46. this.preassignedLevel = false;
  47. this.hierarchyEnumerated = false;
  48. this.labelDimensions = {top:0, left:0, width:0, height:0, yLine:0}; // could be cached
  49. this.boundingBox = {top:0, left:0, right:0, bottom:0};
  50. this.imagelist = imagelist;
  51. this.grouplist = grouplist;
  52. // physics properties
  53. this.fx = 0.0; // external force x
  54. this.fy = 0.0; // external force y
  55. this.vx = 0.0; // velocity x
  56. this.vy = 0.0; // velocity y
  57. this.x = null;
  58. this.y = null;
  59. this.predefinedPosition = false; // used to check if initial zoomExtent should just take the range or approximate
  60. // used for reverting to previous position on stabilization
  61. this.previousState = {vx:0,vy:0,x:0,y:0};
  62. this.damping = networkConstants.physics.damping; // written every time gravity is calculated
  63. this.fixedData = {x:null,y:null};
  64. this.setProperties(properties, constants);
  65. // creating the variables for clustering
  66. this.resetCluster();
  67. this.clusterSession = 0;
  68. this.clusterSizeWidthFactor = networkConstants.clustering.nodeScaling.width;
  69. this.clusterSizeHeightFactor = networkConstants.clustering.nodeScaling.height;
  70. this.clusterSizeRadiusFactor = networkConstants.clustering.nodeScaling.radius;
  71. this.maxNodeSizeIncrements = networkConstants.clustering.maxNodeSizeIncrements;
  72. this.growthIndicator = 0;
  73. // variables to tell the node about the network.
  74. this.networkScaleInv = 1;
  75. this.networkScale = 1;
  76. this.canvasTopLeft = {"x": -300, "y": -300};
  77. this.canvasBottomRight = {"x": 300, "y": 300};
  78. this.parentEdgeId = null;
  79. }
  80. /**
  81. * Revert the position and velocity of the previous step.
  82. */
  83. Node.prototype.revertPosition = function() {
  84. this.x = this.previousState.x;
  85. this.y = this.previousState.y;
  86. this.vx = this.previousState.vx;
  87. this.vy = this.previousState.vy;
  88. }
  89. /**
  90. * (re)setting the clustering variables and objects
  91. */
  92. Node.prototype.resetCluster = function() {
  93. // clustering variables
  94. this.formationScale = undefined; // this is used to determine when to open the cluster
  95. this.clusterSize = 1; // this signifies the total amount of nodes in this cluster
  96. this.containedNodes = {};
  97. this.containedEdges = {};
  98. this.clusterSessions = [];
  99. };
  100. /**
  101. * Attach a edge to the node
  102. * @param {Edge} edge
  103. */
  104. Node.prototype.attachEdge = function(edge) {
  105. if (this.edges.indexOf(edge) == -1) {
  106. this.edges.push(edge);
  107. }
  108. if (this.dynamicEdges.indexOf(edge) == -1) {
  109. this.dynamicEdges.push(edge);
  110. }
  111. };
  112. /**
  113. * Detach a edge from the node
  114. * @param {Edge} edge
  115. */
  116. Node.prototype.detachEdge = function(edge) {
  117. var index = this.edges.indexOf(edge);
  118. if (index != -1) {
  119. this.edges.splice(index, 1);
  120. }
  121. index = this.dynamicEdges.indexOf(edge);
  122. if (index != -1) {
  123. this.dynamicEdges.splice(index, 1);
  124. }
  125. };
  126. /**
  127. * Set or overwrite properties for the node
  128. * @param {Object} properties an object with properties
  129. * @param {Object} constants and object with default, global properties
  130. */
  131. Node.prototype.setProperties = function(properties, constants) {
  132. if (!properties) {
  133. return;
  134. }
  135. var fields = ['borderWidth','borderWidthSelected','shape','image','brokenImage','radius','fontColor',
  136. 'fontSize','fontFace','fontFill','fontStrokeWidth','fontStrokeColor','group','mass','fontDrawThreshold',
  137. 'scaleFontWithValue','fontSizeMaxVisible'
  138. ];
  139. util.selectiveDeepExtend(fields, this.options, properties);
  140. // basic properties
  141. if (properties.id !== undefined) {this.id = properties.id;}
  142. if (properties.label !== undefined) {this.label = properties.label; this.originalLabel = properties.label;}
  143. if (properties.title !== undefined) {this.title = properties.title;}
  144. if (properties.x !== undefined) {this.x = properties.x; this.predefinedPosition = true;}
  145. if (properties.y !== undefined) {this.y = properties.y; this.predefinedPosition = true;}
  146. if (properties.value !== undefined) {this.value = properties.value;}
  147. if (properties.level !== undefined) {this.level = properties.level; this.preassignedLevel = true;}
  148. // navigation controls properties
  149. if (properties.horizontalAlignLeft !== undefined) {this.horizontalAlignLeft = properties.horizontalAlignLeft;}
  150. if (properties.verticalAlignTop !== undefined) {this.verticalAlignTop = properties.verticalAlignTop;}
  151. if (properties.triggerFunction !== undefined) {this.triggerFunction = properties.triggerFunction;}
  152. if (this.id === undefined) {
  153. throw "Node must have an id";
  154. }
  155. // copy group properties
  156. if (typeof properties.group === 'number' || (typeof properties.group === 'string' && properties.group != '')) {
  157. var groupObj = this.grouplist.get(properties.group);
  158. util.deepExtend(this.options, groupObj);
  159. // the color object needs to be completely defined. Since groups can partially overwrite the colors, we parse it again, just in case.
  160. this.options.color = util.parseColor(this.options.color);
  161. }
  162. // individual shape properties
  163. if (properties.radius !== undefined) {this.baseRadiusValue = this.options.radius;}
  164. if (properties.color !== undefined) {this.options.color = util.parseColor(properties.color);}
  165. if (this.options.image !== undefined && this.options.image!= "") {
  166. if (this.imagelist) {
  167. this.imageObj = this.imagelist.load(this.options.image, this.options.brokenImage);
  168. }
  169. else {
  170. throw "No imagelist provided";
  171. }
  172. }
  173. if (properties.allowedToMoveX !== undefined) {
  174. this.xFixed = !properties.allowedToMoveX;
  175. this.allowedToMoveX = properties.allowedToMoveX;
  176. }
  177. else if (properties.x !== undefined && this.allowedToMoveX == false) {
  178. this.xFixed = true;
  179. }
  180. if (properties.allowedToMoveY !== undefined) {
  181. this.yFixed = !properties.allowedToMoveY;
  182. this.allowedToMoveY = properties.allowedToMoveY;
  183. }
  184. else if (properties.y !== undefined && this.allowedToMoveY == false) {
  185. this.yFixed = true;
  186. }
  187. this.radiusFixed = this.radiusFixed || (properties.radius !== undefined);
  188. if (this.options.shape === 'image' || this.options.shape === 'circularImage') {
  189. this.options.radiusMin = constants.nodes.widthMin;
  190. this.options.radiusMax = constants.nodes.widthMax;
  191. }
  192. // choose draw method depending on the shape
  193. switch (this.options.shape) {
  194. case 'database': this.draw = this._drawDatabase; this.resize = this._resizeDatabase; break;
  195. case 'box': this.draw = this._drawBox; this.resize = this._resizeBox; break;
  196. case 'circle': this.draw = this._drawCircle; this.resize = this._resizeCircle; break;
  197. case 'ellipse': this.draw = this._drawEllipse; this.resize = this._resizeEllipse; break;
  198. // TODO: add diamond shape
  199. case 'image': this.draw = this._drawImage; this.resize = this._resizeImage; break;
  200. case 'circularImage': this.draw = this._drawCircularImage; this.resize = this._resizeCircularImage; break;
  201. case 'text': this.draw = this._drawText; this.resize = this._resizeText; break;
  202. case 'dot': this.draw = this._drawDot; this.resize = this._resizeShape; break;
  203. case 'square': this.draw = this._drawSquare; this.resize = this._resizeShape; break;
  204. case 'triangle': this.draw = this._drawTriangle; this.resize = this._resizeShape; break;
  205. case 'triangleDown': this.draw = this._drawTriangleDown; this.resize = this._resizeShape; break;
  206. case 'star': this.draw = this._drawStar; this.resize = this._resizeShape; break;
  207. default: this.draw = this._drawEllipse; this.resize = this._resizeEllipse; break;
  208. }
  209. // reset the size of the node, this can be changed
  210. this._reset();
  211. };
  212. /**
  213. * select this node
  214. */
  215. Node.prototype.select = function() {
  216. this.selected = true;
  217. this._reset();
  218. };
  219. /**
  220. * unselect this node
  221. */
  222. Node.prototype.unselect = function() {
  223. this.selected = false;
  224. this._reset();
  225. };
  226. /**
  227. * Reset the calculated size of the node, forces it to recalculate its size
  228. */
  229. Node.prototype.clearSizeCache = function() {
  230. this._reset();
  231. };
  232. /**
  233. * Reset the calculated size of the node, forces it to recalculate its size
  234. * @private
  235. */
  236. Node.prototype._reset = function() {
  237. this.width = undefined;
  238. this.height = undefined;
  239. };
  240. /**
  241. * get the title of this node.
  242. * @return {string} title The title of the node, or undefined when no title
  243. * has been set.
  244. */
  245. Node.prototype.getTitle = function() {
  246. return typeof this.title === "function" ? this.title() : this.title;
  247. };
  248. /**
  249. * Calculate the distance to the border of the Node
  250. * @param {CanvasRenderingContext2D} ctx
  251. * @param {Number} angle Angle in radians
  252. * @returns {number} distance Distance to the border in pixels
  253. */
  254. Node.prototype.distanceToBorder = function (ctx, angle) {
  255. var borderWidth = 1;
  256. if (!this.width) {
  257. this.resize(ctx);
  258. }
  259. switch (this.options.shape) {
  260. case 'circle':
  261. case 'dot':
  262. return this.options.radius+ borderWidth;
  263. case 'ellipse':
  264. var a = this.width / 2;
  265. var b = this.height / 2;
  266. var w = (Math.sin(angle) * a);
  267. var h = (Math.cos(angle) * b);
  268. return a * b / Math.sqrt(w * w + h * h);
  269. // TODO: implement distanceToBorder for database
  270. // TODO: implement distanceToBorder for triangle
  271. // TODO: implement distanceToBorder for triangleDown
  272. case 'box':
  273. case 'image':
  274. case 'text':
  275. default:
  276. if (this.width) {
  277. return Math.min(
  278. Math.abs(this.width / 2 / Math.cos(angle)),
  279. Math.abs(this.height / 2 / Math.sin(angle))) + borderWidth;
  280. // TODO: reckon with border radius too in case of box
  281. }
  282. else {
  283. return 0;
  284. }
  285. }
  286. // TODO: implement calculation of distance to border for all shapes
  287. };
  288. /**
  289. * Set forces acting on the node
  290. * @param {number} fx Force in horizontal direction
  291. * @param {number} fy Force in vertical direction
  292. */
  293. Node.prototype._setForce = function(fx, fy) {
  294. this.fx = fx;
  295. this.fy = fy;
  296. };
  297. /**
  298. * Add forces acting on the node
  299. * @param {number} fx Force in horizontal direction
  300. * @param {number} fy Force in vertical direction
  301. * @private
  302. */
  303. Node.prototype._addForce = function(fx, fy) {
  304. this.fx += fx;
  305. this.fy += fy;
  306. };
  307. /**
  308. * Store the state before the next step
  309. */
  310. Node.prototype.storeState = function() {
  311. this.previousState.x = this.x;
  312. this.previousState.y = this.y;
  313. this.previousState.vx = this.vx;
  314. this.previousState.vy = this.vy;
  315. }
  316. /**
  317. * Perform one discrete step for the node
  318. * @param {number} interval Time interval in seconds
  319. */
  320. Node.prototype.discreteStep = function(interval) {
  321. this.storeState();
  322. if (!this.xFixed) {
  323. var dx = this.damping * this.vx; // damping force
  324. var ax = (this.fx - dx) / this.options.mass; // acceleration
  325. this.vx += ax * interval; // velocity
  326. this.x += this.vx * interval; // position
  327. }
  328. else {
  329. this.fx = 0;
  330. this.vx = 0;
  331. }
  332. if (!this.yFixed) {
  333. var dy = this.damping * this.vy; // damping force
  334. var ay = (this.fy - dy) / this.options.mass; // acceleration
  335. this.vy += ay * interval; // velocity
  336. this.y += this.vy * interval; // position
  337. }
  338. else {
  339. this.fy = 0;
  340. this.vy = 0;
  341. }
  342. };
  343. /**
  344. * Perform one discrete step for the node
  345. * @param {number} interval Time interval in seconds
  346. * @param {number} maxVelocity The speed limit imposed on the velocity
  347. */
  348. Node.prototype.discreteStepLimited = function(interval, maxVelocity) {
  349. this.storeState();
  350. if (!this.xFixed) {
  351. var dx = this.damping * this.vx; // damping force
  352. var ax = (this.fx - dx) / this.options.mass; // acceleration
  353. this.vx += ax * interval; // velocity
  354. this.vx = (Math.abs(this.vx) > maxVelocity) ? ((this.vx > 0) ? maxVelocity : -maxVelocity) : this.vx;
  355. this.x += this.vx * interval; // position
  356. }
  357. else {
  358. this.fx = 0;
  359. this.vx = 0;
  360. }
  361. if (!this.yFixed) {
  362. var dy = this.damping * this.vy; // damping force
  363. var ay = (this.fy - dy) / this.options.mass; // acceleration
  364. this.vy += ay * interval; // velocity
  365. this.vy = (Math.abs(this.vy) > maxVelocity) ? ((this.vy > 0) ? maxVelocity : -maxVelocity) : this.vy;
  366. this.y += this.vy * interval; // position
  367. }
  368. else {
  369. this.fy = 0;
  370. this.vy = 0;
  371. }
  372. };
  373. /**
  374. * Check if this node has a fixed x and y position
  375. * @return {boolean} true if fixed, false if not
  376. */
  377. Node.prototype.isFixed = function() {
  378. return (this.xFixed && this.yFixed);
  379. };
  380. /**
  381. * Check if this node is moving
  382. * @param {number} vmin the minimum velocity considered as "moving"
  383. * @return {boolean} true if moving, false if it has no velocity
  384. */
  385. Node.prototype.isMoving = function(vmin) {
  386. var velocity = Math.sqrt(Math.pow(this.vx,2) + Math.pow(this.vy,2));
  387. // this.velocity = Math.sqrt(Math.pow(this.vx,2) + Math.pow(this.vy,2))
  388. return (velocity > vmin);
  389. };
  390. /**
  391. * check if this node is selecte
  392. * @return {boolean} selected True if node is selected, else false
  393. */
  394. Node.prototype.isSelected = function() {
  395. return this.selected;
  396. };
  397. /**
  398. * Retrieve the value of the node. Can be undefined
  399. * @return {Number} value
  400. */
  401. Node.prototype.getValue = function() {
  402. return this.value;
  403. };
  404. /**
  405. * Calculate the distance from the nodes location to the given location (x,y)
  406. * @param {Number} x
  407. * @param {Number} y
  408. * @return {Number} value
  409. */
  410. Node.prototype.getDistance = function(x, y) {
  411. var dx = this.x - x,
  412. dy = this.y - y;
  413. return Math.sqrt(dx * dx + dy * dy);
  414. };
  415. /**
  416. * Adjust the value range of the node. The node will adjust it's radius
  417. * based on its value.
  418. * @param {Number} min
  419. * @param {Number} max
  420. */
  421. Node.prototype.setValueRange = function(min, max) {
  422. if (!this.radiusFixed && this.value !== undefined) {
  423. if (max == min) {
  424. this.options.radius= (this.options.radiusMin + this.options.radiusMax) / 2;
  425. if (this.options.scaleFontWithValue == true) {
  426. this.options.fontSize = (this.options.fontSizeMin + this.options.fontSizeMax) / 2;
  427. }
  428. }
  429. else {
  430. var scale = (this.options.radiusMax - this.options.radiusMin) / (max - min);
  431. var fontScale = (this.options.fontSizeMax - this.options.fontSizeMin) / (max - min);
  432. if (this.options.scaleFontWithValue == true) {
  433. this.options.fontSize = Math.max(this.options.fontSizeMin ,(this.value - min) * fontScale + this.options.fontSizeMin);
  434. }
  435. this.options.radius= Math.max(this.options.radiusMin,(this.value - min) * scale + this.options.radiusMin); // max function is protection against value = 0
  436. }
  437. }
  438. this.baseRadiusValue = this.options.radius;
  439. };
  440. /**
  441. * Draw this node in the given canvas
  442. * The 2d context of a HTML canvas can be retrieved by canvas.getContext("2d");
  443. * @param {CanvasRenderingContext2D} ctx
  444. */
  445. Node.prototype.draw = function(ctx) {
  446. throw "Draw method not initialized for node";
  447. };
  448. /**
  449. * Recalculate the size of this node in the given canvas
  450. * The 2d context of a HTML canvas can be retrieved by canvas.getContext("2d");
  451. * @param {CanvasRenderingContext2D} ctx
  452. */
  453. Node.prototype.resize = function(ctx) {
  454. throw "Resize method not initialized for node";
  455. };
  456. /**
  457. * Check if this object is overlapping with the provided object
  458. * @param {Object} obj an object with parameters left, top, right, bottom
  459. * @return {boolean} True if location is located on node
  460. */
  461. Node.prototype.isOverlappingWith = function(obj) {
  462. return (this.left < obj.right &&
  463. this.left + this.width > obj.left &&
  464. this.top < obj.bottom &&
  465. this.top + this.height > obj.top);
  466. };
  467. Node.prototype._resizeImage = function (ctx) {
  468. // TODO: pre calculate the image size
  469. if (!this.width || !this.height) { // undefined or 0
  470. var width, height;
  471. if (this.value) {
  472. this.options.radius= this.baseRadiusValue;
  473. var scale = this.imageObj.height / this.imageObj.width;
  474. if (scale !== undefined) {
  475. width = this.options.radius|| this.imageObj.width;
  476. height = this.options.radius* scale || this.imageObj.height;
  477. }
  478. else {
  479. width = 0;
  480. height = 0;
  481. }
  482. }
  483. else {
  484. width = this.imageObj.width;
  485. height = this.imageObj.height;
  486. }
  487. this.width = width;
  488. this.height = height;
  489. this.growthIndicator = 0;
  490. if (this.width > 0 && this.height > 0) {
  491. this.width += Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * this.clusterSizeWidthFactor;
  492. this.height += Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * this.clusterSizeHeightFactor;
  493. this.options.radius+= Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * this.clusterSizeRadiusFactor;
  494. this.growthIndicator = this.width - width;
  495. }
  496. }
  497. };
  498. Node.prototype._drawImageAtPosition = function (ctx) {
  499. if (this.imageObj.width != 0 ) {
  500. // draw the shade
  501. if (this.clusterSize > 1) {
  502. var lineWidth = ((this.clusterSize > 1) ? 10 : 0.0);
  503. lineWidth *= this.networkScaleInv;
  504. lineWidth = Math.min(0.2 * this.width,lineWidth);
  505. ctx.globalAlpha = 0.5;
  506. ctx.drawImage(this.imageObj, this.left - lineWidth, this.top - lineWidth, this.width + 2*lineWidth, this.height + 2*lineWidth);
  507. }
  508. // draw the image
  509. ctx.globalAlpha = 1.0;
  510. ctx.drawImage(this.imageObj, this.left, this.top, this.width, this.height);
  511. }
  512. };
  513. Node.prototype._drawImageLabel = function (ctx) {
  514. var yLabel;
  515. var offset = 0;
  516. if (this.height){
  517. offset = this.height / 2;
  518. var labelDimensions = this.getTextSize(ctx);
  519. if (labelDimensions.lineCount >= 1){
  520. offset += labelDimensions.height / 2;
  521. offset += 3;
  522. }
  523. }
  524. yLabel = this.y + offset;
  525. this._label(ctx, this.label, this.x, yLabel, undefined);
  526. };
  527. Node.prototype._drawImage = function (ctx) {
  528. this._resizeImage(ctx);
  529. this.left = this.x - this.width / 2;
  530. this.top = this.y - this.height / 2;
  531. this._drawImageAtPosition(ctx);
  532. this.boundingBox.top = this.top;
  533. this.boundingBox.left = this.left;
  534. this.boundingBox.right = this.left + this.width;
  535. this.boundingBox.bottom = this.top + this.height;
  536. this._drawImageLabel(ctx);
  537. this.boundingBox.left = Math.min(this.boundingBox.left, this.labelDimensions.left);
  538. this.boundingBox.right = Math.max(this.boundingBox.right, this.labelDimensions.left + this.labelDimensions.width);
  539. this.boundingBox.bottom = Math.max(this.boundingBox.bottom, this.boundingBox.bottom + this.labelDimensions.height);
  540. };
  541. Node.prototype._resizeCircularImage = function (ctx) {
  542. if(!this.imageObj.src || !this.imageObj.width || !this.imageObj.height){
  543. if (!this.width) {
  544. var diameter = this.options.radius * 2;
  545. this.width = diameter;
  546. this.height = diameter;
  547. // scaling used for clustering
  548. //this.width += Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * 0.5 * this.clusterSizeWidthFactor;
  549. //this.height += Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * 0.5 * this.clusterSizeHeightFactor;
  550. this.options.radius += Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * 0.5 * this.clusterSizeRadiusFactor;
  551. this.growthIndicator = this.options.radius- 0.5*diameter;
  552. this._swapToImageResizeWhenImageLoaded = true;
  553. }
  554. }
  555. else {
  556. if (this._swapToImageResizeWhenImageLoaded) {
  557. this.width = 0;
  558. this.height = 0;
  559. delete this._swapToImageResizeWhenImageLoaded;
  560. }
  561. this._resizeImage(ctx);
  562. }
  563. };
  564. Node.prototype._drawCircularImage = function (ctx) {
  565. this._resizeCircularImage(ctx);
  566. this.left = this.x - this.width / 2;
  567. this.top = this.y - this.height / 2;
  568. var centerX = this.left + (this.width / 2);
  569. var centerY = this.top + (this.height / 2);
  570. var radius = Math.abs(this.height / 2);
  571. this._drawRawCircle(ctx, centerX, centerY, radius);
  572. ctx.save();
  573. ctx.circle(this.x, this.y, radius);
  574. ctx.stroke();
  575. ctx.clip();
  576. this._drawImageAtPosition(ctx);
  577. ctx.restore();
  578. this.boundingBox.top = this.y - this.options.radius;
  579. this.boundingBox.left = this.x - this.options.radius;
  580. this.boundingBox.right = this.x + this.options.radius;
  581. this.boundingBox.bottom = this.y + this.options.radius;
  582. this._drawImageLabel(ctx);
  583. this.boundingBox.left = Math.min(this.boundingBox.left, this.labelDimensions.left);
  584. this.boundingBox.right = Math.max(this.boundingBox.right, this.labelDimensions.left + this.labelDimensions.width);
  585. this.boundingBox.bottom = Math.max(this.boundingBox.bottom, this.boundingBox.bottom + this.labelDimensions.height);
  586. };
  587. Node.prototype._resizeBox = function (ctx) {
  588. if (!this.width) {
  589. var margin = 5;
  590. var textSize = this.getTextSize(ctx);
  591. this.width = textSize.width + 2 * margin;
  592. this.height = textSize.height + 2 * margin;
  593. this.width += Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * 0.5 * this.clusterSizeWidthFactor;
  594. this.height += Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * 0.5 * this.clusterSizeHeightFactor;
  595. this.growthIndicator = this.width - (textSize.width + 2 * margin);
  596. // this.options.radius+= Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * 0.5 * this.clusterSizeRadiusFactor;
  597. }
  598. };
  599. Node.prototype._drawBox = function (ctx) {
  600. this._resizeBox(ctx);
  601. this.left = this.x - this.width / 2;
  602. this.top = this.y - this.height / 2;
  603. var clusterLineWidth = 2.5;
  604. var borderWidth = this.options.borderWidth;
  605. var selectionLineWidth = this.options.borderWidthSelected || 2 * this.options.borderWidth;
  606. ctx.strokeStyle = this.selected ? this.options.color.highlight.border : this.hover ? this.options.color.hover.border : this.options.color.border;
  607. // draw the outer border
  608. if (this.clusterSize > 1) {
  609. ctx.lineWidth = (this.selected ? selectionLineWidth : borderWidth) + ((this.clusterSize > 1) ? clusterLineWidth : 0.0);
  610. ctx.lineWidth *= this.networkScaleInv;
  611. ctx.lineWidth = Math.min(this.width,ctx.lineWidth);
  612. ctx.roundRect(this.left-2*ctx.lineWidth, this.top-2*ctx.lineWidth, this.width+4*ctx.lineWidth, this.height+4*ctx.lineWidth, this.options.radius);
  613. ctx.stroke();
  614. }
  615. ctx.lineWidth = (this.selected ? selectionLineWidth : borderWidth) + ((this.clusterSize > 1) ? clusterLineWidth : 0.0);
  616. ctx.lineWidth *= this.networkScaleInv;
  617. ctx.lineWidth = Math.min(this.width,ctx.lineWidth);
  618. ctx.fillStyle = this.selected ? this.options.color.highlight.background : this.hover ? this.options.color.hover.background : this.options.color.background;
  619. ctx.roundRect(this.left, this.top, this.width, this.height, this.options.radius);
  620. ctx.fill();
  621. ctx.stroke();
  622. this.boundingBox.top = this.top;
  623. this.boundingBox.left = this.left;
  624. this.boundingBox.right = this.left + this.width;
  625. this.boundingBox.bottom = this.top + this.height;
  626. this._label(ctx, this.label, this.x, this.y);
  627. };
  628. Node.prototype._resizeDatabase = function (ctx) {
  629. if (!this.width) {
  630. var margin = 5;
  631. var textSize = this.getTextSize(ctx);
  632. var size = textSize.width + 2 * margin;
  633. this.width = size;
  634. this.height = size;
  635. // scaling used for clustering
  636. this.width += Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * this.clusterSizeWidthFactor;
  637. this.height += Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * this.clusterSizeHeightFactor;
  638. this.options.radius+= Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * this.clusterSizeRadiusFactor;
  639. this.growthIndicator = this.width - size;
  640. }
  641. };
  642. Node.prototype._drawDatabase = function (ctx) {
  643. this._resizeDatabase(ctx);
  644. this.left = this.x - this.width / 2;
  645. this.top = this.y - this.height / 2;
  646. var clusterLineWidth = 2.5;
  647. var borderWidth = this.options.borderWidth;
  648. var selectionLineWidth = this.options.borderWidthSelected || 2 * this.options.borderWidth;
  649. ctx.strokeStyle = this.selected ? this.options.color.highlight.border : this.hover ? this.options.color.hover.border : this.options.color.border;
  650. // draw the outer border
  651. if (this.clusterSize > 1) {
  652. ctx.lineWidth = (this.selected ? selectionLineWidth : borderWidth) + ((this.clusterSize > 1) ? clusterLineWidth : 0.0);
  653. ctx.lineWidth *= this.networkScaleInv;
  654. ctx.lineWidth = Math.min(this.width,ctx.lineWidth);
  655. ctx.database(this.x - this.width/2 - 2*ctx.lineWidth, this.y - this.height*0.5 - 2*ctx.lineWidth, this.width + 4*ctx.lineWidth, this.height + 4*ctx.lineWidth);
  656. ctx.stroke();
  657. }
  658. ctx.lineWidth = (this.selected ? selectionLineWidth : borderWidth) + ((this.clusterSize > 1) ? clusterLineWidth : 0.0);
  659. ctx.lineWidth *= this.networkScaleInv;
  660. ctx.lineWidth = Math.min(this.width,ctx.lineWidth);
  661. ctx.fillStyle = this.selected ? this.options.color.highlight.background : this.hover ? this.options.color.hover.background : this.options.color.background;
  662. ctx.database(this.x - this.width/2, this.y - this.height*0.5, this.width, this.height);
  663. ctx.fill();
  664. ctx.stroke();
  665. this.boundingBox.top = this.top;
  666. this.boundingBox.left = this.left;
  667. this.boundingBox.right = this.left + this.width;
  668. this.boundingBox.bottom = this.top + this.height;
  669. this._label(ctx, this.label, this.x, this.y);
  670. };
  671. Node.prototype._resizeCircle = function (ctx) {
  672. if (!this.width) {
  673. var margin = 5;
  674. var textSize = this.getTextSize(ctx);
  675. var diameter = Math.max(textSize.width, textSize.height) + 2 * margin;
  676. this.options.radius = diameter / 2;
  677. this.width = diameter;
  678. this.height = diameter;
  679. // scaling used for clustering
  680. // this.width += Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * 0.5 * this.clusterSizeWidthFactor;
  681. // this.height += Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * 0.5 * this.clusterSizeHeightFactor;
  682. this.options.radius += Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * 0.5 * this.clusterSizeRadiusFactor;
  683. this.growthIndicator = this.options.radius- 0.5*diameter;
  684. }
  685. };
  686. Node.prototype._drawRawCircle = function (ctx, x, y, radius) {
  687. var clusterLineWidth = 2.5;
  688. var borderWidth = this.options.borderWidth;
  689. var selectionLineWidth = this.options.borderWidthSelected || 2 * this.options.borderWidth;
  690. ctx.strokeStyle = this.selected ? this.options.color.highlight.border : this.hover ? this.options.color.hover.border : this.options.color.border;
  691. // draw the outer border
  692. if (this.clusterSize > 1) {
  693. ctx.lineWidth = (this.selected ? selectionLineWidth : borderWidth) + ((this.clusterSize > 1) ? clusterLineWidth : 0.0);
  694. ctx.lineWidth *= this.networkScaleInv;
  695. ctx.lineWidth = Math.min(this.width,ctx.lineWidth);
  696. ctx.circle(x, y, radius+2*ctx.lineWidth);
  697. ctx.stroke();
  698. }
  699. ctx.lineWidth = (this.selected ? selectionLineWidth : borderWidth) + ((this.clusterSize > 1) ? clusterLineWidth : 0.0);
  700. ctx.lineWidth *= this.networkScaleInv;
  701. ctx.lineWidth = Math.min(this.width,ctx.lineWidth);
  702. ctx.fillStyle = this.selected ? this.options.color.highlight.background : this.hover ? this.options.color.hover.background : this.options.color.background;
  703. ctx.circle(this.x, this.y, radius);
  704. ctx.fill();
  705. ctx.stroke();
  706. };
  707. Node.prototype._drawCircle = function (ctx) {
  708. this._resizeCircle(ctx);
  709. this.left = this.x - this.width / 2;
  710. this.top = this.y - this.height / 2;
  711. this._drawRawCircle(ctx, this.x, this.y, this.options.radius);
  712. this.boundingBox.top = this.y - this.options.radius;
  713. this.boundingBox.left = this.x - this.options.radius;
  714. this.boundingBox.right = this.x + this.options.radius;
  715. this.boundingBox.bottom = this.y + this.options.radius;
  716. this._label(ctx, this.label, this.x, this.y);
  717. };
  718. Node.prototype._resizeEllipse = function (ctx) {
  719. if (!this.width) {
  720. var textSize = this.getTextSize(ctx);
  721. this.width = textSize.width * 1.5;
  722. this.height = textSize.height * 2;
  723. if (this.width < this.height) {
  724. this.width = this.height;
  725. }
  726. var defaultSize = this.width;
  727. // scaling used for clustering
  728. this.width += Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * this.clusterSizeWidthFactor;
  729. this.height += Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * this.clusterSizeHeightFactor;
  730. this.options.radius += Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * this.clusterSizeRadiusFactor;
  731. this.growthIndicator = this.width - defaultSize;
  732. }
  733. };
  734. Node.prototype._drawEllipse = function (ctx) {
  735. this._resizeEllipse(ctx);
  736. this.left = this.x - this.width / 2;
  737. this.top = this.y - this.height / 2;
  738. var clusterLineWidth = 2.5;
  739. var borderWidth = this.options.borderWidth;
  740. var selectionLineWidth = this.options.borderWidthSelected || 2 * this.options.borderWidth;
  741. ctx.strokeStyle = this.selected ? this.options.color.highlight.border : this.hover ? this.options.color.hover.border : this.options.color.border;
  742. // draw the outer border
  743. if (this.clusterSize > 1) {
  744. ctx.lineWidth = (this.selected ? selectionLineWidth : borderWidth) + ((this.clusterSize > 1) ? clusterLineWidth : 0.0);
  745. ctx.lineWidth *= this.networkScaleInv;
  746. ctx.lineWidth = Math.min(this.width,ctx.lineWidth);
  747. ctx.ellipse(this.left-2*ctx.lineWidth, this.top-2*ctx.lineWidth, this.width+4*ctx.lineWidth, this.height+4*ctx.lineWidth);
  748. ctx.stroke();
  749. }
  750. ctx.lineWidth = (this.selected ? selectionLineWidth : borderWidth) + ((this.clusterSize > 1) ? clusterLineWidth : 0.0);
  751. ctx.lineWidth *= this.networkScaleInv;
  752. ctx.lineWidth = Math.min(this.width,ctx.lineWidth);
  753. ctx.fillStyle = this.selected ? this.options.color.highlight.background : this.hover ? this.options.color.hover.background : this.options.color.background;
  754. ctx.ellipse(this.left, this.top, this.width, this.height);
  755. ctx.fill();
  756. ctx.stroke();
  757. this.boundingBox.top = this.top;
  758. this.boundingBox.left = this.left;
  759. this.boundingBox.right = this.left + this.width;
  760. this.boundingBox.bottom = this.top + this.height;
  761. this._label(ctx, this.label, this.x, this.y);
  762. };
  763. Node.prototype._drawDot = function (ctx) {
  764. this._drawShape(ctx, 'circle');
  765. };
  766. Node.prototype._drawTriangle = function (ctx) {
  767. this._drawShape(ctx, 'triangle');
  768. };
  769. Node.prototype._drawTriangleDown = function (ctx) {
  770. this._drawShape(ctx, 'triangleDown');
  771. };
  772. Node.prototype._drawSquare = function (ctx) {
  773. this._drawShape(ctx, 'square');
  774. };
  775. Node.prototype._drawStar = function (ctx) {
  776. this._drawShape(ctx, 'star');
  777. };
  778. Node.prototype._resizeShape = function (ctx) {
  779. if (!this.width) {
  780. this.options.radius= this.baseRadiusValue;
  781. var size = 2 * this.options.radius;
  782. this.width = size;
  783. this.height = size;
  784. // scaling used for clustering
  785. this.width += Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * this.clusterSizeWidthFactor;
  786. this.height += Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * this.clusterSizeHeightFactor;
  787. this.options.radius+= Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * 0.5 * this.clusterSizeRadiusFactor;
  788. this.growthIndicator = this.width - size;
  789. }
  790. };
  791. Node.prototype._drawShape = function (ctx, shape) {
  792. this._resizeShape(ctx);
  793. this.left = this.x - this.width / 2;
  794. this.top = this.y - this.height / 2;
  795. var clusterLineWidth = 2.5;
  796. var borderWidth = this.options.borderWidth;
  797. var selectionLineWidth = this.options.borderWidthSelected || 2 * this.options.borderWidth;
  798. var radiusMultiplier = 2;
  799. // choose draw method depending on the shape
  800. switch (shape) {
  801. case 'dot': radiusMultiplier = 2; break;
  802. case 'square': radiusMultiplier = 2; break;
  803. case 'triangle': radiusMultiplier = 3; break;
  804. case 'triangleDown': radiusMultiplier = 3; break;
  805. case 'star': radiusMultiplier = 4; break;
  806. }
  807. ctx.strokeStyle = this.selected ? this.options.color.highlight.border : this.hover ? this.options.color.hover.border : this.options.color.border;
  808. // draw the outer border
  809. if (this.clusterSize > 1) {
  810. ctx.lineWidth = (this.selected ? selectionLineWidth : borderWidth) + ((this.clusterSize > 1) ? clusterLineWidth : 0.0);
  811. ctx.lineWidth *= this.networkScaleInv;
  812. ctx.lineWidth = Math.min(this.width,ctx.lineWidth);
  813. ctx[shape](this.x, this.y, this.options.radius+ radiusMultiplier * ctx.lineWidth);
  814. ctx.stroke();
  815. }
  816. ctx.lineWidth = (this.selected ? selectionLineWidth : borderWidth) + ((this.clusterSize > 1) ? clusterLineWidth : 0.0);
  817. ctx.lineWidth *= this.networkScaleInv;
  818. ctx.lineWidth = Math.min(this.width,ctx.lineWidth);
  819. ctx.fillStyle = this.selected ? this.options.color.highlight.background : this.hover ? this.options.color.hover.background : this.options.color.background;
  820. ctx[shape](this.x, this.y, this.options.radius);
  821. ctx.fill();
  822. ctx.stroke();
  823. this.boundingBox.top = this.y - this.options.radius;
  824. this.boundingBox.left = this.x - this.options.radius;
  825. this.boundingBox.right = this.x + this.options.radius;
  826. this.boundingBox.bottom = this.y + this.options.radius;
  827. if (this.label) {
  828. this._label(ctx, this.label, this.x, this.y + this.height / 2, undefined, 'hanging',true);
  829. this.boundingBox.left = Math.min(this.boundingBox.left, this.labelDimensions.left);
  830. this.boundingBox.right = Math.max(this.boundingBox.right, this.labelDimensions.left + this.labelDimensions.width);
  831. this.boundingBox.bottom = Math.max(this.boundingBox.bottom, this.boundingBox.bottom + this.labelDimensions.height);
  832. }
  833. };
  834. Node.prototype._resizeText = function (ctx) {
  835. if (!this.width) {
  836. var margin = 5;
  837. var textSize = this.getTextSize(ctx);
  838. this.width = textSize.width + 2 * margin;
  839. this.height = textSize.height + 2 * margin;
  840. // scaling used for clustering
  841. this.width += Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * this.clusterSizeWidthFactor;
  842. this.height += Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * this.clusterSizeHeightFactor;
  843. this.options.radius+= Math.min(this.clusterSize - 1, this.maxNodeSizeIncrements) * this.clusterSizeRadiusFactor;
  844. this.growthIndicator = this.width - (textSize.width + 2 * margin);
  845. }
  846. };
  847. Node.prototype._drawText = function (ctx) {
  848. this._resizeText(ctx);
  849. this.left = this.x - this.width / 2;
  850. this.top = this.y - this.height / 2;
  851. this._label(ctx, this.label, this.x, this.y);
  852. this.boundingBox.top = this.top;
  853. this.boundingBox.left = this.left;
  854. this.boundingBox.right = this.left + this.width;
  855. this.boundingBox.bottom = this.top + this.height;
  856. };
  857. Node.prototype._label = function (ctx, text, x, y, align, baseline, labelUnderNode) {
  858. var relativeFontSize = Number(this.options.fontSize) * this.networkScale;
  859. if (text && relativeFontSize >= this.options.fontDrawThreshold - 1) {
  860. var fontSize = Number(this.options.fontSize);
  861. // this ensures that there will not be HUGE letters on screen by setting an upper limit on the visible text size (regardless of zoomLevel)
  862. if (relativeFontSize >= this.options.fontSizeMaxVisible) {
  863. fontSize = Number(this.options.fontSizeMaxVisible) * this.networkScaleInv;
  864. }
  865. // fade in when relative scale is between threshold and threshold - 1
  866. var fontColor = this.options.fontColor || "#000000";
  867. var strokecolor = this.options.fontStrokeColor;
  868. if (relativeFontSize <= this.options.fontDrawThreshold) {
  869. var opacity = Math.max(0,Math.min(1,1 - (this.options.fontDrawThreshold - relativeFontSize)));
  870. fontColor = util.overrideOpacity(fontColor, opacity);
  871. strokecolor = util.overrideOpacity(strokecolor, opacity);
  872. }
  873. ctx.font = (this.selected ? "bold " : "") + fontSize + "px " + this.options.fontFace;
  874. var lines = text.split('\n');
  875. var lineCount = lines.length;
  876. var yLine = y + (1 - lineCount) / 2 * fontSize;
  877. if (labelUnderNode == true) {
  878. yLine = y + (1 - lineCount) / (2 * fontSize);
  879. }
  880. // font fill from edges now for nodes!
  881. var width = ctx.measureText(lines[0]).width;
  882. for (var i = 1; i < lineCount; i++) {
  883. var lineWidth = ctx.measureText(lines[i]).width;
  884. width = lineWidth > width ? lineWidth : width;
  885. }
  886. var height = fontSize * lineCount;
  887. var left = x - width / 2;
  888. var top = y - height / 2;
  889. if (baseline == "hanging") {
  890. top += 0.5 * fontSize;
  891. top += 4; // distance from node, required because we use hanging. Hanging has less difference between browsers
  892. yLine += 4; // distance from node
  893. }
  894. this.labelDimensions = {top:top,left:left,width:width,height:height,yLine:yLine};
  895. // create the fontfill background
  896. if (this.options.fontFill !== undefined && this.options.fontFill !== null && this.options.fontFill !== "none") {
  897. ctx.fillStyle = this.options.fontFill;
  898. ctx.fillRect(left, top, width, height);
  899. }
  900. // draw text
  901. ctx.fillStyle = fontColor;
  902. ctx.textAlign = align || "center";
  903. ctx.textBaseline = baseline || "middle";
  904. if (this.options.fontStrokeWidth > 0){
  905. ctx.lineWidth = this.options.fontStrokeWidth;
  906. ctx.strokeStyle = strokecolor;
  907. ctx.lineJoin = 'round';
  908. }
  909. for (var i = 0; i < lineCount; i++) {
  910. if(this.options.fontStrokeWidth){
  911. ctx.strokeText(lines[i], x, yLine);
  912. }
  913. ctx.fillText(lines[i], x, yLine);
  914. yLine += fontSize;
  915. }
  916. }
  917. };
  918. Node.prototype.getTextSize = function(ctx) {
  919. if (this.label !== undefined) {
  920. var fontSize = Number(this.options.fontSize);
  921. if (fontSize * this.networkScale > this.options.fontSizeMaxVisible) {
  922. fontSize = Number(this.options.fontSizeMaxVisible) * this.networkScaleInv;
  923. }
  924. ctx.font = (this.selected ? "bold " : "") + fontSize + "px " + this.options.fontFace;
  925. var lines = this.label.split('\n'),
  926. height = (fontSize + 4) * lines.length,
  927. width = 0;
  928. for (var i = 0, iMax = lines.length; i < iMax; i++) {
  929. width = Math.max(width, ctx.measureText(lines[i]).width);
  930. }
  931. return {"width": width, "height": height, lineCount: lines.length};
  932. }
  933. else {
  934. return {"width": 0, "height": 0, lineCount: 0};
  935. }
  936. };
  937. /**
  938. * this is used to determine if a node is visible at all. this is used to determine when it needs to be drawn.
  939. * there is a safety margin of 0.3 * width;
  940. *
  941. * @returns {boolean}
  942. */
  943. Node.prototype.inArea = function() {
  944. if (this.width !== undefined) {
  945. return (this.x + this.width *this.networkScaleInv >= this.canvasTopLeft.x &&
  946. this.x - this.width *this.networkScaleInv < this.canvasBottomRight.x &&
  947. this.y + this.height*this.networkScaleInv >= this.canvasTopLeft.y &&
  948. this.y - this.height*this.networkScaleInv < this.canvasBottomRight.y);
  949. }
  950. else {
  951. return true;
  952. }
  953. };
  954. /**
  955. * checks if the core of the node is in the display area, this is used for opening clusters around zoom
  956. * @returns {boolean}
  957. */
  958. Node.prototype.inView = function() {
  959. return (this.x >= this.canvasTopLeft.x &&
  960. this.x < this.canvasBottomRight.x &&
  961. this.y >= this.canvasTopLeft.y &&
  962. this.y < this.canvasBottomRight.y);
  963. };
  964. /**
  965. * This allows the zoom level of the network to influence the rendering
  966. * We store the inverted scale and the coordinates of the top left, and bottom right points of the canvas
  967. *
  968. * @param scale
  969. * @param canvasTopLeft
  970. * @param canvasBottomRight
  971. */
  972. Node.prototype.setScaleAndPos = function(scale,canvasTopLeft,canvasBottomRight) {
  973. this.networkScaleInv = 1.0/scale;
  974. this.networkScale = scale;
  975. this.canvasTopLeft = canvasTopLeft;
  976. this.canvasBottomRight = canvasBottomRight;
  977. };
  978. /**
  979. * This allows the zoom level of the network to influence the rendering
  980. *
  981. * @param scale
  982. */
  983. Node.prototype.setScale = function(scale) {
  984. this.networkScaleInv = 1.0/scale;
  985. this.networkScale = scale;
  986. };
  987. /**
  988. * set the velocity at 0. Is called when this node is contained in another during clustering
  989. */
  990. Node.prototype.clearVelocity = function() {
  991. this.vx = 0;
  992. this.vy = 0;
  993. };
  994. /**
  995. * Basic preservation of (kinectic) energy
  996. *
  997. * @param massBeforeClustering
  998. */
  999. Node.prototype.updateVelocity = function(massBeforeClustering) {
  1000. var energyBefore = this.vx * this.vx * massBeforeClustering;
  1001. //this.vx = (this.vx < 0) ? -Math.sqrt(energyBefore/this.options.mass) : Math.sqrt(energyBefore/this.options.mass);
  1002. this.vx = Math.sqrt(energyBefore/this.options.mass);
  1003. energyBefore = this.vy * this.vy * massBeforeClustering;
  1004. //this.vy = (this.vy < 0) ? -Math.sqrt(energyBefore/this.options.mass) : Math.sqrt(energyBefore/this.options.mass);
  1005. this.vy = Math.sqrt(energyBefore/this.options.mass);
  1006. };
  1007. module.exports = Node;