skip to main content
Diagrammer > Programmer's documentation > Developing with the JViews Diagrammer SDK > Using and adding renderers > Using renderers in the style sheet
 
Using renderers in the style sheet
Shows how to define renderers in the style sheet.
*Enabling a renderer
*Describes how to enable a renderer in the style sheet.
*Customizing a renderer
*Describes how to customize a renderer in the style sheet.
*Using rendering properties on objects
*Provides information on customizing the behavior of a renderer on specific objects.
Enabling a renderer
To enable a renderer, simply set the declaration <renderer-name> : true; in a style rule with a selector that matches SDM.
The following code example shows a style rule that enables the Decoration and LinkLayout renderers.
 
 
SDM {
   Decoration : true;
   LinkLayout : true;
}
Customizing a renderer
To customize one of the renderers, you write a style rule with a selector that is the renderer name and declarations that set properties of the renderer. Each renderer is implemented by a JavaBean™, and you can set any property of the bean in the style rule.
For example, the LinkLayout renderer is implemented by the class IlvLinkLayoutRenderer. This class defines a property called performingLayoutOnZoom which requires the layout algorithm to be reapplied each time the view is zoomed in or out. The following code example shows a style rule that customizes the LinkLayout renderer to reapply the layout algorithm in this way.
Customizing a renderer in the style sheet
 
LinkLayout {
   performingLayoutOnZoom : true;
}
Some renderers have a “default” property that you can set directly in the SDM rule instead of setting it in the renderer’s customization rule. For example, the default parameter of the GraphLayout renderer is the name of the layout algorithm to apply. The following code example shows how to customize this renderer directly in the SDM rule.
Customizing a renderer directly
 
SDM {
   GraphLayout : "Hierarchical";
}
Direct customization in the SDM rule is a shortcut for the longer way, which is shown in the following code example.
Customizing a renderer the longer way
 
SDM {
   GraphLayout : true;
}
GraphLayout {
   graphLayout : "Hierarchical";
}
Using rendering properties on objects
In addition to the general rules for renderers, you can write specific rules to customize the behavior of a renderer on a per-object basis through rendering properties. Rendering properties can be seen as additional properties of the graphic objects which you can set to tell a renderer how it should handle a particular object.
For example, the GraphLayout renderer defines a rendering property called Fixed. When this property is set to true, the GraphLayout renderer will keep the position of the object unchanged. The following code example shows a style rule that sets the Fixed property.
Customizing the layout of a type of node
 
node.participant {
   shapeType : "Ellipse";
   Fixed : "true";
}
This rule says that the nodes of type participant must not be moved when a graph layout is applied. As you can see, you can mix “real” properties of graphic objects (such as shapeType ) with rendering properties (such as Fixed ).
Important By convention, most rendering properties start with an uppercase letter, whereas the properties of graphic objects start with a lowercase letter.
The following predefined renderers do not have rendering properties:
*Coloring
*Decoration
*LabelLayout
*Legend
If a rendering property conflicts with a graphic object property (which should generally not happen), you can use the pseudo-class construct to restrict a rule to a specified renderer. As an example, suppose you have written a custom graphic object which also has a property called Fixed. The following code example shows a style rule which specifies that the property is to be set only in the renderer (not in the custom graphic object).
Setting a renderer property for a graphic object
 
node.participant:renderer {
   Fixed : "true";
}
The pseudo-class renderer is interpreted as the renderer which has the property called Fixed.
The pseudo-class specification can also be the name of the renderer with an initial lowercase letter, for example, graphLayoutRenderer.

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.