01026513428dce0bf216c14dbef84f531cc07561
[jalviewjs.git] / site / j2s / javax / swing / tree / DefaultMutableTreeNode.js
1 Clazz.declarePackage ("javax.swing.tree");\r
2 Clazz.load (["java.util.Enumeration", "javax.swing.tree.MutableTreeNode", "java.util.NoSuchElementException"], "javax.swing.tree.DefaultMutableTreeNode", ["java.lang.ArrayIndexOutOfBoundsException", "$.Error", "$.IllegalArgumentException", "$.IllegalStateException", "java.util.Stack", "$.Vector"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.parent = null;\r
5 this.$children = null;\r
6 this.userObject = null;\r
7 this.allowsChildren = false;\r
8 if (!Clazz.isClassDefined ("javax.swing.tree.DefaultMutableTreeNode.PreorderEnumeration")) {\r
9 javax.swing.tree.DefaultMutableTreeNode.$DefaultMutableTreeNode$PreorderEnumeration$ ();\r
10 }\r
11 if (!Clazz.isClassDefined ("javax.swing.tree.DefaultMutableTreeNode.PostorderEnumeration")) {\r
12 javax.swing.tree.DefaultMutableTreeNode.$DefaultMutableTreeNode$PostorderEnumeration$ ();\r
13 }\r
14 if (!Clazz.isClassDefined ("javax.swing.tree.DefaultMutableTreeNode.BreadthFirstEnumeration")) {\r
15 javax.swing.tree.DefaultMutableTreeNode.$DefaultMutableTreeNode$BreadthFirstEnumeration$ ();\r
16 }\r
17 if (!Clazz.isClassDefined ("javax.swing.tree.DefaultMutableTreeNode.PathBetweenNodesEnumeration")) {\r
18 javax.swing.tree.DefaultMutableTreeNode.$DefaultMutableTreeNode$PathBetweenNodesEnumeration$ ();\r
19 }\r
20 Clazz.instantialize (this, arguments);\r
21 }, javax.swing.tree, "DefaultMutableTreeNode", null, [Cloneable, javax.swing.tree.MutableTreeNode]);\r
22 Clazz.makeConstructor (c$, \r
23 function () {\r
24 this.construct (null);\r
25 });\r
26 Clazz.makeConstructor (c$, \r
27 function (userObject) {\r
28 this.construct (userObject, true);\r
29 }, "~O");\r
30 Clazz.makeConstructor (c$, \r
31 function (userObject, allowsChildren) {\r
32 this.parent = null;\r
33 this.allowsChildren = allowsChildren;\r
34 this.userObject = userObject;\r
35 }, "~O,~B");\r
36 Clazz.overrideMethod (c$, "insert", \r
37 function (newChild, childIndex) {\r
38 if (!this.allowsChildren) {\r
39 throw  new IllegalStateException ("node does not allow children");\r
40 } else if (newChild == null) {\r
41 throw  new IllegalArgumentException ("new child is null");\r
42 } else if (this.isNodeAncestor (newChild)) {\r
43 throw  new IllegalArgumentException ("new child is an ancestor");\r
44 }var oldParent = newChild.getParent ();\r
45 if (oldParent != null) {\r
46 oldParent.remove (newChild);\r
47 }newChild.setParent (this);\r
48 if (this.$children == null) {\r
49 this.$children =  new java.util.Vector ();\r
50 }this.$children.insertElementAt (newChild, childIndex);\r
51 }, "javax.swing.tree.MutableTreeNode,~N");\r
52 Clazz.defineMethod (c$, "remove", \r
53 function (childIndex) {\r
54 var child = this.getChildAt (childIndex);\r
55 this.$children.removeElementAt (childIndex);\r
56 child.setParent (null);\r
57 }, "~N");\r
58 Clazz.defineMethod (c$, "setParent", \r
59 function (newParent) {\r
60 this.parent = newParent;\r
61 }, "javax.swing.tree.MutableTreeNode");\r
62 Clazz.defineMethod (c$, "getParent", \r
63 function () {\r
64 return this.parent;\r
65 });\r
66 Clazz.overrideMethod (c$, "getChildAt", \r
67 function (index) {\r
68 if (this.$children == null) {\r
69 throw  new ArrayIndexOutOfBoundsException ("node has no children");\r
70 }return this.$children.elementAt (index);\r
71 }, "~N");\r
72 Clazz.defineMethod (c$, "getChildCount", \r
73 function () {\r
74 if (this.$children == null) {\r
75 return 0;\r
76 } else {\r
77 return this.$children.size ();\r
78 }});\r
79 Clazz.overrideMethod (c$, "getIndex", \r
80 function (aChild) {\r
81 if (aChild == null) {\r
82 throw  new IllegalArgumentException ("argument is null");\r
83 }if (!this.isNodeChild (aChild)) {\r
84 return -1;\r
85 }return this.$children.indexOf (aChild);\r
86 }, "javax.swing.tree.TreeNode");\r
87 Clazz.defineMethod (c$, "children", \r
88 function () {\r
89 if (this.$children == null) {\r
90 return javax.swing.tree.DefaultMutableTreeNode.EMPTY_ENUMERATION;\r
91 } else {\r
92 return this.$children.elements ();\r
93 }});\r
94 Clazz.defineMethod (c$, "setAllowsChildren", \r
95 function (allows) {\r
96 if (allows != this.allowsChildren) {\r
97 this.allowsChildren = allows;\r
98 if (!this.allowsChildren) {\r
99 this.removeAllChildren ();\r
100 }}}, "~B");\r
101 Clazz.overrideMethod (c$, "getAllowsChildren", \r
102 function () {\r
103 return this.allowsChildren;\r
104 });\r
105 Clazz.overrideMethod (c$, "setUserObject", \r
106 function (userObject) {\r
107 this.userObject = userObject;\r
108 }, "~O");\r
109 Clazz.defineMethod (c$, "getUserObject", \r
110 function () {\r
111 return this.userObject;\r
112 });\r
113 Clazz.overrideMethod (c$, "removeFromParent", \r
114 function () {\r
115 var parent = this.getParent ();\r
116 if (parent != null) {\r
117 parent.remove (this);\r
118 }});\r
119 Clazz.defineMethod (c$, "remove", \r
120 function (aChild) {\r
121 if (aChild == null) {\r
122 throw  new IllegalArgumentException ("argument is null");\r
123 }if (!this.isNodeChild (aChild)) {\r
124 throw  new IllegalArgumentException ("argument is not a child");\r
125 }this.remove (this.getIndex (aChild));\r
126 }, "javax.swing.tree.MutableTreeNode");\r
127 Clazz.defineMethod (c$, "removeAllChildren", \r
128 function () {\r
129 for (var i = this.getChildCount () - 1; i >= 0; i--) {\r
130 this.remove (i);\r
131 }\r
132 });\r
133 Clazz.defineMethod (c$, "add", \r
134 function (newChild) {\r
135 if (newChild != null && newChild.getParent () === this) this.insert (newChild, this.getChildCount () - 1);\r
136  else this.insert (newChild, this.getChildCount ());\r
137 }, "javax.swing.tree.MutableTreeNode");\r
138 Clazz.defineMethod (c$, "isNodeAncestor", \r
139 function (anotherNode) {\r
140 if (anotherNode == null) {\r
141 return false;\r
142 }var ancestor = this;\r
143 do {\r
144 if (ancestor === anotherNode) {\r
145 return true;\r
146 }} while ((ancestor = ancestor.getParent ()) != null);\r
147 return false;\r
148 }, "javax.swing.tree.TreeNode");\r
149 Clazz.defineMethod (c$, "isNodeDescendant", \r
150 function (anotherNode) {\r
151 if (anotherNode == null) return false;\r
152 return anotherNode.isNodeAncestor (this);\r
153 }, "javax.swing.tree.DefaultMutableTreeNode");\r
154 Clazz.defineMethod (c$, "getSharedAncestor", \r
155 function (aNode) {\r
156 if (aNode === this) {\r
157 return this;\r
158 } else if (aNode == null) {\r
159 return null;\r
160 }var level1;\r
161 var level2;\r
162 var diff;\r
163 var node1;\r
164 var node2;\r
165 level1 = this.getLevel ();\r
166 level2 = aNode.getLevel ();\r
167 if (level2 > level1) {\r
168 diff = level2 - level1;\r
169 node1 = aNode;\r
170 node2 = this;\r
171 } else {\r
172 diff = level1 - level2;\r
173 node1 = this;\r
174 node2 = aNode;\r
175 }while (diff > 0) {\r
176 node1 = node1.getParent ();\r
177 diff--;\r
178 }\r
179 do {\r
180 if (node1 === node2) {\r
181 return node1;\r
182 }node1 = node1.getParent ();\r
183 node2 = node2.getParent ();\r
184 } while (node1 != null);\r
185 if (node1 != null || node2 != null) {\r
186 throw  new Error ("nodes should be null");\r
187 }return null;\r
188 }, "javax.swing.tree.DefaultMutableTreeNode");\r
189 Clazz.defineMethod (c$, "isNodeRelated", \r
190 function (aNode) {\r
191 return (aNode != null) && (this.getRoot () === aNode.getRoot ());\r
192 }, "javax.swing.tree.DefaultMutableTreeNode");\r
193 Clazz.defineMethod (c$, "getDepth", \r
194 function () {\r
195 var last = null;\r
196 var enum_ = this.breadthFirstEnumeration ();\r
197 while (enum_.hasMoreElements ()) {\r
198 last = enum_.nextElement ();\r
199 }\r
200 if (last == null) {\r
201 throw  new Error ("nodes should be null");\r
202 }return (last).getLevel () - this.getLevel ();\r
203 });\r
204 Clazz.defineMethod (c$, "getLevel", \r
205 function () {\r
206 var ancestor;\r
207 var levels = 0;\r
208 ancestor = this;\r
209 while ((ancestor = ancestor.getParent ()) != null) {\r
210 levels++;\r
211 }\r
212 return levels;\r
213 });\r
214 Clazz.defineMethod (c$, "getPath", \r
215 function () {\r
216 return this.getPathToRoot (this, 0);\r
217 });\r
218 Clazz.defineMethod (c$, "getPathToRoot", \r
219 function (aNode, depth) {\r
220 var retNodes;\r
221 if (aNode == null) {\r
222 if (depth == 0) return null;\r
223  else retNodes =  new Array (depth);\r
224 } else {\r
225 depth++;\r
226 retNodes = this.getPathToRoot (aNode.getParent (), depth);\r
227 retNodes[retNodes.length - depth] = aNode;\r
228 }return retNodes;\r
229 }, "javax.swing.tree.TreeNode,~N");\r
230 Clazz.defineMethod (c$, "getUserObjectPath", \r
231 function () {\r
232 var realPath = this.getPath ();\r
233 var retPath =  new Array (realPath.length);\r
234 for (var counter = 0; counter < realPath.length; counter++) retPath[counter] = (realPath[counter]).getUserObject ();\r
235 \r
236 return retPath;\r
237 });\r
238 Clazz.defineMethod (c$, "getRoot", \r
239 function () {\r
240 var ancestor = this;\r
241 var previous;\r
242 do {\r
243 previous = ancestor;\r
244 ancestor = ancestor.getParent ();\r
245 } while (ancestor != null);\r
246 return previous;\r
247 });\r
248 Clazz.defineMethod (c$, "isRoot", \r
249 function () {\r
250 return this.getParent () == null;\r
251 });\r
252 Clazz.defineMethod (c$, "getNextNode", \r
253 function () {\r
254 if (this.getChildCount () == 0) {\r
255 var nextSibling = this.getNextSibling ();\r
256 if (nextSibling == null) {\r
257 var aNode = this.getParent ();\r
258 do {\r
259 if (aNode == null) {\r
260 return null;\r
261 }nextSibling = aNode.getNextSibling ();\r
262 if (nextSibling != null) {\r
263 return nextSibling;\r
264 }aNode = aNode.getParent ();\r
265 } while (true);\r
266 } else {\r
267 return nextSibling;\r
268 }} else {\r
269 return this.getChildAt (0);\r
270 }});\r
271 Clazz.defineMethod (c$, "getPreviousNode", \r
272 function () {\r
273 var previousSibling;\r
274 var myParent = this.getParent ();\r
275 if (myParent == null) {\r
276 return null;\r
277 }previousSibling = this.getPreviousSibling ();\r
278 if (previousSibling != null) {\r
279 if (previousSibling.getChildCount () == 0) return previousSibling;\r
280  else return previousSibling.getLastLeaf ();\r
281 } else {\r
282 return myParent;\r
283 }});\r
284 Clazz.defineMethod (c$, "preorderEnumeration", \r
285 function () {\r
286 return Clazz.innerTypeInstance (javax.swing.tree.DefaultMutableTreeNode.PreorderEnumeration, this, null, this);\r
287 });\r
288 Clazz.defineMethod (c$, "postorderEnumeration", \r
289 function () {\r
290 return Clazz.innerTypeInstance (javax.swing.tree.DefaultMutableTreeNode.PostorderEnumeration, this, null, this);\r
291 });\r
292 Clazz.defineMethod (c$, "breadthFirstEnumeration", \r
293 function () {\r
294 return Clazz.innerTypeInstance (javax.swing.tree.DefaultMutableTreeNode.BreadthFirstEnumeration, this, null, this);\r
295 });\r
296 Clazz.defineMethod (c$, "depthFirstEnumeration", \r
297 function () {\r
298 return this.postorderEnumeration ();\r
299 });\r
300 Clazz.defineMethod (c$, "pathFromAncestorEnumeration", \r
301 function (ancestor) {\r
302 return Clazz.innerTypeInstance (javax.swing.tree.DefaultMutableTreeNode.PathBetweenNodesEnumeration, this, null, ancestor, this);\r
303 }, "javax.swing.tree.TreeNode");\r
304 Clazz.defineMethod (c$, "isNodeChild", \r
305 function (aNode) {\r
306 var retval;\r
307 if (aNode == null) {\r
308 retval = false;\r
309 } else {\r
310 if (this.getChildCount () == 0) {\r
311 retval = false;\r
312 } else {\r
313 retval = (aNode.getParent () === this);\r
314 }}return retval;\r
315 }, "javax.swing.tree.TreeNode");\r
316 Clazz.defineMethod (c$, "getFirstChild", \r
317 function () {\r
318 if (this.getChildCount () == 0) {\r
319 throw  new java.util.NoSuchElementException ("node has no children");\r
320 }return this.getChildAt (0);\r
321 });\r
322 Clazz.defineMethod (c$, "getLastChild", \r
323 function () {\r
324 if (this.getChildCount () == 0) {\r
325 throw  new java.util.NoSuchElementException ("node has no children");\r
326 }return this.getChildAt (this.getChildCount () - 1);\r
327 });\r
328 Clazz.defineMethod (c$, "getChildAfter", \r
329 function (aChild) {\r
330 if (aChild == null) {\r
331 throw  new IllegalArgumentException ("argument is null");\r
332 }var index = this.getIndex (aChild);\r
333 if (index == -1) {\r
334 throw  new IllegalArgumentException ("node is not a child");\r
335 }if (index < this.getChildCount () - 1) {\r
336 return this.getChildAt (index + 1);\r
337 } else {\r
338 return null;\r
339 }}, "javax.swing.tree.TreeNode");\r
340 Clazz.defineMethod (c$, "getChildBefore", \r
341 function (aChild) {\r
342 if (aChild == null) {\r
343 throw  new IllegalArgumentException ("argument is null");\r
344 }var index = this.getIndex (aChild);\r
345 if (index == -1) {\r
346 throw  new IllegalArgumentException ("argument is not a child");\r
347 }if (index > 0) {\r
348 return this.getChildAt (index - 1);\r
349 } else {\r
350 return null;\r
351 }}, "javax.swing.tree.TreeNode");\r
352 Clazz.defineMethod (c$, "isNodeSibling", \r
353 function (anotherNode) {\r
354 var retval;\r
355 if (anotherNode == null) {\r
356 retval = false;\r
357 } else if (anotherNode === this) {\r
358 retval = true;\r
359 } else {\r
360 var myParent = this.getParent ();\r
361 retval = (myParent != null && myParent === anotherNode.getParent ());\r
362 if (retval && !(this.getParent ()).isNodeChild (anotherNode)) {\r
363 throw  new Error ("sibling has different parent");\r
364 }}return retval;\r
365 }, "javax.swing.tree.TreeNode");\r
366 Clazz.defineMethod (c$, "getSiblingCount", \r
367 function () {\r
368 var myParent = this.getParent ();\r
369 if (myParent == null) {\r
370 return 1;\r
371 } else {\r
372 return myParent.getChildCount ();\r
373 }});\r
374 Clazz.defineMethod (c$, "getNextSibling", \r
375 function () {\r
376 var retval;\r
377 var myParent = this.getParent ();\r
378 if (myParent == null) {\r
379 retval = null;\r
380 } else {\r
381 retval = myParent.getChildAfter (this);\r
382 }if (retval != null && !this.isNodeSibling (retval)) {\r
383 throw  new Error ("child of parent is not a sibling");\r
384 }return retval;\r
385 });\r
386 Clazz.defineMethod (c$, "getPreviousSibling", \r
387 function () {\r
388 var retval;\r
389 var myParent = this.getParent ();\r
390 if (myParent == null) {\r
391 retval = null;\r
392 } else {\r
393 retval = myParent.getChildBefore (this);\r
394 }if (retval != null && !this.isNodeSibling (retval)) {\r
395 throw  new Error ("child of parent is not a sibling");\r
396 }return retval;\r
397 });\r
398 Clazz.defineMethod (c$, "isLeaf", \r
399 function () {\r
400 return (this.getChildCount () == 0);\r
401 });\r
402 Clazz.defineMethod (c$, "getFirstLeaf", \r
403 function () {\r
404 var node = this;\r
405 while (!node.isLeaf ()) {\r
406 node = node.getFirstChild ();\r
407 }\r
408 return node;\r
409 });\r
410 Clazz.defineMethod (c$, "getLastLeaf", \r
411 function () {\r
412 var node = this;\r
413 while (!node.isLeaf ()) {\r
414 node = node.getLastChild ();\r
415 }\r
416 return node;\r
417 });\r
418 Clazz.defineMethod (c$, "getNextLeaf", \r
419 function () {\r
420 var nextSibling;\r
421 var myParent = this.getParent ();\r
422 if (myParent == null) return null;\r
423 nextSibling = this.getNextSibling ();\r
424 if (nextSibling != null) return nextSibling.getFirstLeaf ();\r
425 return myParent.getNextLeaf ();\r
426 });\r
427 Clazz.defineMethod (c$, "getPreviousLeaf", \r
428 function () {\r
429 var previousSibling;\r
430 var myParent = this.getParent ();\r
431 if (myParent == null) return null;\r
432 previousSibling = this.getPreviousSibling ();\r
433 if (previousSibling != null) return previousSibling.getLastLeaf ();\r
434 return myParent.getPreviousLeaf ();\r
435 });\r
436 Clazz.defineMethod (c$, "getLeafCount", \r
437 function () {\r
438 var count = 0;\r
439 var node;\r
440 var enum_ = this.breadthFirstEnumeration ();\r
441 while (enum_.hasMoreElements ()) {\r
442 node = enum_.nextElement ();\r
443 if (node.isLeaf ()) {\r
444 count++;\r
445 }}\r
446 if (count < 1) {\r
447 throw  new Error ("tree has zero leaves");\r
448 }return count;\r
449 });\r
450 Clazz.defineMethod (c$, "toString", \r
451 function () {\r
452 if (this.userObject == null) {\r
453 return null;\r
454 } else {\r
455 return this.userObject.toString ();\r
456 }});\r
457 Clazz.defineMethod (c$, "clone", \r
458 function () {\r
459 var newNode = null;\r
460 try {\r
461 newNode = Clazz.superCall (this, javax.swing.tree.DefaultMutableTreeNode, "clone", []);\r
462 newNode.$children = null;\r
463 newNode.parent = null;\r
464 } catch (e) {\r
465 if (Clazz.exceptionOf (e, CloneNotSupportedException)) {\r
466 throw  new Error (e.toString ());\r
467 } else {\r
468 throw e;\r
469 }\r
470 }\r
471 return newNode;\r
472 });\r
473 c$.$DefaultMutableTreeNode$PreorderEnumeration$ = function () {\r
474 Clazz.pu$h(self.c$);\r
475 c$ = Clazz.decorateAsClass (function () {\r
476 Clazz.prepareCallback (this, arguments);\r
477 this.stack = null;\r
478 Clazz.instantialize (this, arguments);\r
479 }, javax.swing.tree.DefaultMutableTreeNode, "PreorderEnumeration", null, java.util.Enumeration);\r
480 Clazz.makeConstructor (c$, \r
481 function (a) {\r
482 var b =  new java.util.Vector (1);\r
483 b.addElement (a);\r
484 this.stack =  new java.util.Stack ();\r
485 this.stack.push (b.elements ());\r
486 }, "javax.swing.tree.TreeNode");\r
487 Clazz.overrideMethod (c$, "hasMoreElements", \r
488 function () {\r
489 return (!this.stack.empty () && (this.stack.peek ()).hasMoreElements ());\r
490 });\r
491 Clazz.overrideMethod (c$, "nextElement", \r
492 function () {\r
493 var a = this.stack.peek ();\r
494 var b = a.nextElement ();\r
495 var c = b.children ();\r
496 if (!a.hasMoreElements ()) {\r
497 this.stack.pop ();\r
498 }if (c.hasMoreElements ()) {\r
499 this.stack.push (c);\r
500 }return b;\r
501 });\r
502 c$ = Clazz.p0p ();\r
503 };\r
504 c$.$DefaultMutableTreeNode$PostorderEnumeration$ = function () {\r
505 Clazz.pu$h(self.c$);\r
506 c$ = Clazz.decorateAsClass (function () {\r
507 Clazz.prepareCallback (this, arguments);\r
508 this.root = null;\r
509 this.children = null;\r
510 this.subtree = null;\r
511 Clazz.instantialize (this, arguments);\r
512 }, javax.swing.tree.DefaultMutableTreeNode, "PostorderEnumeration", null, java.util.Enumeration);\r
513 Clazz.makeConstructor (c$, \r
514 function (a) {\r
515 this.root = a;\r
516 this.children = this.root.children ();\r
517 this.subtree = javax.swing.tree.DefaultMutableTreeNode.EMPTY_ENUMERATION;\r
518 }, "javax.swing.tree.TreeNode");\r
519 Clazz.defineMethod (c$, "hasMoreElements", \r
520 function () {\r
521 return this.root != null;\r
522 });\r
523 Clazz.defineMethod (c$, "nextElement", \r
524 function () {\r
525 var a;\r
526 if (this.subtree.hasMoreElements ()) {\r
527 a = this.subtree.nextElement ();\r
528 } else if (this.children.hasMoreElements ()) {\r
529 this.subtree = Clazz.innerTypeInstance (javax.swing.tree.DefaultMutableTreeNode.PostorderEnumeration, this, null, this.children.nextElement ());\r
530 a = this.subtree.nextElement ();\r
531 } else {\r
532 a = this.root;\r
533 this.root = null;\r
534 }return a;\r
535 });\r
536 c$ = Clazz.p0p ();\r
537 };\r
538 c$.$DefaultMutableTreeNode$BreadthFirstEnumeration$ = function () {\r
539 Clazz.pu$h(self.c$);\r
540 c$ = Clazz.decorateAsClass (function () {\r
541 Clazz.prepareCallback (this, arguments);\r
542 this.queue = null;\r
543 if (!Clazz.isClassDefined ("javax.swing.tree.DefaultMutableTreeNode.BreadthFirstEnumeration.Queue")) {\r
544 javax.swing.tree.DefaultMutableTreeNode.BreadthFirstEnumeration.$DefaultMutableTreeNode$BreadthFirstEnumeration$Queue$ ();\r
545 }\r
546 Clazz.instantialize (this, arguments);\r
547 }, javax.swing.tree.DefaultMutableTreeNode, "BreadthFirstEnumeration", null, java.util.Enumeration);\r
548 Clazz.makeConstructor (c$, \r
549 function (a) {\r
550 var b =  new java.util.Vector (1);\r
551 b.addElement (a);\r
552 this.queue = Clazz.innerTypeInstance (javax.swing.tree.DefaultMutableTreeNode.BreadthFirstEnumeration.Queue, this, null);\r
553 this.queue.enqueue (b.elements ());\r
554 }, "javax.swing.tree.TreeNode");\r
555 Clazz.overrideMethod (c$, "hasMoreElements", \r
556 function () {\r
557 return (!this.queue.isEmpty () && (this.queue.firstObject ()).hasMoreElements ());\r
558 });\r
559 Clazz.overrideMethod (c$, "nextElement", \r
560 function () {\r
561 var a = this.queue.firstObject ();\r
562 var b = a.nextElement ();\r
563 var c = b.children ();\r
564 if (!a.hasMoreElements ()) {\r
565 this.queue.dequeue ();\r
566 }if (c.hasMoreElements ()) {\r
567 this.queue.enqueue (c);\r
568 }return b;\r
569 });\r
570 c$.$DefaultMutableTreeNode$BreadthFirstEnumeration$Queue$ = function () {\r
571 Clazz.pu$h(self.c$);\r
572 c$ = Clazz.decorateAsClass (function () {\r
573 Clazz.prepareCallback (this, arguments);\r
574 this.head = null;\r
575 this.tail = null;\r
576 if (!Clazz.isClassDefined ("javax.swing.tree.DefaultMutableTreeNode.BreadthFirstEnumeration.Queue.QNode")) {\r
577 javax.swing.tree.DefaultMutableTreeNode.BreadthFirstEnumeration.Queue.$DefaultMutableTreeNode$BreadthFirstEnumeration$Queue$QNode$ ();\r
578 }\r
579 Clazz.instantialize (this, arguments);\r
580 }, javax.swing.tree.DefaultMutableTreeNode.BreadthFirstEnumeration, "Queue");\r
581 Clazz.defineMethod (c$, "enqueue", \r
582 function (a) {\r
583 if (this.head == null) {\r
584 this.head = this.tail = Clazz.innerTypeInstance (javax.swing.tree.DefaultMutableTreeNode.BreadthFirstEnumeration.Queue.QNode, this, null, a, null);\r
585 } else {\r
586 this.tail.next = Clazz.innerTypeInstance (javax.swing.tree.DefaultMutableTreeNode.BreadthFirstEnumeration.Queue.QNode, this, null, a, null);\r
587 this.tail = this.tail.next;\r
588 }}, "~O");\r
589 Clazz.defineMethod (c$, "dequeue", \r
590 function () {\r
591 if (this.head == null) {\r
592 throw  new java.util.NoSuchElementException ("No more elements");\r
593 }var a = this.head.object;\r
594 var b = this.head;\r
595 this.head = this.head.next;\r
596 if (this.head == null) {\r
597 this.tail = null;\r
598 } else {\r
599 b.next = null;\r
600 }return a;\r
601 });\r
602 Clazz.defineMethod (c$, "firstObject", \r
603 function () {\r
604 if (this.head == null) {\r
605 throw  new java.util.NoSuchElementException ("No more elements");\r
606 }return this.head.object;\r
607 });\r
608 Clazz.defineMethod (c$, "isEmpty", \r
609 function () {\r
610 return this.head == null;\r
611 });\r
612 c$.$DefaultMutableTreeNode$BreadthFirstEnumeration$Queue$QNode$ = function () {\r
613 Clazz.pu$h(self.c$);\r
614 c$ = Clazz.decorateAsClass (function () {\r
615 Clazz.prepareCallback (this, arguments);\r
616 this.object = null;\r
617 this.next = null;\r
618 Clazz.instantialize (this, arguments);\r
619 }, javax.swing.tree.DefaultMutableTreeNode.BreadthFirstEnumeration.Queue, "QNode");\r
620 Clazz.makeConstructor (c$, \r
621 function (a, b) {\r
622 this.object = a;\r
623 this.next = b;\r
624 }, "~O,javax.swing.tree.DefaultMutableTreeNode.BreadthFirstEnumeration.Queue.QNode");\r
625 c$ = Clazz.p0p ();\r
626 };\r
627 c$ = Clazz.p0p ();\r
628 };\r
629 c$ = Clazz.p0p ();\r
630 };\r
631 c$.$DefaultMutableTreeNode$PathBetweenNodesEnumeration$ = function () {\r
632 Clazz.pu$h(self.c$);\r
633 c$ = Clazz.decorateAsClass (function () {\r
634 Clazz.prepareCallback (this, arguments);\r
635 this.stack = null;\r
636 Clazz.instantialize (this, arguments);\r
637 }, javax.swing.tree.DefaultMutableTreeNode, "PathBetweenNodesEnumeration", null, java.util.Enumeration);\r
638 Clazz.makeConstructor (c$, \r
639 function (a, b) {\r
640 if (a == null || b == null) {\r
641 throw  new IllegalArgumentException ("argument is null");\r
642 }var c;\r
643 this.stack =  new java.util.Stack ();\r
644 this.stack.push (b);\r
645 c = b;\r
646 while (c !== a) {\r
647 c = c.getParent ();\r
648 if (c == null && b !== a) {\r
649 throw  new IllegalArgumentException ("node " + a + " is not an ancestor of " + b);\r
650 }this.stack.push (c);\r
651 }\r
652 }, "javax.swing.tree.TreeNode,javax.swing.tree.TreeNode");\r
653 Clazz.overrideMethod (c$, "hasMoreElements", \r
654 function () {\r
655 return this.stack.size () > 0;\r
656 });\r
657 Clazz.overrideMethod (c$, "nextElement", \r
658 function () {\r
659 try {\r
660 return this.stack.pop ();\r
661 } catch (e) {\r
662 if (Clazz.exceptionOf (e, java.util.EmptyStackException)) {\r
663 throw  new java.util.NoSuchElementException ("No more elements");\r
664 } else {\r
665 throw e;\r
666 }\r
667 }\r
668 });\r
669 c$ = Clazz.p0p ();\r
670 };\r
671 c$.$DefaultMutableTreeNode$1$ = function () {\r
672 Clazz.pu$h(self.c$);\r
673 c$ = Clazz.declareAnonymous (javax.swing.tree, "DefaultMutableTreeNode$1", null, java.util.Enumeration);\r
674 Clazz.defineMethod (c$, "hasMoreElements", \r
675 function () {\r
676 return false;\r
677 });\r
678 Clazz.defineMethod (c$, "nextElement", \r
679 function () {\r
680 throw  new java.util.NoSuchElementException ("No more elements");\r
681 });\r
682 c$ = Clazz.p0p ();\r
683 };\r
684 c$.EMPTY_ENUMERATION = c$.prototype.EMPTY_ENUMERATION = ((Clazz.isClassDefined ("javax.swing.tree.DefaultMutableTreeNode$1") ? 0 : javax.swing.tree.DefaultMutableTreeNode.$DefaultMutableTreeNode$1$ ()), Clazz.innerTypeInstance (javax.swing.tree.DefaultMutableTreeNode$1, this, null));\r
685 });\r