Hi Roberto,
First of all, I really would like to thank you for your email. This kind of emails are really important for improving Roassal.
I have solved your problem. Check this video: https://vimeo.com/75820243
Even though the solution is quite ad-hoc, I think you can play with it. Consider the following examples:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"View"
| view elements stack t running |
view := ROView new.
view @ RODraggable.
"Stack, useful to have a menu"
stack := ROViewStack new.
stack addView: view.
t := 0.
running := nil.
stack addMenu: '+1' callBack: [ :evt |
t := t + 1.
view elementsDo: #remove.
elements := (ROElement forCollection: (1 to: t)) collect: [:e | e + (ROBorder gray size: 200) + ROBox ].
view addAll: elements.
running := view elements first.
view elements allButFirst do: [ :el |
view add: (ROEdge lineFrom: running to: el).
running := el.
].
" ROHorizontalLineLayout on: view elements.
" (ROTreeMapLayout withWeightBlock: [ :e | e model ]) applyOn: elements.
].
stack open.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"View"
| view elements stack t classes |
view := ROView new.
view @ RODraggable.
"We prepare the data"
classes := ROShape withAllSubclasses asSortedCollection: [ :c1 :c2 | c1 name < c2 name ].
t := 0.
"Stack, useful to have a menu"
stack := ROViewStack new.
stack addView: view.
stack addMenu: '+1' callBack: [ :evt |
"Increment the amount of classes found in the visualization"
t := t + 1.
"We clean the view"
view elementsDo: #remove.
elements := (ROElement forCollection: (classes copyFrom: 1 to: t)) collect: [:e | e + (ROBorder gray size: 200) + ROBox @ ROPopup ].
view addAll: elements.
view elements allButFirst do: [ :el |
view addAll: (ROEdge buildEdgesFromElements: elements from: #superclass to: #yourself).
].
" ROTreeLayout on: view elementsNotEdge edges: view elementsAsEdge.
" (ROTreeMapLayout withWeightBlock: [ :e | e model numberOfLinesOfCode]) applyOn: elements.
view signalUpdate.
].
stack open.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Alexandre
--
On Sep 30, 2013, at 4:21 AM, roberto.minelli@usi.ch wrote:
> Hi,
>
> I am playing around with Roassal (in particular, a tree map) and I have a question: Is there a way to dynamically adding nodes? I mean, once the view is generated to update the #nodes by adding a new node (and associations as well, i.e., edges) and have the visualization re-
>
> At the moment I managed to have something *almost* working, but the behavior of the ROTreeMapLayout is not clear to me.
>
> Using the ROMondrianViewBuilder I can specify the size of the Tree map, but then I am not able to dynamically add nodes. Well, at least I did not manage to do that. So I moved to pure Roassal, as suggested by Alejandro.
>
> Here's how my actual code looks like: http://ws.stfx.eu/CFM522Z9X3ES
>
> I am a beginner with Roassal, so I spend some time to figure out how to draw the tree map in this way. I did not really quite understand why I have to add the ROBox new size: 200 to the ROElement, but I'll figure it out.
>
> The thing is when I try to add the new node. Following, again, Alejandro's advice I am writing something like:
>
> "I add a new node, re-layout the view, and signalUpdate"
> rawView add: ((ROElement on: 10) + (ROBox new size: 200)).
> (ROTreeMapLayout withWeightBlock: [ :e | e model ]) applyOn: rawView elements.
> rawView signalUpdate .
>
> The result is quite strange, the view is indeed updated but I cannot understand why all sizes are messed up.
>
> I think that once I apply the layout, the "elements" array is actually changed (i.e., sizes, parents, resize strategy). Am I correct? is it the correct behavior?
>
> My questions, in short are: How can I fix the overall size of the tree map? Am I doing everything correct till now?
>
> Thanks again for your help,
> Roby
> _______________________________________________
> Moose-dev mailing list
> Moose-dev@iam.unibe.ch
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
_______________________________________________
Moose-dev mailing list
Moose-dev@iam.unibe.ch
https://www.iam.unibe.ch/mailman/listinfo/moose-dev