I eventually reduced my test case to this more concise demonstration in Mondrian Easel... view shape rectangle width: 40; text: #yourself. view node: 'R1'. view shape ellipse width:40; text: #yourself. view node: 'E1'.
The Principle Of Least Surprise suggests that both nodes R1 & E1 would render text in a similar way - but they don't. After spending most of a frustrating day trying to trace down the discrepancy, I discovered that rectangle is treated differently to every other shape that is rendered by ConcreteShapeVisitor. This inconsistency is particularly apparent when comparing #visitEllipseShape and #visitRoundedRectangleShape with #visitRectangleShape. The latter deals with a lot more than drawing a rectangle and perhaps would be more correctly named to be #visitRectangleAndLabelShape.
A few naive* observations then... + it seems that the #text: method actually has no effect on shapes other than rectangle, and so should perhaps report an error like 'Not implemented, use forms instead.' + for consistency, 'view shape rectangleAndLabel' seems more appropriate than just 'view shape rectangle' + the label stuff would seem better split off from rectangle + rather than 'view shape label' creating a rectangle with no border, #label might be able to be applied to any shape and automatically build a form including the original shape.
*I share these ideas without fully understanding the Mondrian architecture. If I am told they are poor ideas, then I learn something.
I did manage to work out most of what I needed with forms. I provide an example you might want to add to Mondrian Easel > Examples > builder ... view shape form: [:b | b column; fill; row; fill. b x:1 y:1 add: (MOEllipseShape new fillColor: Color lightGreen; width: 80 ; height: 80). b x:1 y:1 add: (MORectangleShape new withoutBorder; withText ; fillColor: Color transparent ). ]. view node: ' labels other than rectangles '.
cheers, -ben
Ben Coman wrote:
In Moose 4.6, World > Moose > Mondrian Easel > Examples > basic > edges + tiled nodes has this code... | nodes | view shape rectangle width: 40; text: #yourself. nodes := view nodes: (1 to: 20). view shape arrowedLine. view edges: (2 to: 20) from: 1 to: #yourself. view layout: (MOCircleLayout forNodes: nodes allButFirst)
which displays text inside each rectangular node. If I change the second line to... view shape ellipse
then nodes do appear as ellipses but the text disappears. That is not what I expected. How can text be made to display within an ellipse?
cheers, Ben
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev