action.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /// <reference path="raphael.js" />
  2. /// <reference path="viewer.js" />
  3. /// <reference path="actionKinds.js" />
  4. var AB;
  5. (function (AB) {
  6. var Node = (function () {
  7. function Node() {
  8. // Members
  9. this.rect = null;
  10. this.text = null;
  11. this.line = null;
  12. this.action = null;
  13. this.detached = false;
  14. this.minimized = false;
  15. }
  16. // Get node's object attribute
  17. // element: The element to get the attribute
  18. // attribute: the attribute name "text, "width", etc.
  19. // value: optional, if not reading mode but writing mode
  20. Node.prototype.attr = function(element, attribute, value) {
  21. if (value)
  22. element.attr(attribute, value);
  23. else
  24. return element.attr(attribute);
  25. }
  26. // Returns the point at (x, y) is inside the node
  27. // x: the x position of the point
  28. // y: the y position of the point
  29. Node.prototype.isPointInside = function (x, y) {
  30. return this.rect.isPointInside(x, y) || this.text.isPointInside(x, y);
  31. }
  32. return Node;
  33. })();
  34. var Action = (function() {
  35. function Action(node) {
  36. // Graph related
  37. this.parent = null;
  38. this.children = new Array();
  39. this.node = node;
  40. // Action
  41. this.name = "";
  42. this.type = AB.ActionsBuilder.Type.OBJECT;
  43. this.propertiesResults = new Array();
  44. this.properties = new Array();
  45. // Extra
  46. this.combine = false;
  47. this.combineArray = new Array();
  48. this.hub = null;
  49. }
  50. // Adds a child to the action
  51. // object: the child
  52. Action.prototype.addChild = function (object) {
  53. if (object == null)
  54. return false;
  55. this.children.push(object);
  56. object.parent = this;
  57. return true;
  58. }
  59. // Removes a child from the action
  60. // object: the child to remove
  61. Action.prototype.removeChild = function (object) {
  62. var indice = this.children.indexOf(object);
  63. if (indice != -1) {
  64. this.children.splice(indice, 1);
  65. return true;
  66. }
  67. return false;
  68. }
  69. // Clears all the children of the action
  70. Action.prototype.clearChildren = function () {
  71. this.children = new Array();
  72. }
  73. return Action;
  74. })();
  75. AB.Action = Action;
  76. AB.Node = Node;
  77. })(AB || (AB = { }));