Java Object Tree

Site map version

The object tree is Java applet that displays hierarchical structures. It is designed to be used to illustrate the topology of a web site. Here is a simple example of the object tree. Click the blue arrows to expand or collapse a branch.

[Sorry, you need a Java-enabled browser.]

This tree displays the structure of my personal web site. The applet is quite capable of handling trees with many thousands of entries. It is also designed to work with frames.

Make your own object tree

It is very easy to use the object tree on your own web site. Just download these files into a web-accessible directory:

tree.class
tree_panel.class
tree_node.class
Three compiled Java class files required to run the applet.
tree.java Open source code (optional).
data.txt A sample data file.
tree.html A sample web page with the applet tags.

Once these files are downloaded into a directory, it should produce the same tree as the one displayed in the example above. The next step is to write a data file that reflects your web site's hierarchy. Each entry of the data file consists of the following syntax:

  [spaces]<name of page>|<location of page>

Use either a single space (as below) or a single tab character for each level you wish to indent the entries. The data file for a simple site might look like this:

  Government Policies|./
   Domestic Policy|domestic/
    Unemployment|domestic/unemploy.html
    Welfare|domestic/welfare.html
    Homelessness|domestic/nohome.html
   Foreign Policy|foreign/
    Terrorism|foreign/terror.html

The final step is to change the root address that the applet points at when one clicks on an entry. Simply change the linkbase parameter in tree.html to point at your site's root address.

If you want to create alternative content for people who don't have a Java, I've created an online tool to convert data files into html.

The future

Let me know if you get an object tree operational or if you have any problems. To my knowledge the only bug is a cosmetic one with slack space at the bottom of the scrollbars (no two implementations of Java use the same scrollbar functionality). The code is free, you can copy it and hack it as much as you wish. Take a moment to look at all the parameters in the html file, you can do a huge amount of customization without recompiling the Java.

I was been playing with the idea of interfacing the Java tree to JavaScript so that it becomes scriptable. But I've abandoned that idea due to the extreme unreliability of the LiveConnect interface. For more information, read my scriptability post mortem.

There will probably be a few minor tweaks and updates to this applet, but I don't foresee any major improvements. This applet is currently in use on Stockscotland. There is a slightly modified version of this applet that is specifically designed for displaying object hierarchies within the Lambda MOO environment.

-------------------------------------
Last modified: 2 December 2003