JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / bin / jalview / datamodel / BinaryNode.js
1 Clazz.declarePackage ("jalview.datamodel");\r
2 c$ = Clazz.decorateAsClass (function () {\r
3 this.$element = null;\r
4 this.name = null;\r
5 this.$left = null;\r
6 this.$right = null;\r
7 this.$parent = null;\r
8 this.bootstrap = 0;\r
9 Clazz.instantialize (this, arguments);\r
10 }, jalview.datamodel, "BinaryNode");\r
11 Clazz.makeConstructor (c$, \r
12 function () {\r
13 this.$left = this.$right = this.$parent = null;\r
14 this.bootstrap = 0;\r
15 });\r
16 Clazz.makeConstructor (c$, \r
17 function (element, parent, name) {\r
18 this.$element = element;\r
19 this.$parent = parent;\r
20 this.name = name;\r
21 this.$left = this.$right = null;\r
22 }, "~O,jalview.datamodel.BinaryNode,~S");\r
23 Clazz.defineMethod (c$, "element", \r
24 function () {\r
25 return this.$element;\r
26 });\r
27 Clazz.defineMethod (c$, "setElement", \r
28 function (v) {\r
29 return this.$element = v;\r
30 }, "~O");\r
31 Clazz.defineMethod (c$, "left", \r
32 function () {\r
33 return this.$left;\r
34 });\r
35 Clazz.defineMethod (c$, "setLeft", \r
36 function (n) {\r
37 return this.$left = n;\r
38 }, "jalview.datamodel.BinaryNode");\r
39 Clazz.defineMethod (c$, "right", \r
40 function () {\r
41 return this.$right;\r
42 });\r
43 Clazz.defineMethod (c$, "setRight", \r
44 function (n) {\r
45 return this.$right = n;\r
46 }, "jalview.datamodel.BinaryNode");\r
47 Clazz.defineMethod (c$, "parent", \r
48 function () {\r
49 return this.$parent;\r
50 });\r
51 Clazz.defineMethod (c$, "setParent", \r
52 function (n) {\r
53 return this.$parent = n;\r
54 }, "jalview.datamodel.BinaryNode");\r
55 Clazz.defineMethod (c$, "isLeaf", \r
56 function () {\r
57 return (this.$left == null) && (this.$right == null);\r
58 });\r
59 Clazz.defineMethod (c$, "SetChildren", \r
60 function (leftchild, rightchild) {\r
61 if (leftchild != null) {\r
62 this.setLeft (leftchild);\r
63 leftchild.detach ();\r
64 leftchild.setParent (this);\r
65 }if (rightchild != null) {\r
66 this.setRight (rightchild);\r
67 rightchild.detach ();\r
68 rightchild.setParent (this);\r
69 }}, "jalview.datamodel.BinaryNode,jalview.datamodel.BinaryNode");\r
70 Clazz.defineMethod (c$, "detach", \r
71 function () {\r
72 if (this.$parent != null) {\r
73 if (this.$parent.$left === this) {\r
74 this.$parent.$left = null;\r
75 } else {\r
76 if (this.$parent.$right === this) {\r
77 this.$parent.$right = null;\r
78 }}}this.$parent = null;\r
79 return this;\r
80 });\r
81 Clazz.defineMethod (c$, "ascendLeft", \r
82 function () {\r
83 var c = this;\r
84 do {\r
85 c = c.parent ();\r
86 } while ((c != null) && (c.left () != null) && !c.left ().isLeaf ());\r
87 return c;\r
88 });\r
89 Clazz.defineMethod (c$, "ascendRight", \r
90 function () {\r
91 var c = this;\r
92 do {\r
93 c = c.parent ();\r
94 } while ((c != null) && (c.right () != null) && !c.right ().isLeaf ());\r
95 return c;\r
96 });\r
97 Clazz.defineMethod (c$, "setName", \r
98 function (name) {\r
99 this.name = name;\r
100 }, "~S");\r
101 Clazz.defineMethod (c$, "getName", \r
102 function () {\r
103 return this.name;\r
104 });\r
105 Clazz.defineMethod (c$, "setBootstrap", \r
106 function (boot) {\r
107 this.bootstrap = boot;\r
108 }, "~N");\r
109 Clazz.defineMethod (c$, "getBootstrap", \r
110 function () {\r
111 return this.bootstrap;\r
112 });\r