Lleta Tree Utilities

Lleta Tree Utilities is collection of java classes that display trees, presentable in both and graphical formats. These trees can be built by hand or reflectively from existing Java structures. To see Lleta Tree Utilities in action, you can view an applet example. The Lleta Tree Utilities package was written by Zach Buckner. The source code is available here. These utilities require Jazz, an impressive api for zoomable interfaces.

Reflection

Consider the following code. To explore the reflection capablities of the lleta tree utilities, we'll create a family of animals, rooted at an object called smithFamily:
public class Parents {
	public Animal she;
	public Animal he;
	public Parents (Animal she, Animal he) { this.she = she; this.he = he; }
}

public class Animal {
	public String name = "";
	public int age;
	public java.util.Vector children = new java.util.Vector();
	public Animal(String name, int age) { this.name = name; this.age = age; }
}

Animal mom = new Animal("mammy", 37);
Animal dad = new Animal("pappy", 40);
Animal ralph = new Animal("ralph", 12);
Animal sally = new Animal("sally", 10);
mom.children.add(ralph);
mom.children.add(sally);
dad.children = mom.children;
Parents smithFamily  = new Parents(mom, dad);

Reflection / Jazz

To display the smith family via the Jazz presenter interface, we'll execute the following code, which produces a tree that can be navigated using the jazz interface via the keyboard or the mouse:
new JazzTreePresenter(smithFamily);

Using the arrow keys on the keyboard, we can descend deeper into the tree. The yellow nodes represent 'cycles', nodes that have already been displayed early in the tree. the second figure, the yellow node on the bottom right is dad's children field, which points back to mom's children field (dad and mom both the same collection of children).

Reflection / Text

 TextTreePresenter.present(smithFamily);
Using the same classes and instances described earlier, the above code produces a [slightly unwieldy] text description of the tree:
 1
 root
 class org.lleta.tests.TreeTest$Parents
 org.lleta.tests.TreeTest$Parents@712c4e
 0

 2
 she
 class org.lleta.tests.TreeTest$Animal
 org.lleta.tests.TreeTest$Animal@6a2dfe
 1

 3
 name
 class java.lang.String
 mammy
 2

 4
 age
 class java.lang.Integer
 37
 2

 5
 children
 class java.util.Vector
 [org.lleta.tests.TreeTest$Animal@d107f, org.lleta.tests.TreeTest$Animal@360be0]
 2

 6
 elementData
 class [Ljava.lang.Object;
 [Ljava.lang.Object;@2f0db
 3

 7
 elementData
 class org.lleta.tests.TreeTest$Animal
 org.lleta.tests.TreeTest$Animal@d107f
 4

 8
 name
 class java.lang.String
 ralph
 5

 9
 age
 class java.lang.Integer
 12
 5

 10
 children
 class java.util.Vector
 []
 5

 11
 elementData
 class [Ljava.lang.Object;
 [Ljava.lang.Object;@390b39
 6

 12
 elementCount
 class java.lang.Integer
 0
 6

 13
 capacityIncrement
 class java.lang.Integer
 0
 6
 12

 14
 elementData
 class org.lleta.tests.TreeTest$Animal
 org.lleta.tests.TreeTest$Animal@360be0
 4

 15
 name
 class java.lang.String
 sally
 5

 16
 age
 class java.lang.Integer
 10
 5

 17
 children
 class java.util.Vector
 []
 5
 10

 18
 elementCount
 class java.lang.Integer
 2
 3

 19
 capacityIncrement
 class java.lang.Integer
 0
 3
 13

 20
 he
 class org.lleta.tests.TreeTest$Animal
 org.lleta.tests.TreeTest$Animal@28c4e7
 1

 21
 name
 class java.lang.String
 pappy
 2

 22
 age
 class java.lang.Integer
 40
 2

 23
 children
 class java.util.Vector
 [org.lleta.tests.TreeTest$Animal@d107f, org.lleta.tests.TreeTest$Animal@360be0]
 2
 5