Hi Alex,
You should never need to talk with NodeFigure :).
In Mondrian there are 5 important concepts:
- Entity represents the object to be drawn
- Figure (Node and Edge) represents the graphical object that shows the Entity. However, a Figure does not know how to draw itself. A Figure is also a graph.
- Shape specifies the actual drawing transformation.
- Layout specifies the algorithm of arranging a graph.
- ViewRenderer is the facade that provides the scripting language. The basic methods in ViewRenderer are: #nodes:using:, #nodes:using:forEach:, #edges:from:to: All the rest methods are derived from these ones.
In your case, you want to build nodes and set the shape to be rectangle with a linear color based on a metric.
This would be: view nodes: classes using: ((RectangleShape new linearFillColor: #numberOfLinesOfCode within: classes) decoratedWith: BorderShape new).
In this case, we used a RectangleShape and a linearFillColor:within: that performs the linearization of the color based on the given metric. You could also just use #fillColor: to set a manual color.
But, because we wanted Mondrian scripts to not need to instantiate directly, we also allowed for the shape to be defined *before* a view nodes: or view edges:from:to:
Thus, the above script would transform to: view newShape rectangle; linearFillColor: #numberOfLinesOfCode within: classes; withBorder. view nodes: classes.
As you can see, there are no instantiations and no parentheses :). I am using a special class (ShapeRenderer) and cascading.
Cheers, Doru
On Apr 17, 2008, at 11:21 PM, Alexandre Bergel wrote:
Dear list,
I wish to color some nodes according using a metric. Ideally, I would love to use something like: view nodes: each classes forEach: [:node| node setColor: (...)].
But setColor:, color: are not defined on Mondrian.NodeFigure.
Each node may potentially have a different color.
I tried to use "view node: ... forIt: ..." and "view nodes: aCollection using: aShape " but this was not successful.
I found a way to color all nodes contained in a view with:
view nodes: packages forEach: [:each | view blueRectangleShape. view nodes: each classes. view gridLayout.]. -=-=-=-=-=-=-=-=-=-=-=-=
i am nearly there :-)
Any help?
Cheers, Alexandre
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- www.tudorgirba.com www.tudorgirba.com/blog
"Beauty is where we see it."