Styling > Customizing Shelves and Cards > LED Representation

The graphic representation of LEDs is intended to be simple and reduced. Therefore it is only based on the attributes type, name and on the alarms set in the object state, but not on any other state information.

images/LedRepresentation.gif

Figure 8.5 A LED Representation

This section contains information on:

Customizing LED Representations

LEDs are meant to be simple objects with a reduced graphical representation. In this representation, the only property used to customize the LED representation is the property foreground, which defines the color of the graphic object.

By default, this color is mapped from the alarm information set in the object.

Table 8.6 CSS Property for LED Representations
Property Name 
Type 
Set 
Default Value 
Description 
foreground 
Color 
Yes 
lightGray 
Denotes the color of the LED. 

The predefined LED types have a label and a tooltip specified in the JViews TGO resource bundle (see About Internationalization in the Context and Deployment Descriptor documentation).

The resources that apply to LED types are identified as:

You can edit the values directly in the JViews TGO resource bundle files.

When you create new LED types, the label and tooltip information will also be retrieved from this resource bundle to be displayed, for example, in a table cell. As you declare new LED types, register the corresponding entries into the resource bundle file, as follows:

Considering that you have created the following new LED type:

IltLed.Type batteryType = new IltLed.Type("Battery");

You should declare the following properties in the JTGOMessages.properties file:

Customizing LED Types

In JViews TGO, the LED type attribute determines how the object base is represented. Each LED type is associated with a specific base renderer that is in charge of drawing the object according to its type and state information.

In JViews TGO, you can customize the base representation of LED objects either by using an implementation of a predefined base renderer, such as IltLedImageBaseRendererFactory or IltLedSVGBaseRendererFactory, or by defining a new implementation of IltLedBaseRenderer. The principle to create a new IltLedBaseRenderer is the same as to create a new IltNEBaseRenderer.

For details, refer to Extending the Class IltNEBaseRenderer.

How to Create and Register an LED Type (using the API)
IltLed.Type MyType = new IltLed.Type("MyType");
IltSettings.SetValue("Led.Type.MyType.Renderer", 
                     new IltBaseRendererFactory() {
                       public IltBaseRenderer createValue() {
                         return new MyLedTypeBaseRenderer();
                       }
                     });
How to Create and Register an LED Type (using CSS)

You can also create new LED types by using global CSS settings (see Using Global Settings in Chapter 2, Using Cascading Style Sheets for more information):

setting."ilog.tgo.model.IltLed"{
   types[0]: @+ledType0;
}
Subobject#ledType0 {
  class: 'ilog.tgo.model.IltLed.Type'; 
  name: "MyType";
}

Likewise, you can customize the renderer using global CSS settings. To do so, you need to specify the full path to the object to be customized, as well as the value of its name attribute in order to match the right type of object in the system. The CSS property to customize here is renderer. In the example below, the name of the renderer factory class that is included in the search path is MyLedRendererFactory.

setting."ilog.tgo.model.IltLed.Type"[name="MyType"] {
   renderer: @+ledRendererFactory;
}
Subobject#ledRendererFactory {
   class: 'MyLedRendererFactory';
}
How to Create a New LED Type Using Only One Image

To create a new LED type using a single image, do the following:

  1. Create a new type of LED with the following code:
IltLed.Type myNewType = new IltLed.Type("MyType");
  1. Create the image base renderer factory corresponding to the new LED type.
IltLedImageBaseRendererFactory factory = new 
  IltLedImageBaseRendererFactory(image);
  1. You must indicate to JViews TGO that this factory should be used to draw this type of LED. This is done through the mapping method IltSettings.SetValue, as follows:
IltSettings.SetValue("Led.Type.MyType.Renderer", factory);

To illustrate the creation of a new LED type from a single image, suppose you want to create an LED type based on the following image, which is a GIF image with transparency:

images/customshelves7.gif

The following code excerpt illustrates a static method that creates a new LED type, and the mapping between the type and the factory.

// Create the new LED type
IltLed.Type batteryType = new IltLed.Type("Battery");
 
// Retrieve the image and create the base renderer factory 
Image img = IltSystem.GetDefaultContext().getImageRepository().getImage("battery.png");
IltLedImageBaseRendererFactory factor = new IltLedImageBaseRendererFactory(img);
 
// Associate the new LED type to the image base renderer factory
IltSettings.SetValue("Led.Type.Battery.Renderer", factory);

For details about how to create image base renderers, refer to Customizing Network Element Types From Images.

Once the LED type has been created, you can start to instantiate LED objects as follows:

IltLed led = new IltLed("new", batteryType);
How to Create a New LED Type Using Two Images

JViews TGO offers another way of creating new LED types, based on two images. This process, known as TwoImagesBaseRenderer, allows you to create very detailed LEDs, where a specific image area "glows", while the other areas remain unchanged.

The image base renderer gets two images and compares them pixel by pixel, identifying the differences between them. The difference defines the "glowing" area of the LED, or the area where the color changes.

Note
To use the TwoImagesBaseRenderer process, both images must have the same size and should differ at least by one pixel.

Although the processes of creating a new LED type based on one image or on two images are similar, the concepts behind the two processes are quite different. In the case of a one-image LED type, a color filter is applied to the whole image when the LED color is set; in the case of a two-image LED type, the filter is applied only to the region that differs when the two images are compared.

To create a new LED type using two images, do the following:

  1. Create a new type of LED with the following code:
IltLed.Type myNewType = new IltLed.Type("MyType");
  1. Create the image base renderer factory corresponding to the new LED type.
IltLedImageBaseRendererFactory factory = new 
  IltLedImageBaseRendererFactory(image_off, image_on);
  1. You must indicate to JViews TGO that this factory should be used to draw this type of LED. This is done through the mapping method IltSettings.SetValue, as follows:
IltSettings.SetValue("Led.Type.MyType.Renderer", factory);

Example

To illustrate the TwoImagesBaseRenderer process, imagine you want to create an LED representing a black area with a glowing trashcan. Only the trashcan and its frame are supposed to glow, the rest of the image must remain unchanged.

images/customshelves8.gif

Figure 8.6 Two-Image LED

The following code excerpt defines a static method to create the new LED type from two images.

/**
 * Creates the new led type using the
 * "trash_on.png" and "trash_off.png"
 * png images.
 */
String fileOn = "trash_on.png";
String fileOff = "trash_off.png";
 
// create the new type that will be associated with the
// given images
IltLed.Type theType = new IltLed.Type("TrashCan");
 
try {
  IlpImageRepository repository = IltSystem.GetDefaultContext().getImageRepository();
  Image imgOn = repository.getImage(fileOn);
  Image imgOff = repository.getImage(fileOff);
 
  // then map the factory created using the images with the new type
  IltLedImageBaseRendererFactory factory = 
    new IltLedImageBaseRendererFactory(imgOff, imgOn);
 
  IltSettings.SetValue("Led.Type.TrashCan.Renderer", factory);
  // Note: the numerical values above have been adjusted
  // using the imagecolortuner application provided with
  // JTGO
} catch (Exception ex) {
  logger.log("Error while creating TrashCan LED type.");
}

With the method defined above, you can instantiate an LED of the new type by coding:

IltLed newLedType = new IltLed("new", theType);

Customizing LED Tiny Types

As with network elements, the tiny representation of LEDs is a reduced form of the symbolic representation. Therefore, it is not possible to create a tiny representation that is different from the symbolic representation of the object.

Customizing LED Names

By default, LED names are not visible in the network and equipment components. You can modify this behavior by setting the property labelVisible. All other label properties are also applicable to IltLED instances.

Please refer to Customizing the Label of Business Objects for a complete list of properties that apply to the LED name representation.

How to Make a LED Label Visible
object."ilog.tgo.model.IltLed" {
  labelVisible: true;
}

Customizing LED States and Alarms

LEDs do NOT display state information. The only information that can affect their appearance are alarms, which are by default mapped to the foreground color of the object base.

The following properties are available to customize the representation of LEDs based on its alarm information:

Table 8.7 CSS Properties for LED Alarms
Property Name 
Type 
Default Value 
Description 
alarmBorderVisible 
boolean 
false 
Denotes whether the alarm border is displayed or not around the object base. 
alarmColorVisible 
boolean 
true 
Denotes whether the alarm color is displayed or not in the object base. If this value is set to false, the foreground color of the object base does not change when new alarms are set in the object. 

How to Customize LED States and Alarms

The following CSS file shows how you can change the predefined LED representation to hide the alarm border in case of alarms:

object."ilog.tgo.model.IltLed" {
   alarmBorderVisible: false;
}

The foreground color of the LED can be customized based on your own model attributes or using other state information present in the LED. The following CSS extract is part of sample imageRenderer that is located in <installdir>/samples/equipment/imageRenderer where the color of the LED is defined by the SNMP primary state:

object."ilog.tgo.model.IltLed" {
  foreground: lightGrey;
}
object."ilog.tgo.model.IltLed"["objectState.SNMP.State"=Up] {
  foreground: green;
}
 
object."ilog.tgo.model.IltLed"["objectState.SNMP.State"=Failed] {
  foreground: yellow;
}