[squeak-dev] Tree graph/diagram drawing

Marcel Taeumel marcel.taeumel at hpi.de
Fri Sep 17 07:21:01 UTC 2021

Hi there.

You could also use TableLayout to construct that tree. Model each sub-tree as a morph that presents itself as a node and has submorphs for all its sub-trees. Repeat until a sub-tree is just a leaf itself without. Set #listDirection to #leftToRight and #hReszing/#vResizing to #shrinkWrap. For the node itself, I chose to overwrite #drawOn: into a space I reserved via #layoutInset (e.g., 0 50 0 0).

Am 16.09.2021 17:20:42 schrieb Michał Olszewski <m.olszewski at nexat.pl>:
Thank you, it was really helpful.

W dniu 2021-09-14 o 16:46, Stéphane Rollandin pisze:

Does anybody know an algorithm for drawing tree graph nodes so they
don't clump in one place but rather form a (vertical) tree? I plan on
visualizing a few ASTs. Example included in attachment.

It's not related to Squeak per se, but I have no idea where to begin;
what to type into Google.

See the attached file. It defines TreeMorph, illustrating a simple recursive algorithm that I just made up for you - it seems to work fine.

Try it with:

    TreeMorph example openInWorld

You can use it to display any tree-like object. Just define visiting blocks #morphicGetter and #nodesGetter accordingly.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210917/fb1a3bd4/attachment.html>

More information about the Squeak-dev mailing list