Layers

The grapher in JViews TGO has a set of predefined rules for assigning layers to objects that are inserted in the grapher. The choice of layer for a given object can be customized using the abstract class IltLayerPolicy. The IlpNetworkView class provides the following default layering policy in setLayerPolicy, for which no coding is required:
  • Nodes are gathered in the same layer.
  • Links are gathered in a layer below the node layer.
  • Regions are gathered in a layer below the link 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.
The layer in which a representation object is displayed (along with all its associated decorations) is determined by the IltLayerPolicy.
Note
The network and each of its subnetworks have their own set of layers. The descriptions concerning layers apply separately to each grapher.
JViews TGO provides support for layers in the form of a layer policy and a layer visibility.

Layer policy

Each graphic representation of an object is an instance of the class IlpGraphic. It has a set of decorations that are instances of the class IlvGraphic. (Note that the IlpGraphic class itself is a subclass of IlvGraphic .) The graphic representations ( IlpGraphic ) are layered according to a given order, and so are the decorations. The mechanism that defines the stacking order for decorations and graphic representations is called layer policy, and is implemented by the abstract class IltLayerPolicy. This mechanism defines how two graphic representations overlap and ensures that their decorations do not intertwine. See the stacking order defined at the beginning of Layers.
Each IlpNetworkView has a layer policy that defines in which order the objects will be displayed in the grapher. This layer policy is created during initialization, but you can also modify it through the IltCompositeGrapher class:
You get the IltCompositeGrapher that belongs to an IlpNetworkView by calling network.getView().getCompositeGrapher() .
The layer policy is responsible for allocating specific layers in the Rogue Wave® JViews grapher. The grapher is used to define the stacking order of the decorations. JViews TGO provides a specific class for handling layers called IltcLayer. This interface is the extension of IlvManagerLayer for IlpGraphic objects. Even though JViews TGO uses IltcLayer instances, it is also possible to use IlvManagerLayer instances directly to place graphic objects like map backgrounds or annotations.
Important
The created layers must be referenced using IlvManagerLayer instead of the layer numbers, since JViews TGO may cause layers to be added or removed, which invalidates the previous layer numbers.
To create your own layer policy, you will have to implement the IltLayerPolicy interface that defines the following methods:
  • public IltcLayer getDefaultLayer (IlpGraphic graphic) . This method returns the IlpLayer into which the main objects will be inserted. If you want to define specific layers according to the type of object, you should implement this method.
  • public IltcLayer getElementLayer (IlpGraphic graphic, IltGraphicElementName element) . This method returns the IltcLayer into which a specific decoration will be inserted. This method determines whether alarm balloons will be displayed on top of the other decorations.
  • public boolean isRemovable (IltcLayer layer) . This method indicates which layers cannot be removed; for example, all the layers created by this layer policy.
The layers returned by the methods above can be created in layer policy initialization. The class IltCompositeGrapher provides methods through its superclass for dynamically allocating the layers in the grapher to execute this operation.
  • addLayerOnTop/addLayerBelow (IltcLayer layer) . These methods create a new IltcLayer above or below the given IltcLayer .
  • addLayerOnTop/addLayerBelow (IlvManagerLayer layer) . These methods create a new IltcLayer above or below the given IlvManagerLayer .
  • addIlvManagerLayerOnTop/addIlvManagerLayerBelow (IltcLayer layer) . These methods create a new IlvManagerLayer above or below the given IltcLayer .
  • addLayerOnTop . This method creates a new IltcLayer on top of all the other layers of this grapher.
  • addLayerAtBottom . This method creates a new IltcLayer beneath all the other layers of this grapher.
The following code extract shows you how to create layers.

How to create layers

public MyLayerPolicy (IltCompositeGrapher grapher) {
  _groupLayer = grapher.addLayerOnTop ();
  _linkLayer = grapher.addLayerOnTop();
  _mainLayer = grapher.addLayerOnTop();
  _alarmBalloonLayer = grapher.addLayerOnTop();
  _infoWindowLayer = grapher.addLayerOnTop();
  _systemWindowLayer = grapher.addLayerOnTop();
}

public IltcLayer getElementLayer (IlpGraphic graphic,
                                  IltGraphicElementName element) {
  if (element == IltGraphicElementName.AlarmBalloon)
    return _alarmBalloonLayer;
  else if (element == IltGraphicElementName.InfoWindow)
    return _infoWindowLayer;
  else if (element == IltGraphicElementName.SystemWindow)
    return _systemWindowLayer;
  return null;
}
Note
When you use the layer policy and your own layers in an IlpNetworkView , JViews TGO expects all the layers for IlpGraphic instances and decorations to be adjacent. For example, if you intend to load an IVL file that has predefined layers for the vectorial elements, these layers must be previously allocated in the IlvGrapher instance before you create the IlpNetworkView . (See IlvManager in the Rogue Wave JViews Java™ API Reference Documentation for information on how to create layers.)

Layer visibility

The layering mechanism is frequently used to hide and show collections of objects. Since JViews TGO manages the allocation of layers and the distribution of IlvGraphic instances on them, the following methods are available for controlling the visibility of collections of objects.
There are three possible mechanisms for modifying the visibility of layers:
  • To set the visibility of a specified JViews TGO layer to on or off, use the following:
    • setVisibleIltCompositeGrapher.setVisible (IltcLayer layer, boolean visibility).
  • To set the visibility of a specified Rogue Wave JViews Manager layer to on or off, use the following:
    • setVisibleIlpNetworkView.setVisible (IlvManagerLayer layer, boolean visibility).
  • To indicate that the layer must be hidden or displayed at a specific moment, use the following filter:
    • addVisibilityFilterIltcLayer.addVisibilityFilter (IlvLayerVisibilityFilter filter)
      See IlvLayerVisibilityFilter in the Rogue Wave JViews Java™ API Reference Documentation.
      Note
      The visibility of layers in subnetworks cannot be changed. Only layers in the top level of the grapher can be made invisible.
To control the visibility of an individual IlpObject, use the methods addObject or removeObject on IlpMutableDataSource. You can also use filters, or assign accepted or excluded classes to the component adapter (see Filtering for details).
To control the visibility of an individual IlpRepresentationObject use the methods addRootObject or removeRootObject on IlpMutableNetworkModel. For objects belonging to a container, use addChild or removeChild.