Conditional layout

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

Conditional layout

abergel
Dear all,

I have created a class RTConditionalLayout and it is into the Layout Builder. 
Consider the following example:


-=-=-=-=-=-=-=-=-=
v := RTView new.
es := (RTEllipse new
size: 30;
color: [ :value | value odd ifTrue: [ Color red ] ifFalse: [ Color blue ] ])
elementsOn: (1 to: 4).
v addAll: es.

l := RTConditionalLayout new
condition: [ :element | element model odd ];
thenLayout: RTVerticalLineLayout new;
elseLayout: RTHorizontalLineLayout new.
l on: es.
v
-=-=-=-=-=-=-=-=-=

The idea is to have a layout that segregate some elements that match a particular condition. 

This is supported in the Layout builder, which allows one to do (using RTMondrian in that case):
-=-=-=-=-=-=-=-=-=
b := RTMondrian new.
b shape rectangle
fillColor: Color white;
borderColor: Color lightGray;
withTextAbove: #name.
b nodes: Collection withAllSubclasses forEach: [ :cls |
b nodes: cls methods.
b edges connectToAll: #dependentMethods.
b layout 
ifElement: #isConnected then: RTTreeLayout new;
else: RTGridLayout new.
 ].

b edges connectFrom: #superclass.
b layout tree.
b
-=-=-=-=-=-=-=-=-=

The issue here is that I have introduced a mechanism to do ‘if’ statements. I am not sure this is the best things…

Comments are welcome :-)

Cheers,
Alexandre

-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.




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

Re: Conditional layout

Peter Uhnak
The issue here is that I have introduced a mechanism to do ‘if’ statements. I am not sure this is the best things…

Why not use filter-like syntax which is already used in RTShapeBuilder? (RTShapeBuilder>>ifElement:color:, etc.)

ifElement: #isConnected layout: RTTreeLayout new.
ifElement: [ :e | e isConnected not ] layout: RTTreeLayout new.

This would also allow for overlapping of layouts.

Peter

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

Re: Conditional layout

abergel
> ifElement: #isConnected layout: RTTreeLayout new.
> ifElement: [ :e | e isConnected not ] layout: RTTreeLayout new.
>
> This would also allow for overlapping of layouts.

Any example?

Alexandre

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



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