Mondrian - display of text within ellipse

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Mondrian - display of text within ellipse

Ben Coman
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
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Mondrian - display of text within ellipse

Ben Coman
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
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Mondrian - display of text within ellipse

Tudor Girba-2
Hi,

On 25 Mar 2012, at 17:42, Ben Coman wrote:

> 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.'

This is a problem, indeed. The current implementation of Mondrian does not support proper


> + for consistency, 'view shape rectangleAndLabel' seems more appropriate than just 'view shape rectangle'

I disagree :).


> + the label stuff would seem better split off from rectangle

This was indeed the original intent. It would be great to get the label properly handled in all basic shapes.


> + 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.

Not really. Forms are slower than basic shapes, and labels is just a very simple form. It is often used so it deserves a special constructor. It used to be the case that Label had its own shape class, but now it just got merged with Rectangle due to implementation convenience.  Long time ago, when shapes were composable also through decorators (in VW), labels were distinct from rectangles by design, and the code did not have to be duplicated to get labels combinable with in any other shape, but that is no longer supported, unfortunately.


> *I share these ideas without fully understanding the Mondrian architecture.  If I am told they are poor ideas, then I learn something.

Perfect :).


> 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   '.

Nice. You are getting advanced :)


Cheers,
Doru



> 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
>> [hidden email]
>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev

--
www.tudorgirba.com

"No matter how many recipes we know, we still value a chef."







_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev