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:,
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:
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:
rectangle; linearFillColor: #numberOfLinesOfCode within: classes;
view nodes: classes.
As you can see, there are no instantiations and no parentheses :). I
am using a special class (ShapeRenderer) and cascading.
On Apr 17, 2008, at 11:21 PM, Alexandre Bergel wrote:
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 nodes: each classes.
i am nearly there :-)
Alexandre Bergel http://www.bergel.eu
Moose-dev mailing list
"Beauty is where we see it."