Integrating the Flag renderer

There are two ways to integrate a new renderer:

Declare the renderer

For maximum efficiency, declare the flag renderer in the style sheet.
In this example, there is a specific rule to create the flag if the model object matches a particular state. The Flag renderer fetches the graphic property Flag from the rule to get the IlvGraphic object that will represent the flag, in this case the label “ALARM HERE”.
The following code example shows the style rules needed.
The style rules for the flag
node[state=alarm] {
      Flag : @#alarm
}

Subobject#alarm {
        class        : 'ilog.views.sdm.graphic.IlvGraphicFactories$ZoomableLabel' ;
        label        : "ALARM HERE" ;
        antialiasing : true ;
        leftMargin   : 5 ;
        rightMargin  : 5 ;
        topMargin    : 5 ;
        bottomMargin : 5 ;
        foreground   : red ;
}

node {
     Flag : ’’ ;
}
The rules operate as follows:
  1. The first rule sets an indirection to create the IlvGraphic object when it is needed.
  2. The second rule creates the flag as a simple red label.
  3. The third rule clears the flag when the node reverts to its normal state. The default value for the flag is then null.

Register the renderer

The simplest way to integrate a renderer is to register the renderer so that it will be understood when the style sheet is read.
To register a renderer, just call the static method addRendererAlias, in the class IlvRendererUtil.. You must do this before you load a style sheet. The following code example shows the code line (highlighted) for the Flag Renderer.
Registering the Flag renderer in Java™ code
public static void main(String[] args)    {
   IlvRendererUtil.addRendererAlias("Flag", "tutorial.FlagRenderer");
   SDMViewer v = new SDMViewer();
   v.init(args);
}
The arguments of the method are as follows:
  • First argument: the symbolic name used in the style sheet
  • Second argument: the fully qualified class name of the renderer, which will be dynamically loaded when needed
After being registered, the Flag renderer is ready to use in a style sheet, like any other renderer. The following code example shows a simple example of rules that use it.
Simple style rules for a registered Flag renderer
SDM {
   Flag : true ;
}
Flag {
   flagLayer : 30 ;
}