| Styling > Customizing Shelves and Cards > LED Representation |
LED Representation |
INDEX
PREVIOUS
NEXT
|
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.
This section contains information on:
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.
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:
ilog.tgo.LED_Type_<TYPE NAME>: LED type labels
ilog.tgo.LED_Type_<TYPE NAME>_ToolTip: LED type tooltips
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:
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.
IltLed.Type MyType = new IltLed.Type("MyType");
IltSettings.SetValue("Led.Type.MyType.Renderer",
new IltBaseRendererFactory() {
public IltBaseRenderer createValue() {
return new MyLedTypeBaseRenderer();
}
});
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';
}
To create a new LED type using a single image, do the following:
IltSettings.SetValue, as follows:
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:
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);
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:
IltSettings.SetValue, as follows:
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.
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);
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.
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.
object."ilog.tgo.model.IltLed" {
labelVisible: true;
}
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:
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;
}
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. All rights reserved. Legal terms. | PREVIOUS NEXT |