Styling > Using Cascading Style Sheets > Changing the Icon Color of Predefined Business Objects

This use case shows you how to change the color of business objects that belong to a predefined business class. It applies to the tree, network, and equipment graphic components.

In this case, the predefined business class is an extension of IltNetworkElement. The color is customized with the property foreground

The following extract of XML represents the definition of a business class that extends the predefined business class IltNetworkElement.

How to Extend a Predefined Business Class
<class>
  <name>myNetworkElement</name>
    <superClass>ilog.tgo.model.IltNetworkElement</superClass>
    <attribute>
      <name>siteName</name> <javaClass>java.lang.String</javaClass>
    </attribute>
    <attribute>
       <name>customerName</name>  <javaClass>java.lang.String</javaClass>
    </attribute>
</class>
How to Use Literal Values for Customizing Colors
object.myNetworkElement {
    foreground: '#FF0000';
}

In this example, the foreground color of the icon representing business objects of the class myNetworkElement is set to red.

How to Customize the Icon Color Based on Specific Attribute Values
object.myNetworkElement[type=NE] {
       foreground:'#FFFFFF';
}
object.myNetworkElement[type=MD] {
       foreground:'#C0C0C0';
}
object.myNetworkElement[type=Server] {
       foreground:'#FFCC00';
}
object.myNetworkElement[type=BSC] {
       foreground:'#FFB200';
}
object.myNetworkElement[type=Desktop] {
       foreground:'#FF0000';
}

In this example, the foreground color of the icon representing business objects of the class myNetworkElement is set to depend on the value of the attribute type defined in the class IltNetworkElement. So myNetworkElement with the type NE will have a white foreground.