aboutsummaryrefslogtreecommitdiff
path: root/libjava/javax/swing/tree/DefaultMutableTreeNode.java
blob: 288b0edc1c98bf3dc8d8e631dcef09834a52b5a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
/* DefaultMutableTreeNode.java --
   Copyright (C) 2002 Free Software Foundation, Inc.

This file is part of GNU Classpath.

GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.

Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.

As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
or based on this library.  If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so.  If you do not wish to do so, delete this
exception statement from your version. */

package javax.swing.tree;

// Imports
import java.io.*;
import java.util.*;

/**
 * DefaultMutableTreeNode
 * @author Andrew Selkirk
 */
public class DefaultMutableTreeNode implements Cloneable, MutableTreeNode, Serializable {

	//-------------------------------------------------------------
	// Variables --------------------------------------------------
	//-------------------------------------------------------------

	/**
	 * EMPTY_ENUMERATION
	 */
	public static final Enumeration EMPTY_ENUMERATION = null; // TODO

	/**
	 * parent
	 */
	protected MutableTreeNode parent = null;

	/**
	 * children
	 */
	protected Vector children = new Vector();

	/**
	 * userObject
	 */
	protected transient Object userObject = "";

	/**
	 * allowsChildren
	 */
	protected boolean allowsChildren = true;


	//-------------------------------------------------------------
	// Initialization ---------------------------------------------
	//-------------------------------------------------------------

	/**
	 * Constructor DefaultMutableTreeNode
	 */
	public DefaultMutableTreeNode() {
		// TODO
	} // DefaultMutableTreeNode()

	/**
	 * Constructor DefaultMutableTreeNode
	 * @param value0 TODO
	 */
	public DefaultMutableTreeNode(Object userObject) {
		this.userObject = userObject;
	} // DefaultMutableTreeNode()

	/**
	 * Constructor DefaultMutableTreeNode
	 * @param value0 TODO
	 * @param value1 TODO
	 */
	public DefaultMutableTreeNode(Object userObject, boolean allowsChildren) {
		this.userObject = userObject;
		this.allowsChildren = allowsChildren;
	} // DefaultMutableTreeNode()


	//-------------------------------------------------------------
	// Methods ----------------------------------------------------
	//-------------------------------------------------------------

	/**
	 * clone
	 * @returns Object
	 */
	public Object clone() {
		return null; // TODO
	} // clone()

	/**
	 * toString
	 * @returns String
	 */
	public String toString() {
		if (userObject == null) {
			return null;
		} // if
		return userObject.toString();
	} // toString()

	/**
	 * add
	 * @param value0 TODO
	 */
	public void add(MutableTreeNode child) {
		children.add(child);
		child.setParent(this);
	} // add()

	/**
	 * getParent
	 * @returns TreeNode
	 */
	public TreeNode getParent() {
		return parent;
	} // getParent()

	/**
	 * remove
	 * @param value0 TODO
	 */
	public void remove(int index) {
		children.remove(index);
	} // remove()

	/**
	 * remove
	 * @param value0 TODO
	 */
	public void remove(MutableTreeNode node) {
		children.remove(node);
	} // remove()

	/**
	 * writeObject
	 * @param value0 TODO
	 * @exception IOException TODO
	 */
	private void writeObject(ObjectOutputStream value0) throws IOException {
		// TODO
	} // writeObject()

	/**
	 * readObject
	 * @param value0 TODO
	 * @exception IOException TODO
	 * @exception ClassNotFoundException TODO
	 */
	private void readObject(ObjectInputStream value0) throws IOException, ClassNotFoundException {
		// TODO
	} // readObject()

	/**
	 * insert
	 * @param value0 TODO
	 * @param value1 TODO
	 */
	public void insert(MutableTreeNode node, int index) {
		children.insertElementAt(node, index);
	} // insert()

	/**
	 * getPath
	 * @returns TreeNode[]
	 */
	public TreeNode[] getPath() {

		// Variables
		TreeNode[]	path;
		int			size;
		int			index;
		TreeNode	current;

		// Determine length of Path
		size = getLevel() + 1;

		// Create Path
		path = new TreeNode[size];
		current = this;
		for (index = size - 1; index >= 0; index--) {
			path[index] = current;
			current = current.getParent();
		} // for

		// Return Path
		return path;

	} // getPath()

	/**
	 * children
	 * @returns Enumeration
	 */
	public Enumeration children() {
		return children.elements();
	} // children()

	/**
	 * setParent
	 * @param value0 TODO
	 */
	public void setParent(MutableTreeNode node) {
		parent = node;
	} // setParent()

	/**
	 * getChildAt
	 * @param value0 TODO
	 * @returns TreeNode
	 */
	public TreeNode getChildAt(int index) {
		return (TreeNode) children.elementAt(index);
	} // getChildAt()

	/**
	 * getChildCount
	 * @returns int
	 */
	public int getChildCount() {
		return children.size();
	} // getChildCount()

	/**
	 * getIndex
	 * @param value0 TODO
	 * @returns int
	 */
	public int getIndex(TreeNode node) {
		return children.indexOf(node);
	} // getIndex()

	/**
	 * setAllowsChildren
	 * @param value0 TODO
	 */
	public void setAllowsChildren(boolean allowsChildren) {
		this.allowsChildren = allowsChildren;
	} // setAllowsChildren()

	/**
	 * getAllowsChildren
	 * @returns boolean
	 */
	public boolean getAllowsChildren() {
		return allowsChildren;
	} // getAllowsChildren()

	/**
	 * setUserObject
	 * @param value0 TODO
	 */
	public void setUserObject(Object userObject) {
		this.userObject = userObject;
	} // setUserObject()

	/**
	 * getUserObject
	 * @returns Object
	 */
	public Object getUserObject() {
		return userObject;
	} // getUserObject()

	/**
	 * removeFromParent
	 */
	public void removeFromParent() {
		parent = null;
		// TODO
	} // removeFromParent()

	/**
	 * removeAllChildren
	 */
	public void removeAllChildren() {
		children.removeAllElements();
	} // removeAllChildren()

	/**
	 * isNodeAncestor
	 * @param value0 TODO
	 * @returns boolean
	 */
	public boolean isNodeAncestor(TreeNode node) {

		// Variables
		TreeNode	current;

		// Sanity Check
		if (node == null) {
			return false;
		} // if

		// Search For Ancestor
		current = this;
		while (current != null && current != node) {
			current = current.getParent();
		} // while

		// Check for Ancestor
		if (current == node) {
			return true;
		} // if

		// Otherwise, no
		return false;

	} // isNodeAncestor()

	/**
	 * isNodeDescendant
	 * @param value0 TODO
	 * @returns boolean
	 */
	public boolean isNodeDescendant(DefaultMutableTreeNode node) {

		// Variables
		TreeNode	current;

		// Sanity Check
		if (node == null) {
			return false;
		} // if

		// Search For Descendant
		current = node;
		while (current != null && current != this) {
			current = current.getParent();
		} // while

		// Check for Descendant
		if (current == this) {
			return true;
		} // if

		// Otherwise, no
		return false;

	} // isNodeDescendant()

	/**
	 * getSharedAncestor
	 * @param value0 TODO
	 * @returns TreeNode
	 */
	public TreeNode getSharedAncestor(DefaultMutableTreeNode node) {

		// Variables
		ArrayList	list;
		TreeNode	current;

		// Get List of Path Elements for this node
		current = this;
		list = new ArrayList();
		while (current != null) {
			list.add(current);
			current = current.getParent();
		} // while

		// Check if any path element of node are in list
		current = node;
		while (current != null) {
			if (list.contains(current) == true) {
				return current;
			} // if
			current = current.getParent();
		} // while

		// Unable to locate shared ancestor
		return null;

	} // getSharedAncestor()

	/**
	 * isNodeRelated
	 * @param value0 TODO
	 * @returns boolean
	 */
	public boolean isNodeRelated(DefaultMutableTreeNode node) {

		// Sanity Check
		if (node == null) {
			return false;
		} // if

		// Check for the same root
		if (node.getRoot() == getRoot()) {
			return true;
		} // if

		// Nodes are not related
		return false;

	} // isNodeRelated()

	/**
	 * getDepth
	 * @returns int
	 */
	public int getDepth() {

		// Variables
		TreeNode		node;
		int				depth;
		int				current;
		int				size;
		Stack			stack;
		int				index;

		// Check for children
		if (allowsChildren == false || children.size() == 0) {
			return 0;
		} // if

		// Process Depths
		stack = new Stack();
		stack.push(new Integer(0));
		node = getChildAt(0);
//System.out.println("  * Descend: 0-0");
		depth = 0;
		current = 1;
		while (stack.empty() == false) {

			// Check if node has children
			if (node.getChildCount() != 0) {
				node = node.getChildAt(0);
				stack.push(new Integer(0));
				current++;
//				System.out.println("  * Descend: 0-" + current);

			// Check for next sibling
			} else {

				// Check Depth
				if (current > depth) {
					depth = current;
				} // if

				do {

					// Traverse to Parent
					node = node.getParent();
					size = node.getChildCount();
					current--;
					index = ((Integer) stack.pop()).intValue();
//					System.out.println("  * Ascend from: " + index + "-" + current);
					index++;

				} while (index >= size && node != this);

				// Check for child
				if (index < size) {
					node = node.getChildAt(index);
					stack.push(new Integer(index));
					current++;
//					System.out.println("  * Descend: " + index + "-" + current);
				} // if

			} // if

		} // while

		return depth;

	} // getDepth()

	static Random	random = new Random(System.currentTimeMillis());

	public static void growTree(DefaultMutableTreeNode root) {

		// Variables
		int						size;
		int						index;
		DefaultMutableTreeNode	node;
		DefaultMutableTreeNode	current;

		current = root;
		index = 0;
//		while (current != root) {
		do {

//			if (random.nextInt(3) < 2) {
			if (random.nextBoolean()) {
				node = new DefaultMutableTreeNode(String.valueOf(index));
				index++;
				current.add(node);
				current = node;
			} else {
				current = (DefaultMutableTreeNode) current.getParent();
			} // if

//		} // while
		} while (current != root && current != null);

		System.out.println("Number of nodes: " + index);

/*
		// Calc # children
		size = random.nextInt(4);

		for (index = 0; index < size; index++) {

			// Create Node
			node = new DefaultMutableTreeNode(String.valueOf(index));
			growTree(node);

			// Add Node to root
			root.add(node);

		} // for
*/
	} // growTree()

	public static void main(String[] argv) {
/*
		DefaultMutableTreeNode	node1 = new DefaultMutableTreeNode("node1");
		DefaultMutableTreeNode	node2 = new DefaultMutableTreeNode("node2");
		DefaultMutableTreeNode	node3 = new DefaultMutableTreeNode("node3");
		DefaultMutableTreeNode	node4 = new DefaultMutableTreeNode("node4");
		DefaultMutableTreeNode	node5 = new DefaultMutableTreeNode("node5");
		DefaultMutableTreeNode	node6 = new DefaultMutableTreeNode("node6");
		DefaultMutableTreeNode	node7 = new DefaultMutableTreeNode("node7");
		DefaultMutableTreeNode	node8 = new DefaultMutableTreeNode("node8");

		node1.add(node2);
		node1.add(node3);
		node2.add(node4);
		node2.add(node5);
		node3.add(node6);
		node3.add(node7);
		node5.add(node8);

		System.out.println("Depth (node1): " + node1.getDepth());
		System.out.println("Depth (node2): " + node2.getDepth());
		System.out.println("Depth (node3): " + node3.getDepth());
*/

		System.out.println("Create tree...");
		DefaultMutableTreeNode	root = new DefaultMutableTreeNode("root");
		growTree(root);
		System.out.println("Find depth...");
		System.out.println("Depth (root): " + root.getDepth());

	} // main

	/**
	 * getLevel
	 * @returns int
	 */
	public int getLevel() {

		// Variables
		TreeNode	current;
		int			count;

		// Lookup Parent
		count = -1;
		current = this;
		do {
			current = current.getParent();
			count++;
		} while (current != null);

		return count;

	} // getLevel()

	/**
	 * getPathToRoot
	 * @param value0 TODO
	 * @param value1 TODO
	 * @returns TreeNode[]
	 */
	protected TreeNode[] getPathToRoot(TreeNode value0, int value1) {
		return null; // TODO
	} // getPathToRoot()

	/**
	 * getUserObjectPath
	 * @returns Object[]
	 */
	public Object[] getUserObjectPath() {

		// Variables
		TreeNode[]	path;
		Object[]	object;
		int			size;
		int			index;

		// Get Path for Tree Nodes
		path = getPath();

		// Construct Object Path
		object = new Object[path.length];
		for (index = 0; index < path.length; index++) {
			object[index] = ((DefaultMutableTreeNode) path[index]).getUserObject();
		} // for

		// Return Object Path
		return object;

	} // getUserObjectPath()

	/**
	 * getRoot
	 * @returns TreeNode
	 */
	public TreeNode getRoot() {

		// Variables
		TreeNode	current;
		TreeNode	check;

		// Lookup Parent
		current = this;
		check = current.getParent();
		while (check != null) {
			current = check;
			check = current.getParent();
		} // while

		return current;

	} // getRoot()

	/**
	 * isRoot
	 * @returns boolean
	 */
	public boolean isRoot() {
		return (parent == null);
	} // isRoot()

	/**
	 * getNextNode
	 * @returns DefaultMutableTreeNode
	 */
	public DefaultMutableTreeNode getNextNode() {
		return null; // TODO
	} // getNextNode()

	/**
	 * getPreviousNode
	 * @returns DefaultMutableTreeNode
	 */
	public DefaultMutableTreeNode getPreviousNode() {
		return null; // TODO
	} // getPreviousNode()

	/**
	 * preorderEnumeration
	 * @returns Enumeration
	 */
	public Enumeration preorderEnumeration() {
		return null; // TODO
	} // preorderEnumeration()

	/**
	 * postorderEnumeration
	 * @returns Enumeration
	 */
	public Enumeration postorderEnumeration() {
		return null; // TODO
	} // postorderEnumeration()

	/**
	 * breadthFirstEnumeration
	 * @returns Enumeration
	 */
	public Enumeration breadthFirstEnumeration() {
		return null; // TODO
	} // breadthFirstEnumeration()

	/**
	 * depthFirstEnumeration
	 * @returns Enumeration
	 */
	public Enumeration depthFirstEnumeration() {
		return null; // TODO
	} // depthFirstEnumeration()

	/**
	 * pathFromAncestorEnumeration
	 * @param value0 TODO
	 * @returns Enumeration
	 */
	public Enumeration pathFromAncestorEnumeration(TreeNode value0) {
		return null; // TODO
	} // pathFromAncestorEnumeration()

	/**
	 * isNodeChild
	 * @param value0 TODO
	 * @returns boolean
	 */
	public boolean isNodeChild(TreeNode node) {

		// Variables
		TreeNode	current;
		int			index;

		// Sanity Check
		if (node == null) {
			return false;
		} // if

		// Process Path
		current = node;
		while (current != null) {
			if (current == this) {
				return true;
			} // if
			current = current.getParent();
		} // while

		// Node not located in path, not child
		return false;

	} // isNodeChild()

	/**
	 * getFirstChild
	 * @returns TreeNode
	 */
	public TreeNode getFirstChild() {
		return (TreeNode) children.firstElement();
	} // getFirstChild()

	/**
	 * getLastChild
	 * @returns TreeNode
	 */
	public TreeNode getLastChild() {
		return (TreeNode) children.lastElement();
	} // getLastChild()

	/**
	 * getChildAfter
	 * @param value0 TODO
	 * @returns TreeNode
	 */
	public TreeNode getChildAfter(TreeNode node) {

		// Variables
		int		index;

		// Check node
		if (node == null || node.getParent() != this) {
			throw new IllegalArgumentException();
		} // if

		// Get index of child node
		index = getIndex(node);

		// Check for child after
		index++;
		if (index == getChildCount()) {
			return null;
		} // if

		// Retrieve Child After
		return getChildAt(index);

	} // getChildAfter()

	/**
	 * getChildBefore
	 * @param value0 TODO
	 * @returns TreeNode
	 */
	public TreeNode getChildBefore(TreeNode node) {

		// Variables
		int		index;

		// Check node
		if (node == null || node.getParent() != this) {
			throw new IllegalArgumentException();
		} // if

		// Get index of child node
		index = getIndex(node);

		// Check for child before
		index--;
		if (index < 0) {
			return null;
		} // if

		// Retrieve Child Before
		return getChildAt(index);

	} // getChildBefore()

	/**
	 * isNodeSibling
	 * @param value0 TODO
	 * @returns boolean
	 */
	public boolean isNodeSibling(TreeNode node) {

		// Variables
		int			index;

		// Check for null
		if (node == null) {
			return false;
		} // if

		// Check if nodes share a parent
		if (node.getParent() == getParent() && getParent() != null) {
			return true;
		} // if

		// Nodes are not siblings
		return false;

	} // isNodeSibling()

	/**
	 * getSiblingCount
	 * @returns int
	 */
	public int getSiblingCount() {

		// Variables

		// Check for no parent
		if (parent == null) {
			return 1;
		} // if

		// Calculate sibling count from parent's child count
		return parent.getChildCount();

	} // getSiblingCount()

	/**
	 * getNextSibling
	 * @returns DefaultMutableTreeNode
	 */
	public DefaultMutableTreeNode getNextSibling() {

		// Variables
		int		index;
		int		size;

		// Check for Parent
		if (parent == null) {
			return null;
		} // if

		// Get Index of this node
		index = parent.getIndex(this);

		// Check for Next Sibling
		size = parent.getChildCount();
		index++;
		if (index == size) {
			return null;
		} // if

		return (DefaultMutableTreeNode) parent.getChildAt(index);

	} // getNextSibling()

	/**
	 * getPreviousSibling
	 * @returns DefaultMutableTreeNode
	 */
	public DefaultMutableTreeNode getPreviousSibling() {

		// Variables
		int		index;

		// Check for Parent
		if (parent == null) {
			return null;
		} // if

		// Get Index of this node
		index = parent.getIndex(this);

		// Check for Previous Sibling
		index--;
		if (index < 0) {
			return null;
		} // if

		return (DefaultMutableTreeNode) parent.getChildAt(index);

	} // getPreviousSibling()

	/**
	 * isLeaf
	 * @returns boolean
	 */
	public boolean isLeaf() {
		return (children.size() == 0); // TODO: check allowsChildren??
	} // isLeaf()

	/**
	 * getFirstLeaf
	 * @returns DefaultMutableTreeNode
	 */
	public DefaultMutableTreeNode getFirstLeaf() {

		// Variables
		TreeNode	current;

		current = this;
		while (current.getChildCount() > 0) {
			current = current.getChildAt(0);
		} // while

		return (DefaultMutableTreeNode) current;

	} // getFirstLeaf()

	/**
	 * getLastLeaf
	 * @returns DefaultMutableTreeNode
	 */
	public DefaultMutableTreeNode getLastLeaf() {

		// Variables
		TreeNode	current;
		int			size;

		current = this;
		size = current.getChildCount();
		while (size > 0) {
			current = current.getChildAt(size - 1);
			size = current.getChildCount();
		} // while

		return (DefaultMutableTreeNode) current;

	} // getLastLeaf()

	/**
	 * getNextLeaf
	 * @returns DefaultMutableTreeNode
	 */
	public DefaultMutableTreeNode getNextLeaf() {
		return null; // TODO
	} // getNextLeaf()

	/**
	 * getPreviousLeaf
	 * @returns DefaultMutableTreeNode
	 */
	public DefaultMutableTreeNode getPreviousLeaf() {
		return null; // TODO
	} // getPreviousLeaf()

	/**
	 * getLeafCount
	 * @returns int
	 */
	public int getLeafCount() {

		// Variables
		Enumeration	enum;
		int			count;
		TreeNode	current;

		// Get Enumeration of all descendants
		enum = depthFirstEnumeration();

		// Process Nodes
		count = 0;
		while (enum.hasMoreElements() == true) {
			current = (TreeNode) enum.nextElement();
			if (current.isLeaf() == true) {
				count++;
			} // if
		} // if

		return count;

	} // getLeafCount()


} // DefaultMutableTreeNode