actionsbuilder.actionNode.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. module ActionsBuilder {
  2. export class Node {
  3. public rect: Rect = null;
  4. public text: Text = null;
  5. public line: Path = null;
  6. public detached: boolean = false;
  7. public minimized: boolean = false;
  8. constructor()
  9. { }
  10. /**
  11. * Returns if the point (x, y) is inside the text or rect
  12. * @param x: the x position of the point
  13. * @param y: the y position of the point
  14. */
  15. public isPointInside(x: number, y: number): boolean {
  16. return this.rect.isPointInside(x, y) || this.text.isPointInside(x, y);
  17. }
  18. }
  19. export class Action {
  20. public node: Node;
  21. public parent: Action = null;
  22. public children: Array<Action> = new Array<Action>();
  23. public name: string = "";
  24. public type: number = Type.OBJECT;
  25. public properties: Array<ElementProperty> = new Array<ElementProperty>();
  26. public propertiesResults: Array<ElementPropertyResult> = new Array<ElementPropertyResult>();
  27. public combineArray: Array<Action> = null;
  28. public hub: Action = null;
  29. public combineAction: Action = null;
  30. /**
  31. * Constructor
  32. * @param node: The associated node to draw in the viewer
  33. */
  34. constructor(node: Node) {
  35. this.node = node;
  36. }
  37. /*
  38. * Removes a combined action from the combine array
  39. * @param action: the action to remove
  40. */
  41. public removeCombinedAction(action: Action): boolean {
  42. if (action === null || this.combineArray === null) {
  43. return false;
  44. }
  45. var index = this.combineArray.indexOf(action);
  46. if (index !== -1) {
  47. this.combineArray.splice(index, 1);
  48. }
  49. return false;
  50. }
  51. /*
  52. * Adds a child
  53. * @param child: the action to add as child
  54. */
  55. public addChild(child: Action): boolean {
  56. if (child === null) {
  57. return false;
  58. }
  59. this.children.push(child);
  60. child.parent = this;
  61. return true;
  62. }
  63. /*
  64. * Removes the given action to children
  65. * @param child: the child to remove
  66. */
  67. public removeChild(child: Action): boolean {
  68. var indice = this.children.indexOf(child);
  69. if (indice !== -1) {
  70. this.children.splice(indice, 1);
  71. return true;
  72. }
  73. return false;
  74. }
  75. /*
  76. * Clears the children's array
  77. */
  78. public clearChildren(): void {
  79. this.children = new Array<Action>();
  80. }
  81. }
  82. }