NodeHook.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import {Circle} from "../Circle";
  2. import {Node} from "./Node";
  3. /**
  4. * Represents a node hook point. Is attached to the node element and represented visually.
  5. *
  6. * Can be used as a node input, output or as a bidirectional connection.
  7. *
  8. * @class NodeHook
  9. * @param {Node} node Node of this hook.
  10. * @param {number} direction Direction of the hook.
  11. */
  12. function NodeHook(node, direction)
  13. {
  14. Circle.call(this);
  15. /**
  16. * If set true the hook can be connected to multiple hooks.
  17. *
  18. * @type {boolean}
  19. */
  20. this.multiple = false;
  21. /**
  22. * Direction of the node hook.
  23. *
  24. * @type {number}
  25. */
  26. this.direction = direction;
  27. /**
  28. * Type of hook. Hooks of the same type can be connected.
  29. *
  30. * @type {string}
  31. */
  32. this.type = "";
  33. /**
  34. * Node where this input element in attached.
  35. *
  36. * @type {Node}
  37. */
  38. this.node = node;
  39. }
  40. /**
  41. * Input hook can only be connected to an output.
  42. *
  43. * Is used to read data from the output.
  44. *
  45. * @type {number}
  46. */
  47. NodeHook.INPUT = 1;
  48. /**
  49. * Output hook can only be connected to an input.
  50. *
  51. * Writes data to the output.
  52. *
  53. * @type {number}
  54. */
  55. NodeHook.OUTPUT = 2;
  56. /**
  57. * Bidirectional hook can be connected to any type of hook.
  58. *
  59. * Can be used to write and read from inputs and/or outputs.
  60. *
  61. * @type {number}
  62. */
  63. NodeHook.BIDIRECTIONAL = 3;
  64. NodeHook.prototype = Object.create(Circle.prototype);
  65. export {NodeHook};