new Mondrian example 'changing subview layout interactively'

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

new Mondrian example 'changing subview layout interactively'

Ben Coman
Just sharing a cool result of some experimentation with Mondrian.  I was
pleasantly surprised with what I ended up with.
Contents of attached text file can be copied to Workspace.  Also I've
uploaded this for Mondrian Easel as Mondrian-Example-BenComan.44.

cheers -ben



        | view b actionBlock makeMenu |
       
        view := MOViewRenderer new.

        "Define shape such that the MOLayout name is displayed above the subview children"
        b := MOFormsBuilder new.
        b column; fill; row; fill; row; fill .
        b x:1 y:1 add:
        ( MORectangleShape new
                text: [ :value | (view nodeForDomainValue: value) layout. ];
                textAlignment: #center;
                borderColor: Color white
        ) .
        b x:1 y:2 add: ( MORectangleShape new ) .
        b x:1 y:2 add: ( MOChildrenShape new ) .
        view shape: b shape.
       
        "Define menus for setting the layouts of subviews"
        actionBlock :=
        [ :selectedValue :newLayout |
                | element position |
                element := view nodeForDomainValue: selectedValue.
                position := element bounds origin.
                element layout: newLayout.
                element applyLayout.
                element resetFormCacheUpToTheRoot.
                element translateBy: position.
                view updateWindow.
        ].
        makeMenu :=
        [ :layout |
                view interaction item: (layout class name asString) action: [ :selectedValue | actionBlock value: selectedValue value: layout ].
        ].
        makeMenu value: (MOGridLayout new).
        makeMenu value: (MOBottomFlowLayout new).
        makeMenu value: (MOBulletTreeLayout new).
        makeMenu value: (MOCircleLayout new scaleBy: 6).
        makeMenu value: (MODominanceTreeLayout new).
        makeMenu value: (MOFADELayout new).
        makeMenu value: (MOFlowLayout new).
        makeMenu value: (MOForceBasedLayout new).
        makeMenu value: (MOHorizontalDominanceTreeLayout new).
        makeMenu value: (MOFlowLayout new).
        makeMenu value: (MODominanceTreeLayout new).
        makeMenu value: (MOHorizontalLineLayout new).
        makeMenu value: (MOHorizontalNarrowTreeLayout new).
        makeMenu value: (MOHorizontalTreeLayout new).
        makeMenu value: (MOMinimumGridLayout new).
        makeMenu value: (MOVerticalNarrowTreeLayout new).
        makeMenu value: (MORadialTreeLayout new).
        makeMenu value: (MOSpringLayout new).
        makeMenu value: (MOSugiyamaLayout new).
        makeMenu value: (MOTreeLayout new).
        makeMenu value: (MOVerticalLineLayout new).
                       
        "Define some nodes and edges"
        view
                nodes: (10 to: 70 by: 10)
                forEach:
                [ :each |
                        view shape rectangle size: 20; withText.
                        view nodes: ( each+1 to: each+9).

                        view edge: each+1 from: each+1 to: each+2.
                        view edge: each+1 from: each+1 to: each+3.
                        view edge: each+1 from: each+1 to: each+4.
                        view edge: each+2 from: each+2 to: each+5.
                        view edge: each+2 from: each+2 to: each+6.
                        view edge: each+2 from: each+2 to: each+7.
                        view edge: each+3 from: each+3 to: each+7.
                        view edge: each+3 from: each+3 to: each+8.
                        view edge: each+3 from: each+3 to: each+9.
                       
                        view circleLayout scaleBy: 6.
                ].
        view circleLayout scaleBy: 25.
       
        view open
_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: new Mondrian example 'changing subview layout interactively'

abergel
Here a screenshot of Ben's script:


We will soon release Roassal. Within 2 or 3 days. Roassal is truly mind blowing :-)

Cheers,
Alexandre


On 1 May 2012, at 12:58, Ben Coman wrote:

Just sharing a cool result of some experimentation with Mondrian.  I was pleasantly surprised with what I ended up with.
Contents of attached text file can be copied to Workspace.  Also I've uploaded this for Mondrian Easel as Mondrian-Example-BenComan.44.

cheers -ben


| view b actionBlock makeMenu |

view := MOViewRenderer new.

"Define shape such that the MOLayout name is displayed above the subview children"
b := MOFormsBuilder new.
b column; fill; row; fill; row; fill .
b x:1 y:1 add:
( MORectangleShape new
text: [ :value | (view nodeForDomainValue: value) layout. ];
textAlignment: #center;
borderColor: Color white
) .
b x:1 y:2 add: ( MORectangleShape new ) .
b x:1 y:2 add: ( MOChildrenShape new ) .
view shape: b shape.

"Define menus for setting the layouts of subviews"
actionBlock :=
[ :selectedValue :newLayout |
| element position |
element := view nodeForDomainValue: selectedValue.
position := element bounds origin.
element layout: newLayout.
element applyLayout.
element resetFormCacheUpToTheRoot.
element translateBy: position.
view updateWindow.
].
makeMenu :=
[ :layout |
view interaction item: (layout class name asString) action: [ :selectedValue | actionBlock value: selectedValue value: layout ].
].
makeMenu value: (MOGridLayout new).
makeMenu value: (MOBottomFlowLayout new).
makeMenu value: (MOBulletTreeLayout new).
makeMenu value: (MOCircleLayout new scaleBy: 6).
makeMenu value: (MODominanceTreeLayout new).
makeMenu value: (MOFADELayout new).
makeMenu value: (MOFlowLayout new).
makeMenu value: (MOForceBasedLayout new).
makeMenu value: (MOHorizontalDominanceTreeLayout new).
makeMenu value: (MOFlowLayout new).
makeMenu value: (MODominanceTreeLayout new).
makeMenu value: (MOHorizontalLineLayout new).
makeMenu value: (MOHorizontalNarrowTreeLayout new).
makeMenu value: (MOHorizontalTreeLayout new).
makeMenu value: (MOMinimumGridLayout new).
makeMenu value: (MOVerticalNarrowTreeLayout new).
makeMenu value: (MORadialTreeLayout new).
makeMenu value: (MOSpringLayout new).
makeMenu value: (MOSugiyamaLayout new).
makeMenu value: (MOTreeLayout new).
makeMenu value: (MOVerticalLineLayout new).

"Define some nodes and edges"
view
nodes: (10 to: 70 by: 10)
forEach:
[ :each |
view shape rectangle size: 20; withText.
view nodes: ( each+1 to: each+9).

view edge: each+1 from: each+1 to: each+2.
view edge: each+1 from: each+1 to: each+3.
view edge: each+1 from: each+1 to: each+4.
view edge: each+2 from: each+2 to: each+5.
view edge: each+2 from: each+2 to: each+6.
view edge: each+2 from: each+2 to: each+7.
view edge: each+3 from: each+3 to: each+7.
view edge: each+3 from: each+3 to: each+8.
view edge: each+3 from: each+3 to: each+9.

view circleLayout scaleBy: 6.
].
view circleLayout scaleBy: 25.

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

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






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