The
Coloring
renderer allocates colors automatically to nodes or links or both,
depending on one of their properties. This is useful when you want
to represent objects with different colors depending on a given
property, but you do not know in advance how many different values
the property will take. There are two ways to set colors.
With the first way, you use the custom function called
coloring
of the
Coloring
renderer which returns the color mapped to the model property
value. The following code example shows a style rule that sets the
foreground color according to the level of the node.
Using a custom function to set coloring in
the style sheet
node[level] { foreground : @|coloring(level); }
This rule states that all nodes that define the
level
property will be visualized with the
foreground
property set to a color computed according to the
level
value. Objects with the same
level
value will have the same color.
With the second way, you use the two properties
colorProperty
and
indexProperty
of the
Coloring
renderer. These properties can be set to achieve a similar,
although more global, behavior, as shown in the following code
example.
Using the Coloring renderer to set global
coloring
Coloring { colorProperty : foreground; indexProperty : level; }
This rule sets the
foreground
property for all nodes that have the
level
property.
The first way is preferred since the object
selectors can be more specific than the coloring renderer global
setting.
The following table lists the properties of the
Coloring
renderer:
Global properties of the Coloring
renderer
Property
|
Type
|
Default
|
Description
|
---|---|---|---|
alpha
|
float
|
1.0
|
The alpha value (that is, the
transparency) of the allocated colors.
|
brightness
|
float
|
1.0
|
The brightness of the allocated colors.
|
colorProperty
|
String
|
“foreground”
|
The color property to set on the graphic
objects.
|
hue
|
float
|
0.0
|
The hue with which the color allocation
algorithm will start.
|
indexProperty
|
String
|
null
|
The object property used as an index to
allocate colors.
|
saturation
|
float
|
1.0
|
The saturation of the allocated colors.
|
The
Coloring
renderer does not have any per-object rendering properties.
See the class IlvColoringRenderer for more details.