Drawing a Tree Structure

I’m working on an iOS mobile app that creates a tree and I wanted a way to display it. Searching online I found this excellent post on Rachel Lim’s Blog:

She provides source code for a demo program written in C#. I’ve converted it to Xojo and have got it working so I thought I’d share it. In the comments in the post there are some suggested changes with a link to revised source code but I didn’t get that version to work properly. But I have not tested this for a variety of tree structures yet.

The following Dropbox link contains a PDF of her post (in case it goes away, and her original source code (in case it goes away) and Xojo binary project which runs on an iPad in the simulator.


Nice, I like the way you did the Helper class, especially, and you separated the data from the view.

I’ve converted it to a Desktop app and am experimenting with it, will post a demo in a week or so which has selectable icons with drag’n’drop to re-arrange the tree.

Intuitive algorithm. Thank you for sharing your find. I think it will be useful in the future and for me!

1 Like

Thanks for sharing.

but please consider using a code hosting plattform like github for this. Your Dropbox might move away in some months or years. If you host your code publicly on Github it stays. This is always the better way imho.

1 Like

All the credit goes to Rachel, I just ported her code as exactly as I could figure out.

As a “citizen developer”, I’m not going to do things that aren’t fun for me. :wink:

My free Dropbox account has been dormant for years and I only use it for stuff like this so I don’t anticipate it going away for a long time.

Feel free to add it to your own depository and let us know.

1 Like

Even as a hobbyist developer, I highly recommend to have a look at Github. For your personal use, but also if you‘re serious with sharing code with the community.

For most developers Github is the first address to have a look for open source code. Not a forum nor a private Dropbox.

1 Like

Have you incorporated Carlos’ bug fixes (in the comments)?

I tried, but they introduced problems. I’ve incorporated his 2nd one, the one that Rachel acknowledged. Have not tested with lots of examples yet, still working on my app.

Yes, implemented Carlos’ fixes and also the test tree Carlos provided. I have a desktop app working fine, just adding some bells & whistles so you can select a node, and drag & drop a subtree to change it graphically :slight_smile: Need to tidy it up and I will post an example next week.

It’s interesting to see the result. I look forward to demonstrating this improvement to the program.

Hi Kay (and anyone else), have a play with this…

At some point I will add a number of other tree representations as well - circular, Petri and more. I also think it might be worthy of inclusion in the Xojo Examples projects.

NB. Yes I appreciate the point of GitHub but given where I work I dare not use it.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.