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.

41 lines
1.0 KiB

  1. class NodeBase {
  2. constructor(options, body, labelModule) {
  3. this.body = body;
  4. this.labelModule = labelModule;
  5. this.setOptions(options);
  6. this.top = undefined;
  7. this.left = undefined;
  8. this.height = undefined;
  9. this.boundingBox = {top: 0, left: 0, right: 0, bottom: 0};
  10. }
  11. setOptions(options) {
  12. this.options = options;
  13. }
  14. _distanceToBorder(angle) {
  15. var borderWidth = 1;
  16. return Math.min(
  17. Math.abs(this.width / 2 / Math.cos(angle)),
  18. Math.abs(this.height / 2 / Math.sin(angle))) + borderWidth;
  19. }
  20. enableShadow(ctx) {
  21. if (this.options.shadow.enabled === true) {
  22. ctx.shadowColor = 'rgba(0,0,0,0.5)';
  23. ctx.shadowBlur = this.options.shadow.size;
  24. ctx.shadowOffsetX = this.options.shadow.x;
  25. ctx.shadowOffsetY = this.options.shadow.y;
  26. }
  27. }
  28. disableShadow(ctx) {
  29. if (this.options.shadow.enabled === true) {
  30. ctx.shadowColor = 'rgba(0,0,0,0)';
  31. ctx.shadowBlur = 0;
  32. ctx.shadowOffsetX = 0;
  33. ctx.shadowOffsetY = 0;
  34. }
  35. }
  36. }
  37. export default NodeBase;