Hi there

I browse the code of SqMondrian to understand how it works (with the previous help of Alex) and after a while, I wondered how the traversal of nodes and edges was really done.

It seems like traversing the graph and drawing shapes are deeply intertwined.

It took me a bit of time to figure out, but it seems that the following method defined for the nil object is very important :)

UndefinedObject>>display: anElement on: aCanvas
anElement display: anElement on: aCanvas

The call sequence look like:
@rootnode#displayOn: -> nil#display: rootnode on: aCanvas -> (...) rootnode children#displayOn: aCanvas -> ... -> shape#display: aNode on: aCanvas -> nil display: aNode on: aCanvas -> aNode children#displayOn: aCanvas -> .....

Or, from Root to nil to root children to child shape to nil to child to children of child to shape to nil to ....etc.

It's quite weird how it always goes through nil to launch and continue the traversal :)



Not discussing the previous design which had its own reason, but now that we have separate composite shape, I think we can also separate the nodes traversal logic from the shape drawing logic for clarity.


--
 Simon