View/Edit #1997!index.html

File name: index.html
  <TITLE>About the Object Tree</TITLE>

<BODY BGCOLOR="#ffffff">

<H1>About the Object Tree</H1>
<H2>MOO version</H2>

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

  <APPLET CODE="tree.class" WIDTH=300 HEIGHT=300>

  <!-- datafile name defaults to data.txt, relative to the code's dir -->
  <!-- the data file *must* be on the same server as the code -->
  <PARAM NAME="datafile" VALUE="data.txt">

  <!-- linkbase defaults to the location of this HTML page -->
  <!-- each object's url is made up of the linkbase plus its object # -->
  <!-- set linkbase to "" to disable all links -->
  <PARAM NAME="linkbase" VALUE="">

  <!-- If the links should point to a different frame, name it. -->
  <!-- <PARAM NAME="target" VALUE="rightFrame"> -->

  <!-- colours are specified in the usual RRGGBB way -->
  <PARAM NAME="bgcolor" VALUE="ffffff">
  <PARAM NAME="textcolor" VALUE="000000">
  <PARAM NAME="bulletcolor" VALUE="000000">
  <PARAM NAME="arrowcolor" VALUE="0000ff">

  <!-- font defaults to TimesRoman of size 12 -->
  <PARAM NAME="fontname" VALUE="TimesRoman">
  <PARAM NAME="fontsize" VALUE="14">

  <!-- subtle behaviour tweaking; all default to 0. Suggest setting them all to 1 if using frames. -->
  <!-- should clicking on a bullet activate the link (1), or do nothing (0)? -->
  <PARAM NAME="bulletlink" VALUE="0">
  <!-- should clicking an arrow activate the link (1), or not (0)? Arrow will open/close regardless. -->
  <PARAM NAME="arrowlink" VALUE="0">
  <!-- should clicking on text open/close the item (1), or not (0)? Link will activate regardless. -->
  <PARAM NAME="textopen" VALUE="0">
  <!-- should opening a branch close all others (1), or not (0)? -->
  <PARAM NAME="singleopen" VALUE="0">

  <!-- where the find box should be located (North vs. South) -->
  <!-- remove parameter to remove find box -->
  <PARAM NAME="find" VALUE="South">

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


<p>This tree contains two dozen of the most important generics on MOO Canada.  The applet is quite capable of loading <A HREF="">every object on MOO Canada</A>.

<h2>Make your own object tree</h2>

It is very easy to use the object tree on your own MOO.  You don't even have to have a web interface.  Just download these files into a web-accessible directory:

<table border=1><tr>
  <td><A HREF="tree.class">tree.class</A><BR>
      <A HREF="tree_panel.class">tree_panel.class</A><BR>
      <A HREF="tree_node.class">tree_node.class</A></td>
  <td>Three compiled Java class files required to run the applet.</td>
  <td><A HREF=""></A></td>
  <td>Open source code (optional).</td>
  <td><A HREF="data.txt">data.txt</A></td>
  <td>A sample data file.</td>
  <td><A HREF="tree.html">tree.html</A></td>
  <td>A sample web page with the applet tags.</td>

<p>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 generate a data file that reflects your MOO's object hierarchy.  Use the following MOO code to generate the data:

@verb #123:"recurse" this none this
@program #123:recurse
{object, level? = 1} = args;
kids = children(object);
if (object in {$garbage})
  "The list of any object types to be ignored.";
  data = $string_utils:space(level - 1) + $string_utils:trim($string_utils:name_and_number(object)));
  data = {data, tostr($string_utils:space(level), "[", length(kids), " children skipped]")};
  data = {$string_utils:space(level - 1) + $string_utils:trim($string_utils:name_and_number(object))};
  if (kids)
    "Split the list of kids into two, those with kids of their own, and those without.";
    with = without = {};
    for kid in (kids)
      if (children(kid))
        with = {@with, kid};
        without = {@without, kid};
    "Sort each class by numerical order.";
    with = $list_utils:sort(with);
    without = $list_utils:sort(without);
    for kid in ({@with, @without})
      data = {@data, @this:(verb)(kid, level + 1)};
return data;
[based on code by <A HREF="">Daryl (#3887)</A>]

<p>When <TT>#123:recurse($root)</TT> is executed it will return a large list of strings.  This text  must be placed into a file.  If the MOO has FUP or FileIO installed, this is easy.  If the MOO has a web interface, the text can be downloaded with a web browser.  If all else fails, one can start a capture session and dump it out the Telnet port.  Replace the data.txt file with your new content, and the MOO's tree structure is complete.  Note that the indenting of the text is entirely cosmetic, it allows humans to read the data file more easily but the applet couldn't care less about the spaces.

<p>The final step is to change the address that the applet points at when one clicks on an object.  MOO Canada has a web interface which allows one to view every object by going to <I></I> (where <I>####</I> is the object number).  If your MOO has something similar then you can simply change the <TT>linkbase</TT> parameter in objtree.html to point at your MOO's root address.  If your MOO doesn't have a web interface and you don't have anywhere to link to, set <TT>linkbase</TT> to <TT>""</TT> and the linking feature will be disabled.

<H2>The future</H2>

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.

<p>I would like to expand this applet into a web-based MOO IDE.  Unfortunately, any further additions to the code will make it impossible to port off of MOO Canada, so what you see is probably the last publicly available version.  With very minor modifications this applet has also been used as
<A HREF="">a site map</A>.

Size: 6,557 bytes.
File perms: Readable

You are not logged in.

[home | help | who | search | setup | code]