Introduction to the JViews TGO layer policy

Article ID: 2126
Last updated: 28 May, 2018
Article ID: 2126
Last updated: 28 May, 2018
Revision: 3
Views: 809
Posted: 26 Jan, 2011
by Dean J.
Updated: 28 May, 2018
by Gargani A.

Question

How do I implement my own layer policy?

Answer

Introduction to Layers

Layers are storage places for graphic objects in a grapher. 
The layer policy defines the layer on which an object is placed.

The Rogue Wave ILOG JViews TGO grapher applies the following default layer policy:

  • Nodes are gathered on the same layer.
  • Links are gathered on a layer below the node layer.
  • Polygons are gathered on a layer below the link layer.
  • Expanded subnetworks are gathered on a layer below the node layer.
JViews TGO adopts the following conventions for displaying network objects and their associated decorations:
  • Within a layer, a graphic object is displayed with all its related decorations (site label, function icon, family label, status icon, and so on).
  • The only exception concerns alarm balloons, which are systematically displayed above all the objects in the view. Information windows are displayed above all other objects.

Expanded subnetworks are also graphers, therefore each subnetwork has its own set of layers and the same layer policy applies.

The layer choice for a given object (along with all its associated decorations) can be customized through the class IltLayerPolicy. 
You can find a complete sample in the JViews TGO distribution, see:

<JViewsTGO-installDir>/samples/network/decoration/srchtml/decoration/CustomLayerPolicy.java.html

Sample decoration

In this sample, the layer policy defines the layer on which each decoration of an object representation is placed.

Visibility Handling

Visibility can be controlled at the adapter level through the use of the filter capabilities, but the layer policy can also be used to handle in-memory visibility of graphic objects. Take the following two examples:

  • Alarm Visibility : You want to put the objects with alarms on one layer and the objects without alarms on another layer. This way, you can choose to set a layer to invisible to display only the objects with alarms.
  • Parallel Networks : You have two parallel networks and you want to display only one at a time, or have the possibility to switch the network visibility.

1- Alarm Visibility

You have to check if the object has an alarm and then put it on the corresponding layer. 
Using the sample of the distribution, you must declare a layer for the objects with alarms (for example, _alarmLayer) and another layer for the objects without alarms (for example, _noAlarmLayer), instead of declaring a layer for the groups, one for the links, and so on. 
The "sorting" is done through the method IltLayerPolicy.getDefaultLayer(). Here, you can check whether the IltObject.AlarmCountNumberAttribute attribute value from the representation object is greater than 0 . If you must work with different alarm severities, you can, for example, use the IltObject.AlarmHighestSeverityAttribute attribute value from the same representation object.

The following code is a possible implementation for the method IltLayerPolicy.getDefaultLayer():

public IltcLayer getDefaultLayer (IltcCompositeGraphic graphic) {
if (graphic instanceof IltCompositeGraphic) { 
IlpRepresentationObject object = graphic.getRepresentationObject();
if (null != object) { 
Object 
alarmCount = object.getAttributeValue(IltObject.AlarmCountNumberAttribute);
if(alarmCount instanceof Integer && ((Integer)alarmCount).intValue() > 0)
return _alarmLayer;
else
return
 _noAlarmLayer;
}
}
return _mainLayer;
}

Each time the graphic object is internally recomputed, the layer policy puts the corresponding object on the correct layer. 
After the layer policy is implemented, you can turn the layer visibility on or off, so that only the objects of one layer are visible.

Note: Make sure that the alarm balloons are not on the same layer as the nodes, links, or groups. If you only turn off the visibility of the layer corresponding to a type of object, the alarm balloons are still visible. Therefore, you must also turn off the visibility of the alarm balloon layer.

2- Parallel Networks

Suppose that you have two networks in the same grapher but you do not want to systematically display both. Sometimes, you want to display only one of them and sometimes both.

Using the layer policy leads you to create two layers per object collection (alarm balloons, info windows...). The alarm balloons are displayed even when the elements to which they belong are on an invisible layer, as explained in the previous paragraph. This means that, if you turn off the visibility of a network in which some objects have alarms, the alarms are visible whereas the objects themselves are not. 
Therefore you must create two layers for the alarm balloons, two layers for the information windows, and so on.

To put an object on the proper layer, you can set a property to the object when you create it and use this property in the method IltLayerPolicy.getDefaultLayer() to know on which layer the object must be placed.

The following code is a possible implementation of the method IltLayerPolicy.getDefaultLayer():

public IltcLayer getDefaultLayer (IltcCompositeGraphic graphic) {
if (graphic instanceof IltCompositeGraphic) {
IlpRepresentationObject object = graphic.getRepresentationObject();
if (object != null) {
Object networkType = object.getAttributeValue(SOME_TYPE_ATTRIBUTE); 
if
 ("Type_A" == networkType) {
if (object instanceof IltGroup)
return _firstGroupLayer;
else
if
 (object instanceof IltAbstractLink)
return _firstLinkLayer;
else
return
 _firstMainLayer;
else {
if (object instanceof IltGroup)
return _secondGroupLayer;
else
if
 (object instanceof IltAbstractLink)
return _secondLinkLayer;
else
return
 _secondMainLayer;
}
}
}
return _secondMainLayer;
}

Another solution consists in using two IltCompositeGrapher instances and work with the visibility of the objects. 
The main constraint is that you cannot have objects that are common to the two networks. If some objects must be displayed in both networks, you must create them twice.

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2126
Last updated: 28 May, 2018
Revision: 3
Views: 809
Posted: 26 Jan, 2011 by Dean J.
Updated: 28 May, 2018 by Gargani A.
Also listed in


Others in this category