Developing with the SDK > Using and Adding Renderers > Predefined Renderers > The Coloring Renderer

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. Code Sample 4.7 shows a style rule that sets the foreground color according to the level of the node.

node[level] {
   foreground : @|coloring(level);
}

Code Sample 4.7 Using a Custom Function to Set Coloring in the Style Sheet

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 Code Sample 4.8.

Coloring {
   colorProperty : foreground;
   indexProperty : level;
}

Code Sample 4.8 Using the Coloring Renderer to Set Global Coloring

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:

Table 4.1 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 ilog.views.sdm.renderer.IlvColoringRenderer for more details.