Configuring a network component through a CSS file

You can customize the following features in a CSS file:
  • Network view
    • Toolbar visibility
    • Toolbar buttons
    • Overview window
    • View interactor
    • Zoom policy
    • Node layout
    • Link layout
    • Label layout
    • Background maps
    • Position converter
  • Network Adapter
    • Expansion
    • Filtering
    • Origin
    • Node factory
    • Link factory
    • Accepted classes
    • Excluded classes

How to load a CSS file in a network component

The network configuration can be split across several CSS files. The method setStyleSheets accepts several CSS filenames.
There are three ways to apply a CSS configuration to a network component, depending on whether you have one or several configuration files:
  • If you have a single configuration file and you do not want to inherit the settings from the default configuration file, pass the CSS configuration filename to the constructor of IlpNetwork as follows:
    networkComponent = new IlpNetwork(myConfigurationFile);
    
    If no CSS file is specified, the network component uses the default network configuration file, that is, ilog.cpl.network.defaultConfiguration.css from the jviews-tgo-all.jar file.
  • If you have one or several configuration files to be applied, you can specify a project file that lists the style sheets and the data file to be loaded in the component (see Loading a project file). The project file will be as follows:
    <?xml version="1.0"?>
    <tgo xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" 
    xsi:noNamespaceSchemaLocation = "ilog/cpl/schema/project.xsd" 
    style="configurationFile1.css,configurationFile2.css">
      <datasource javaClass="ilog.tgo.datasource.IltDefaultDataSource" 
    fileName="network.xml"/>
    </tgo>
    
    If the settings in two of the CSS files disagree, the effect depends on the order of the filenames in the list: the last file mentioned takes precedence over the first file.
  • If you have several configuration files to be applied together, use the setStyleSheets method as follows:
    networkComponent = new IlpNetwork();
    networkComponent.setStyleSheets(
      new String[] { myConfigurationFile1, myConfigurationFile2 });
    
    or, if you want to inherit and extend the settings from the default configuration file, use setStyleSheets as follows:
    networkComponent = new IlpNetwork();
    networkComponent.setStyleSheets(
      new String[] {
        IlpNetwork.DefaultConfigurationFileName,
        myExtraConfigurationFile
      });
    
    If the settings in two of the CSS files disagree, the effect depends on the order of the filenames in the list: the last file mentioned takes precedence over the first file.

How to configure a network component in a CSS file

The following code represents an example of configuring a network in CSS. It is based on the CSS files located in <installdir> /samples/network/styling where <installdir> is the directory where you have installed JViews TGO.
The configuration in CSS is organized as a set of rules that define properties.
// ***************************************************
// * COMPONENT CUSTOMIZATION                         *
// *                                                 *
// * This section is enclosed by                     *
// *    Network {                                    *
// *    }                                            *
// * and specifies which feature will be customized: *
// * - toolbar      (Network Component's toolbar)    *
// * - view         (Scrollbar configuration)        *
// * - overview     (Presence of an overview)        *
// * - interactor   (Default view interactor)        *
// * - zooming      (Zoom policy set in the view)    *
// * - graphlayout  (Layout for the nodes)           *
// * - linklayout   (Layout for the links)           *
// * - labellayout  (Layout for the labels)          *
// * - positioning  (Position policy for objects)    *
// * - backgrounds  (Backgrounds set in the view)    *
// * - adapter      (Network adapter customization)  *
// ***************************************************
Network {
    toolbar: true;
    interactor: true;
    zooming: true;
    adapter: true;
}

For detailed information about the CSS syntax, refer to Introducing cascading style sheets.

The Network rule

This rule specifies Boolean flags that indicate whether each customizable property is present. For example, customization of the property GraphLayout is not taken into account unless graphlayout: true; is declared in the Network rule.
This feature provides powerful cascading possibilities of CSS files. Thus, you can define GraphLayout customizations in a default CSS file and then turn them on or off in another CSS file.
The following properties are supported in the Network rule. You will find detailed documentation for each of these properties in the Rogue Wave® JViews TGO Java™ API Reference Documentation, package ilog.cpl.network.renderer .
 CSS properties of the network view
Property
Rule Type
adapter
Adapter
toolbar
ToolBar
view
View
overview
Overview
interactor
Interactor
zooming
Zooming
graphLayout
GraphLayout
linkLayout
LinkLayout
labelLayout
LabelLayout
backgrounds
Backgrounds
positioning
Positioning

The ToolBar rule

This rule controls the toolbar.
The property enabled is a Boolean property, with default value true . It controls whether the toolbar is visible or not.
The property external is a Boolean property, with default value false . It specifies whether the placement and visibility of the toolbar are managed by user code instead of internally by the network component.
Buttons can be added through the syntax button[i]: @+ButtonId; followed by the customization setting of the button with the given ButtonId .
A button has a mandatory property, actionType . This property specifies the action triggered by the button or a separator that is added to the toolbar. The value can be:
  • a short name, such as Select , used for predefined actions, or
  • the name of a subclass of AbstractButton with a constructor that takes an instance of IlpViewsView as argument, or
  • the Separator short name to indicate that a separator should be placed in the specified position.

How to add a toolbar separator for the network component

You can add toolbar separators in specified positions of the network component toolbar. When configuring the network component toolbar, you can specify the position where a separator should be placed by using the predefined button action called Separator . This button action supports an optional property, dimension , which allows you to specify the dimensions of the separator in the toolbar.
The following example shows how to achieve this result:
ToolBar {
  enabled: true;
  button[0]: @+SelectButton;
  button[1]: @+Separator;
  button[2]: @+PanButton;
}
Subobject#Separator {
  actionType: "Separator";
  dimension: "20,10";
}
The predefined values for the actionType property are the following:
Predefined values of the actionType property 
actionType Values
Bean Class
Description
ZoomIn
Allows you to zoom in the view
ZoomOut
Allows you to zoom out of the view
ZoomBack
Allows you to go back to the previous zoom level
ZoomReset
Allows you to reset the zoom level to the original level
ZoomView
Allows you to specify a rectangular area on which to zoom
FitToContents
Allows you to fit the contents of the view to the size of the view
ScrollToContents
Allows you to recenter the view
Pan
Allows you to pan the view
Select
Allows you to select and move objects
MakeLink
Allows you to create links
MakeLinearGroup
Allows you to create linear groups
MakePolyGroup
Allows you to create polygonal groups
MakeRectGroup
Allows you to create rectangular groups
EditGroup
Allows you to edit the shape of groups
EditLabel
Allows you to edit labels
EditEquipmentObject
Allows you to edit equipment objects
LabelLayout
Allows you to trigger the label layout
A button can have a property permanent . This is a Boolean property, with default value true . For interactor buttons, this property denotes whether the interactor remains attached after it has performed its action.
A button can have a property name . This property specifies the name by which other elements in the file refer to the button. The default name is the short name used as actionType .
A button can have additional properties, corresponding to Bean properties of the Java™ class. For example, the Select button has the properties multipleSelectionMode , moveAllowed , dragAllowed , editingAllowed , moveThreshold , opaqueMove , showingMovingObject , opaqueDragSelection , opaqueResize , opaquePolyPointsEdition , multipleSelectionModifier , selectionModifier , which are documented in the class ilog.cpl.network.action.toolbar.IlpNetworkSelectButton .
An interactor button can have key or gesture actions attached to it. These actions are triggered by specific keystrokes or gestures while the interactor is active. They are added through the syntax action[i]: @+ActionId; followed by a customization setting for the action.
An action customization has the mandatory property class , which specifies the Java class of the javax.swing.Action object. Bean properties of this class are also customizable and the properties key and gesture can be set to specify when the action is to be executed. These two properties are not used in combination. For example, if you specify:
key: "control A";
gesture: "BUTTON1_CLICKED";
the action will be executed either when the key sequence ‘control-A’ is typed, or when the mouse BUTTON1 is clicked. To define the property gesture , specify one of the predefined user gestures defined in class IlpGesture. To define the property key , specify a string that will be converted to a keystroke by the type converter ( IlpTypeConverter).
The following predefined actions are available:
An interactor can have a pop-up menu factory associated with it. This factory can be specified using the property popupMenuFactory . The value of this property should be a bean that implements the interface IlpPopupMenuFactory. For example,
Subobject#SelectButton {
    actionType: "Select";
    popupMenuFactory: @+popupMenuFactory;
  }
 
Subobject#popupMenuFactory {
    class: 'CustomPopupMenuFactory';
  }
In this example, the value of the property " popupMenuFactory " is a bean that is defined by the class CustomPopupMenuFactory . This class should implement the interface IlpPopupMenuFactory.
For more information on configuring the toolbar in a network view, refer to the class IlpToolBarRenderer.

How to add a predefined toolbar button to the network component

JViews TGO provides a list of predefined toolbar buttons usable in the network component (see Predefined values of the actionType property  ).
The following example shows how to add a predefined button that enables the select interactor. When this interactor is enabled, you can customize actions, pop-up menus and interactor properties as illustrated here:
ToolBar {
  enabled: true;
  button[0]: @+SelectButton;
}

Subobject#SelectButton {
  actionType: "Select";
  usingObjectInteractor: true;
  opaqueMove: true;
  action[0]: @+action0;
  popupMenuFactory: @+popupMenuFactory;
}

Subobject#popupMenuFactory {
  class: 'CustomPopupMenuFactory';
}

Subobject#action0 {
  key: "control A";
  class: 'ilog.cpl.graph.action.IlpSelectAllObjectsAction';
}

How to add a custom toolbar button to the network component

To add your own toolbar button, you need to create a new action class that inherits from IlpNetworkInteractorAction and contains a constructor that takes an IlpViewsView as parameter.
public class CustomButtonAction extends IlpNetworkInteractorAction {

  public CustomButtonAction(IlpViewsView view) {
     super(view);
     // Do any needed initialization
     // Define your own view interactor that will be active when the button is 
selected
     // in the toolbar
     IlpViewsViewInteractor interactor =  new IlpViewsViewInteractor();
     // Register the interactor in this action
     setIlpInteractor(interactor);
  }
}
Then, you need to register this new button in your component configuration, as follows:
ToolBar {
  enabled: true;
  button[0]: @+MyButton;
}

Subobject#MyButton {
  actionType: 'CustomButtonAction';
  toolTipText: "Custom";
  icon: @+customIcon;
}
Subobject#customIcon {
  class: 'javax.swing.ImageIcon';
  image: '@|image("custom.png")';
}
The custom action will be encapsulated in an IlpNetworkInteractorButton, and you will be able to customize the properties of this button as with the predefined buttons. For example, you can customize the following:
  • name
  • usingObjectInteractor
  • popupMenuFactory
  • actions associated with gestures and keystrokes

The View rule

This rule controls the view.
You can customize the following properties of the view:
View properties
Property Name
Type
Default Value
Description
horizontalScrollBarPolicy
int
IlvJScrollManagerView.HORIZONTAL_SCROLLBAR_AS_NEEDED
Defines the policy for the visibility of the horizontal scrollbar
verticalScrollBarPolicy
int
IlvJScrollManagerView.VERTICAL_SCROLLBAR_AS_NEEDED
Defines the policy for the visibility of the vertical scrollbar
keepingAspectRatio
boolean
false
Defines whether the view keeps the aspect ratio when zooming
minZoomXFactor
double
0
Specifies the minimum zoom factor allowed on the X (horizontal) axis of the view
maxZoomXFactor
double
Double.MAX_VALUE
Specifies the maximum zoom factor allowed on the X (horizontal) axis of the view
minZoomYFactor
double
0
Specifies the minimum zoom factor allowed on the Y (vertical) axis of the view
maxZoomYFactor
double
Double.MAX_VALUE
Specifies the maximum zoom factor allowed on the Y (vertical) axis of the view
wheelZoomingEnabled
boolean
true
Defines whether the view zooms in response to moving the mouse wheel while pressing the Control key
wheelScrollingEnabled
boolean
true
Defines whether the view scrolls in response to moving the mouse wheel
The following CSS sample shows how to customize the view:
View {
  horizontalScrollBarPolicy: AsNeeded;
  verticalScrollBarPolicy: Never;
  keepingAspectRatio: true;
}
For more information on configuring a network view, refer to the class IlpViewRenderer.

The Overview rule

This rule controls the overview window.
The property enabled controls the visibility of the overview window. The default value is false .
The following CSS sample shows how to customize the overview:
Overview {
  enabled: true;
}
For more information on configuring the overview window in a network view, refer to the class IlpOverviewRenderer.

The Interactor rule

This rule controls the interactor associated with the view.
You can customize the following properties of the interactor:
Interactor properties
Property Name
Type
Default Value
Description
name
String
none
Specifies the name of a toolbar button that activates an interactor. This button is activated at startup. Its interactor becomes the initial view interactor, as well as the default view interactor when another interactor stops its interaction. This property is only considered when the view has a toolbar configured and enabled.
viewInteractor
IlpViewsViewInteractor
none
Specifies the interactor instance that becomes the initial view interactor, and the default view interactor when another interactor stops its interaction.

How to configure a network interactor in a CSS file

Prior to configuring the network view interactor, you need to configure the network component so that the interactor configuration is enabled:
Network {
  interactor: true;
}
After that, you can customize the interactor property in the Interactor rule as illustrated by the next code extract. for details about the CSS syntax, refer to The CSS specification.

How to set the default view interactor from the toolbar of the network component

You can customize the default view interactor to be one of the interactors present in the toolbar configured for the network component. In this case, the toolbar button is identified when the network component is configured, and it is activated at startup. This interactor becomes the initial view interactor, and the default view interactor when another interactor stops its interaction. This configuration is achieved through the property name , whose value must be the name of one of the configured toolbar buttons.
The following CSS extract configures the network view to use the Select toolbar button as the default view interactor:
Interactor {
  name: "Select";
}

How to set the default view Interactor when the toolbar is disabled in the network view

When the toolbar is disabled, you can no longer specify the default view interactor by using a toolbar button name, as in the example above. However, you can specify the view interactor directly in CSS, as follows:
Interactor {
  viewInteractor: @+viewInt;
}

Subobject#viewInt {
  class: 'ilog.cpl.graphic.views.IlpViewsViewInteractor';
}
The behavior of the view interactor is determined by the actions that are associated with user gestures and keystrokes. This behavior can also be customized through CSS. You can also configure a pop-up menu to be displayed in the network view. For more information about interactor customization, refer to Interacting with the network view and Interacting with the network objects.
When the interactor renderer is enabled, you can also customize objects interactors using property interactor . For further information, refer to IlpInteractorRenderer .

The Zooming rule

This rule controls the zoom policy.
The mandatory property type specifies the type of zoom. The possible values are Logical , Physical , or Mixed . Each zoom policy may have additional properties that you can also set using CSS:
  • Logical zoom policy (see IltLogicalZoomPolicy)
    Logical zoom property
    Property Name
    Type
    Default
    Description
    additionalZoom
    double
    1
    Specifies an additional zoom factor that is implicitly added to the zoom transformer of the view. This property is useful when printing with non standard transformers.
  • Physical zoom policy (see IltPhysicalZoomPolicy)
    Physical zoom properties
    Property Name
    Type
    Default
    Description
    decorationNames
    String[]
    null
    Specifies a list of decoration names that are customized at the zoom policy level. See IltGraphicElementName for a list of decoration names that can be used.
    visibilityThresholds
    double[]
    null
    Specifies a list of thresholds, one for each decoration name customized with property decorationNames . These thresholds indicate the zoom level below which the decorations become invisible in the view. It allows you to hide decorations as the user zooms out in the view.
  • Mixed zoom policy (see IltMixedZoomPolicy)
    Mixed zoom properties
    Property Name
    Type
    Default
    Description
    zoomThreshold
    double
    1
    Specifies the zoom threshold when the physical zoom or the logical zoom should be used
    subnetworkZoomFactor
    double
    1
    Specifies an additional zoom threshold that is applied to expanded subnetworks
    decorationNames
    String[]
    null
    Specifies a list of decoration names that are customized at the zoom policy level. See IltGraphicElementName for a list of decoration names that can be used.
    visibilityThresholds
    double[]
    null
    Specifies a list of thresholds, one for each decoration name customized with property decorationNames . These thresholds indicate the zoom level below which the decorations become invisible in the view. It allows you to hide decorations as the user zooms out in the view.

How to customize the zoom policy in a network component

The following CSS sample shows how to customize the zoom policy in a network view:
Zooming {
  type: "Mixed";
  zoomThreshold: 1.0;
  subNetworkZoomFactor: 1.0;
}
For more information on configuring the zoom behavior in a network view, refer to the class IlpZoomingRenderer.

How to configure the visibility of decorations for a specific network component

JViews TGO provides three predefined zoom policies that you can use directly in the network component. For more information, see Zooming. When using the physical or the mixed zoom policy, decorations may become invisible as the user zooms out in the view. By default, this configuration is global in the application. However, you may need to specify the visibility threshold for a specific view. This feature is supported by properties decorationNames and visibilityThresholds . Property decorationNames specifies each decoration that is configured for the view (see IltGraphicElementName for the list of decoration names that can be customized). Property visibilityThresholds specifies, for each decoration name, the visibility threshold below which the decoration becomes invisible. This configuration is illustrated by the following example:
Zooming {
  type: "Mixed";
  decorationNames[0]: Name;
  decorationNames[1]: AlarmBalloon;
  decorationNames[2]: AlarmCount;
  decorationNames[3]: Plinth;
  visibilityThresholds[0]: 0.5;
  visibilityThresholds[1]: 0.8;
  visibilityThresholds[2]: 0.5;
  visibilityThresholds[3]: 0.5;
}

The GraphLayout rule

This rule allows you to control the automatic node layout in the view and to configure nonautomatic node layouts. Nonautomatic node layouts can only be executed through the API. For more details, see Layout.

How to control the automatic node layout in the network view

Automatic node layout is configured through the property class . This property specifies the graph layout class, a subclass of IlvGraphLayout. Additional Bean properties can be specified, depending on the class.
The following CSS sample shows how to customize the graph layout:
GraphLayout {
    class: 
     'ilog.views.graphlayout.uniformlengthedges.IlvUniformLengthEdgesLayout';
    respectNodeSizes: true;
    preferredLinksLength: 200;
    forceFitToLayoutRegion: true;
    layoutRegion: "50, 50, 700, 450";
}
The graph layout is always a subclass of IlvGraphLayout which supports the " preserveFixedNodes " property. This property allows you to switch the support of fixed nodes on or off. You can set a node as fixed in the business object customization.
Note
If a graph layout is set and supports fixed nodes, a link layout is required when links are connected to the fixed nodes.
The properties of each layout algorithm are fully explained in the Rogue Wave® JViews Diagrammer Using Graph Layout Algorithms documentation.
The properties of the IlvGraphLayout subclasses conform to the following JavaBeans™ convention: if a class has a pair of methods called setMyProp (with a single parameter) and getMyProp (without parameters), then you can set the property myProp in the style sheet.
Note
If the value of the property is an enumeration of integer values defined by static member variables of the class, then you can use the name of the variable alone, or the variable name prefixed by the class name alone, or the variable name prefixed by the fully qualified class name. For example, the following declarations are all valid:
globalLinkStyle: "ORTHOGONAL_LINKS";
globalLinkStyle: "IlvHierarchicalLayout.ORTHOGONAL_LINKS";
globalLinkStyle: "ilog.views.graphlayout.hierarchical.IlvHierarchicalLayout.ORTHOGONAL_LINKS";

How to configure multiple node layouts in a network view

The Graph Layout rule allows you to configure multiple node layouts, and to define the node layout to be used automatically in the view. Multiple node layout configuration is achieved through the properties layouts and autoLayoutIndex , as illustrated below:
GraphLayout { 
  layouts[0]: @+treeLayout;
  layouts[1]: @+hierarchicalLayout;
  layouts[2]: @+springEmbedderLayout;
  autoLayoutIndex: 1;
}

Subobject#treeLayout {
  class: 'ilog.views.graphlayout.tree.IlvTreeLayout';
  flowDirection: Bottom;
}

Subobject#hierarchicalLayout {
  class: 'ilog.views.graphlayout.hierarchical.IlvHierarchicalLayout';
  flowDirection: Bottom;
}

Subobject#springEmbedderLayout {
  class: 'ilog.views.graphlayout.springembedder.IlvSpringEmbedderLayout';
  respectNodeSizes: true;
  preferredLinksLength: 200;
  forceFitToLayoutRegion: true;
  layoutRegion: "50, 50, 700, 450";
}
In this use case, three node layouts are configured for the view: IlvTreeLayout, IlvHierarchicalLayout and IlvSpringEmbedderLayout. The hierarchical layout is configured to be performed automatically when the contents of the view changes. This configuration is achieved by specifying the value of property autoLayoutIndex as the index of the hierarchical layout defined through the layouts property. The other node layouts can be performed on demand using the API (see IlpGraphView.performAttachedLayout ).

How to configure nonautomatic node layouts in the network component

If you are not interested in automatic node layout, you can still configure multiple node layouts in CSS. To have only nonautomatic node layouts, set property autoLayoutIndex to -1 , as illustrated below:
GraphLayout { 
  layouts[0]: @+treeLayout;
  layouts[1]: @+hierarchicalLayout;
  layouts[2]: @+springEmbedderLayout;
  autoLayoutIndex: -1;
}

Subobject#treeLayout {
  class: 'ilog.views.graphlayout.tree.IlvTreeLayout';
  flowDirection: Bottom;
}

Subobject#hierarchicalLayout {
  class: 'ilog.views.graphlayout.hierarchical.IlvHierarchicalLayout';
  flowDirection: Bottom;
}

Subobject#springEmbedderLayout {
  class: 'ilog.views.graphlayout.springembedder.IlvSpringEmbedderLayout';
  respectNodeSizes: true;
  preferredLinksLength: 200;
  forceFitToLayoutRegion: true;
  layoutRegion: "50, 50, 700, 450";
}

How to specify a different node layout for each subnetwork

When the node layout is configured for a view, it is applied to the view and to all the subnetworks displayed in this network view.
However, you can specify different node layouts for subnetworks. The node layouts of subnetworks are configured in CSS using the same properties as for the view configuration ( layouts and autoLayoutIndex ).
When you configure the node layout for a specific subnetwork, you must declare the CSS selector with a specific pseudoclass that identifies the graph layout renderer. The pseudoclass must be graphLayoutRenderer , as illustrated below:
GraphLayout {
  layouts[0]: @+treeLayout;
  autoLayoutIndex: 0;
}

Subobject#treeLayout {
  class: 'ilog.views.graphlayout.tree.IlvTreeLayout';
  flowDirection: Bottom;
}

#SubNetwork:graphLayoutRenderer {
  layouts[0]: @+hierarchicalLayout;
  autoLayoutIndex: 0;
}

Subobject#hierarchicalLayout {
  class: 'ilog.views.graphlayout.hierarchical.IlvHierarchicalLayout';
  flowDirection: Top;
}
The property autoLayoutIndex , when used in an object selector with the graphLayoutRenderer pseudoclass, specifies the automatic node layout that is applied to the subnetwork.
You can also specify nonautomatic node layouts for subnetworks. This configuration is achieved in the same way as for the view configuration ( layouts property with multiple node layouts and the autoLayoutIndex set to -1 ).
When you call the method performAttachedLayout(int index) , it is applied recursively in the model hierarchy. Therefore if a node layout is configured for the given index in the subnetwork, this specific layout is performed. Otherwise, the node layout configured for the parent network is executed.

How to set node or link parameters on graph layout objects in the network component

You can set parameters for a graph layout algorithm that applies to a particular node or link, in the style sheet. Such parameters are defined by a method of the form:
setMyParam(Object node,  value);
or
setMyParam(Object link,  value); 
Node parameters are set in the style sheet as follows:
object."ilog.tgo.model.IltObject":graphLayoutRenderer {
  myParam: "value";
}
The name of the property is the name of the method, without the prefix set . The pseudoclass graphLayoutRenderer indicates that the declarations apply to the node layouts that are configured in the graph layout rule.
For example, the graph layout defines a setFixed method that lets you specify whether a node or link is fixed. Fixed nodes or links are not moved when the layout is applied. The signature of the method is:
setFixed(Object nodeOrLink, boolean fixed);
In the style sheet, you can set this parameter as follows:
object."ilog.tgo.model.IltObject":graphLayoutRenderer {
  fixed: true;
}
The value of the property can be any basic type (integer, String, float), or it can be the name of a public constant defined by the graph layout class, for example, WEST , which is defined in the class IlvHierarchicalLayout .
When the graph layout rule contains multiple node layouts, you can still specify node and link layout parameters by using pseudoclasses that identify the graph layout to which the declarations apply.
GraphLayout {
  layouts[0]: @+treeLayout;
  layouts[1]: @+hierarchical;
  autoLayoutIndex: 0;
}

Subobject#treeLayout {
  class: 'ilog.views.graphlayout.tree.IlvTreeLayout';
  flowDirection: Bottom;
}

Subobject#hierarchicalLayout {
  class: 'ilog.views.graphlayout.hierarchical.IlvHierarchicalLayout';
  flowDirection: Top;
}

#NE1:graphLayoutRenderer:tree {
  root: true;
}

#NE1:graphLayoutRenderer:hierarchical {
  specNodeLevelIndex: 0;
}

#NE2:graphLayoutRenderer:hierarchical {
  specNodeLevelIndex: 1;
}
In the example above, NE1 is configured as the root object for the Tree Layout algorithm. This is achieved by declaring the property root in a selector that contains the pseudoclasses graphLayoutRenderer (indicates that this is a graph layout renderer per-object property) and tree (indicates that this is a property specific to the IlvTreeLayout algorithm).
At the same time, NE1 is configured to be placed at level 0 in case of a hierarchical layout. This is achieved using pseudoclasses graphLayoutRenderer and hierarchical (indicates that this is a graph layout per-object property specific to the IlvHierarchicalLayout algorithm).
Each layout algorithm supports a set of per-object parameters. For more information on the parameters supported by each layout algorithm, refer to package ilog.cpl.graph.css.renderer.graphlayout .
In addition to the properties that are specific to the layout algorithms, the graph layout renderer also supports the following properties:
  • layoutIgnored : If this property is set to true , the object is completely ignored by the graph model (using an IlvLayoutGraphicFilter).
  • markedForIncremental : If the layout algorithm is an IlvHierarchicalLayout , you can use the property markedForIncremental . When this property is set to true for an object, the method IlvHierarchicalLayout.markForIncremental(java.lang.Object) is called for this object. This means that the position of the object is recomputed during the next incremental layout. This property has an effect only if the incrementalMode property of the layout itself is set to true . For example:
    GraphLayout {
      layouts[0]: @+hierarchicalLayout;
    }
    
    Subobject#hierarchicalLayout {
      class: 'ilog.views.graphlayout.hierarchical.IlvHierarchicalLayout';
      incrementalMode: true;
    }
    
    #NE1:graphLayoutRenderer:hierarchical {
      markedForIncremental : "true";
    }
    
Important
Starting with JViews TGO 7.5, if you are not using any node or link parameters, you can disable this mechanism by specifying IlpGraphLayoutRenderer.setUsePerObjectParameters(false) . This will remove the overhead of testing the parameters and speed up the rendering process significantly.

How to disable the per-object layout parameters for node configuration in the network view

You can also disable the per-object layout parameters configuration through CSS as follows:
GraphLayout {
  layouts[0]: @+hierarchicalLayout;
  usePerObjectParameters: false;
}
For more information on configuring the node layout in a network view, refer to the class IlpGraphLayoutRenderer.

The LinkLayout rule

This rule controls the automatic link layout in the view.
The mandatory property class specifies the link layout class, a subclass of IlvGraphLayout . Additional Bean properties can be specified, depending on the class.

How to control the automatic link layout in the network view

The following CSS sample shows how to customize the link layout:
LinkLayout {
    class: "ilog.views.graphlayout.link.IlvLinkLayout";
    globalLinkStyle: MIXED_STYLE;
}
The link layout is always a subclass of IlvGraphLayout which supports the " preserveFixedLinks " property. This property allows you to switch the support of fixed links on or off.

How to specify a different link layout for each subnetwork

When the link layout is configured for a view, it is applied to the view and to all the subnetworks displayed in this network view.
However, you can also specify different link layouts for subnetworks. The link layout is configured in CSS using the property linkLayout and the pseudoclass linkLayoutRenderer , as illustrated below:
LinkLayout {
  class:'ilog.views.graphlayout.link.IlvLinkLayout';
}

#SubNetwork:linkLayoutRenderer {
  linkLayout: @+shortLinkLayout;
}

Subobject#shortLinkLayout{
  class: 'ilog.tgo.graphic.graphlayout.IltShortLinkLayout';
}
Like the graph layout renderer, the link layout renderer supports setting per-object link layout parameters through CSS. See How to set node or link parameters on graph layout objects in the network component.

How to specify per-object parameters for link layouts in the network view

Link parameters are set in the style sheet as follows:
object."ilog.tgo.model.IltAbstractLink":linkLayoutRenderer {
  linkStyle: ORTHOGONAL_STYLE;
}

#Link1:linkLayoutRenderer {
  linkStyle: DIRECT_STYLE;
}
Important
Starting with JViews TGO 7.5, if you are not using any node or link parameters, you can disable this mechanism by specifying IlpLinkLayoutRenderer.setUsePerObjectParameters(false) . This will remove the overhead of testing the parameters and speed up the rendering process significantly.

How to disable per-object layout parameters for link configuration in the network view

You can also disable the per-object layout parameters configuration through CSS as follows:
LinkLayout {
  class: 'ilog.views.graphlayout.link.IlvLinkLayout';
  usePerObjectParameters: false;
}
For more information on configuring the link layout in a network view, refer to the class IlpLinkLayoutRenderer.

The LabelLayout rule

This rule controls the automatic label layout in the view.
The mandatory property class specifies the label layout class, a subclass of IlvLabelLayout. Additional Bean properties can be specified, depending on the class. The usual setting is IltAnnealingLabelLayout.
The following CSS sample shows how to customize the label layout:
LabelLayout {
    class: 'ilog.tgo.graphic.graphlayout.labellayout.IltAnnealingLabelLayout';
    obstacleOffset: 10;
    labelOffset: 15;
}
Note that some properties can be set within the IltAnnealingLabelLayout and some within the IlvAnnealingLabelLayout. For more details, refer to the Rogue Wave JViews TGO Java API Reference Documentation.
For more information on configuring the label layout in a network view, refer to the class IlpLabelLayoutRenderer.

The Backgrounds rule

This rule allows you to configure two kinds of background that affect the network component representation:
  • network background
  • manager view background

Network backgrounds

This refers to background files such as maps or background images. You can specify a network background through:
  1. A URL
    The background file is specified directly by its URL:
    Backgrounds {
      background[i]: "URL"; 
    }
    
    For example:
    Backgrounds {
      background[0]: "backgrounds/sf-bayarea.png"; 
    }
    
  2. A CSS bean
    The background URL and its properties are specified through a CSS bean:
    Backgrounds {
      background[i]: @+background0;
    }
    
    Subobject#background0 {
      class: "ilog.cpl.graph.background.css.IlpBackgroundCSSConfiguration";
    
      PROPERTY :  PROPERTY_VALUE;
      ...  
    }
    
    The bean IlpBackgroundCSSConfiguration encapsulates all the properties supported by the predefined background types. You should use it if want to use one of the predefined types.
    For example:
    Backgrounds {
      background[0]: @+background0;
    }
    
    Subobject#background0 {
      class: "ilog.cpl.graph.background.css.IlpBackgroundCSSConfiguration";
    
      //////////////////////
      //Background properties 
      //////////////////////
      url : "backgrounds/sf-bayarea.png";
      loadOnDemand : "true";
      threaded : "false";
    }
    
    If you intend to use a custom background type that has additional properties, you can either subclass the default IlpBackgroundCSSConfiguration and use it with the additional bean properties. Or you can provide a bean that contains all the required properties to configure the IlpBackground implementation. All bean properties are automatically communicated and stored in the IlpBackground implementation through its IlpBackground.setProperty interface method.
    For details on the properties available and supported for each IlpBackground implementation, see Background support.
You can mix and match options 1 and 2 by specifying some backgrounds as beans and some as straight URL strings.
In the case of the Image Tile background type ( IlpImageTileBackground ), only the url property can be configured through CSS. For the other properties, use the XML configuration. See Background support.

Manager view background

This refers to the representation of the view as a background for your network backgrounds (the area that the network backgrounds do not cover).
You can configure the manager view background as follows:
Backgrounds {
  PROPERTY : PROPERTY_VALUE; 
}
For example:
Backgrounds {
  backgroundColor : "white"; 
}
The following table lists the properties that allow you to customize the manager view background:
Properties of the manager view background
Property Name
Type
Default
Sample
Description
backgroundColor
Color
null
backgroundColor:"black";
Specifies the color to be used to fill the background of the view.
backgroundPattern
String
null
backgroundPattern:"pattern.png";
Specifies the location of the pattern image to be used to fill the background of the view.
For more information on configuring the background in a network, refer to the class IlpBackgroundsRenderer.

The Positioning rule

This rule controls the type and converter of the user-defined IlpPosition.
Predefined business objects rely on x- and y-based IlpPosition types such as IlpPoint , IlpRect , and IlpPolygon . The default position converter, IlpDefaultPositionConverter, acts as a pass-through, enabling conversion of these coordinates to x- and y-based view coordinates.
However, custom business objects ( IlpObject ) may define a position system that is not a direct mapping to the view coordinate system, and may require some adaptation to be properly positioned. For these cases, the positioning rule associates an IlpPosition type with a customized position converter.
Typically you set a customized position converter through the Java API, as it must be in place before the JViews TGO component (Network or Equipment) is populated. Alternatively you can use CSS to set the position converter, but the TGO component must be completely empty before you do this.
The property positionClass denotes the Java class name of the class or interface that implements IlpPosition .
The property converterClass denotes a Java class name or CSS bean that implements the IlpPositionConverter interface and determines the conversion between business data coordinates and (x,y) coordinates in the view.
The following CSS sample shows how to set a customized position converter:
Positioning {
  positionClass: 'my.package.MyPosition';
  converterClass: 'my.package.MyPositionConverter';
}
For more information on configuring the positioning in a network view, refer to the class IlpPositioningRenderer.

The Adapter rule

This rule controls the configuration of the network adapter. The network adapter is responsible for converting the business objects in the data source to representation objects (network nodes) in the network component. It provides the following features:
  • Filtering: applies a filter so that business objects currently in the data source are not mapped to representation objects in the network component.
  • Origins: defines which objects become root nodes in the network.
  • Link factory: defines how a link representation object will be created from its business object counterpart.
  • Node factory: defines how a representation object that is not a link will be created from its business object counterpart.
  • Expansion strategy: defines how the objects will be loaded in the network component, that is, either at initialization time or on demand, as the user interacts with the network nodes.
  • Accepted classes: defines the list of business classes that are accepted by the network adapter. Only the business objects that match one of these business classes will be mapped to representation objects by the network adapter.
  • Excluded classes: defines the list of business classes that are excluded by the network adapter. The business objects of these business classes will not be mapped to representation objects by the network adapter. By default, the IltAlarm business class is part of the list of excluded classes.
These network adapter features can be customized through CSS using the following properties:
CSS properties of the network adapter
Property Name
Property Type
filter
origins
list of object identifiers
networkNodeFactory
networkLinkFactory
expansionStrategyFactory
acceptedClasses
list of IlpClass
excludedClasses
list of IlpClass

How to configure a network adapter in a CSS file

Prior to configuring the adapter, you need to configure the network component so that the adapter configuration is enabled:
Network {
  adapter: true;
}
After that, you can customize each adapter property in the Adapter rule as illustrated by the following code extract. Refer to The CSS specification in the Styling documentation for details about the CSS syntax.
Adapter {
  filter: @+Filter;
}

Subobject#Filter {
  class: 'CustomFilter';
  rejectObject[0]: "NE1";
  rejectObject[1]: "Link5";
}

How to programmatically configure adapter using CSS

You can programmatically modify the CSS configuration of the default network adapter ( IlpNetworkAdapter ) by using mutable style sheets through the IlpMutableStyleSheet API.
Important
The mutable style sheet is set to the adapter as a regular style sheet and is cascaded in the order in which it has been declared.
To use mutable style sheets:
  1. Get the mutable style sheet.
    You access the mutable style sheet through the getMutableStyleSheet() method in the network adapter API:
    IlpMutableStyleSheet mutable = adapter.getMutableStyleSheet();
    
    This method automatically registers the mutable style sheet into the adapter. You can manually instantiate an object of the class IlpMutableStyleSheet and register it yourself through the setStyleSheet() API:
    IlpMutableStyleSheet mutable = new IlpMutableStyleSheet(adapter);
    try {
      adapter.setStyleSheets(new String[] { mutable.toString() });
    } catch (Exception x) {
      x.printStackTrace();
    }
    
  2. Set the CSS declarations.
    Once you have the mutable style sheet, you can set the declarations you want:
    mutable.setDeclaration("#myObjectId", "expansion", "NO_EXPANSION");
    
    This creates the following CSS declaration into the mutable style sheet:
    #myObjectId {
      expansion: NO_EXPANSION;
    }
    
  3. Register the mutable style sheet.
    The mutable style sheet should be set to the adapter as a regular style sheet using the setStyleSheet() method:
    try {
      adapter.setStyleSheets(new String[] { mutable.toString() });
    } catch (Exception x) {
      x.printStackTrace();
    }
    
  4. Set and update the CSS declarations.
    The mutable style sheet can be modified even after being registered to the adapter:
    // Update the expansion type for 'myObjectId'
    mutable.setDeclaration("#myObjectId", "expansion", "IN_PLACE");
    // Add a new declaration
    mutable.setDeclaration("#myOtherId", "expansion", "IN_PLACE");
    
    Note
    Like any style sheet, the mutable style sheet is lost when the setStyleSheet() API is invoked and a new set of style sheets is applied to the adapter.

How to customize the mutable style sheet

Reapplying a CSS configuration may be a heavy task, as the adapter may be forced to review filters, origins, recreate representation objects, and so on. It is important to use the mutable style sheet with care and to customize it properly to reapply the CSS wisely. To do so, there are two methods available in the IlpMutableStyleSheet API: setUpdateMask() and setAdjusting() .
  1. setUpdateMask()
    This method controls what should be recustomized once a declaration of the mutable style sheet has been updated. The CSS configuration of the adapter is divided into two parts: adapter customization and representation object customization.
    The adapter customization handles the origins, filters, and so on:
    Adapter {
      origins[0]: id0;
      origins[1]: id1;
      showOrigin: true;
      filter: @+myFilter;
    } 
    
    The representation object customization handles the expansion type of a representation object:
    #myObjectId {
      expansion: IN_PLACE;
    }
    
    The accepted values for setUpdateMask() are:
    • IlpStylable.UPDATE_COMPONENT_MASK : Only the adapter part is recustomized.
    • IlpStylable.UPDATE_OBJECTS_MASK : Only the representation object part is recustomized.
    • IlpStylable.UPDATE_ALL_MASK : Bot the adapter and representation object parts are recustomized.
    • IlpStylable.UPDATE_NONE_MASK : Nothing is recustomized.
    For example, if you update the expansion type of a representation object through the mutable style sheet, it is recommended that you set the update mask to UPDATE_OBJECTS_MASK as there is no need to reapply the CSS configuration for the adapter part:
    mutable.setUpdateMask(IlpStylable.UPDATE_OBJECTS_MASK);
    mutable.setDeclaration("object", "expansion", "IN_PLACE");
    
  2. setAdjusting()
    This method is used when a series of declarations must be applied to the mutable style sheet. When the method is set to true , the mutable style sheet puts all the calls to setDeclaration() into a queue. When the method is set back to false , all the queued declarations are processed in a batch:
    mutable.setAdjusting(true);
    mutable.setDeclaration("#myObjectId", "expansion", "IN_PLACE");
    mutable.setDeclaration("#myOtherId", "expansion", "IN_PLACE");
    mutable.setAdjusting(false);