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.

49 lines
1.4 KiB

  1. 'use strict';
  2. import NodeBase from '../util/NodeBase'
  3. /**
  4. * A Database Node/Cluster shape.
  5. *
  6. * @param {Object} options
  7. * @param {Object} body
  8. * @param {Label} labelModule
  9. * @constructor Database
  10. * @extends NodeBase
  11. */
  12. class Database extends NodeBase {
  13. constructor (options, body, labelModule) {
  14. super(options, body, labelModule);
  15. this._setMargins(labelModule);
  16. }
  17. resize(ctx, selected, hover) {
  18. if (this.needsRefresh(selected, hover)) {
  19. this.textSize = this.labelModule.getTextSize(ctx, selected, hover);
  20. var size = this.textSize.width + this.margin.right + this.margin.left;
  21. this.width = size;
  22. this.height = size;
  23. this.radius = this.width / 2;
  24. }
  25. }
  26. draw(ctx, x, y, selected, hover, values) {
  27. this.resize(ctx, selected, hover);
  28. this.left = x - this.width / 2;
  29. this.top = y - this.height / 2;
  30. this.initContextForDraw(ctx, values);
  31. ctx.database(x - this.width / 2, y - this.height / 2, this.width, this.height);
  32. this.performFill(ctx, values);
  33. this.updateBoundingBox(x, y, ctx, selected, hover);
  34. this.labelModule.draw(ctx, this.left + this.textSize.width / 2 + this.margin.left,
  35. this.top + this.textSize.height / 2 + this.margin.top, selected, hover);
  36. }
  37. distanceToBorder(ctx, angle) {
  38. return this._distanceToBorder(ctx,angle);
  39. }
  40. }
  41. export default Database;