Styling > Customizing Network Elements > Customizing Network Element Types > Customizing Network Element Types From Images

This section describes how to define new network element types with new representations without extending an existing base renderer class.

JViews TGO provides a base renderer factory class, IltNEImageBaseRendererFactory, that simply requires an image from which it will automatically compute all the representations that a network element can have according to the state it is in (out of service, in service carrying traffic, in service carrying no traffic, or not installed) or the alarms it raises. See States.

How to Create a New Type of Network Element from an Image (using the API)

To create a new type of network element using an image, do the following:

  1. Create a new type of network element with the following code:
IltNetworkElement.Type myNewType =
          new IltNetworkElement.Type(YOUR_NEW_TYPE_NAME); 
  1. Create the image corresponding to the base style Carrying Traffic without any alarm and instantiate an IltNEImageBaseRendererFactory using this image:
IltNEImageBaseRendererFactory factory = new IltNEImageBaseRendererFactory(image, YOUR_IMAGE_PARAMETERS); 
  1. Map the factory with the new type using IltSettings.SetValue:
IltSettings.SetValue("NetworkElement.Type.YOUR_NEW_TYPE_NAME.Renderer",factory); 
How to Create a New Type of Network Element from an Image (using CSS)

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

setting."ilog.tgo.model.IltNetworkElement"{
  types[0]: @+neType0;
}
Subobject#neType0 {
  class: 'ilog.tgo.model.IltNetworkElement.Type'; 
  name: "YOUR_NEW_TYPE_NAME";
}

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 MyNERendererFactory.

setting."ilog.tgo.model.IltNetworkElement.Type"[name=YOUR_NEW_TYPE_NAME] { 
   renderer: @+neRendererFactory0;
}
Subobject#neRendererFactory0 {
   class: 'MyNERendererFactory';
}

Starting from an original image of type java.awt.Image corresponding to the Carrying Traffic base style without any alarm, JViews TGO automatically processes the range of representations corresponding to other states and alarms.

Suppose that you want to define a new network element with the following representation for the base style Carrying Traffic with no alarms.

images/ne001.gif

Figure 3.5 Sample New Network Element

To define this new network element representation, all you have to do is instantiate an IltNEImageBaseRendererFactory and provide the above bitmap image as an argument to its constructor. JViews TGO automatically computes the various representations that this network element can have according to its associated state and alarms.

The IltNEImageBaseRendererFactory has three constructors:

Figure 3.6 presents the four base styles (rows) with their various representations corresponding to alarms of different severity and loss of connectivity (columns).

images/ne002.gif

Figure 3.6 Sample Instantiations of New Network Elements
How to Create a New Type of Network Element using an Image per Base Style

Another way to represent a type with an image is to specify a source image and an alarm color level parameter for every required base style, directly in CSS. No other base style property or renderer parameter is needed, as a complete image is provided for every needed base style.

To create a new type of network element using an image per base style, do the following:

  1. Create a new type of network element
  2. Using the API:
IltNetworkElement.Type myNewType = new IltNetworkElement.Type(YOUR_NEW_TYPE_NAME); 
or, using global CSS settings:
setting."ilog.tgo.model.IltNetworkElement" {
   types[0]: @+neType0;
}
 
Subobject#neType0 {
   class: 'ilog.tgo.model.IltNetworkElement.Type';
   name: YOUR_NEW_TYPE_NAME;
}
  1. Map an IltNEDirectImageBaseRendererFactory to the new type
  2. Using the API IltSettings.SetValue:
IltSettings.SetValue("NetworkElement.Type.YOUR_NEW_TYPE_NAME.Renderer", new IltNEDirectImageBaseRendererFactory()); 
or, using global CSS settings:
setting."ilog.tgo.model.IltNetworkElement.Type"[name=YOUR_NEW_TYPE_NAME] {
   renderer: @+neRendererFactory;
}
 
Subobject#neRendererFactory {
   class: 'ilog.tgo.graphic.renderer.IltNEDirectImageBaseRendererFactory';
}
  1. Define an image and an alarm color or gray-level parameter in CSS for each required base style
object."ilog.tgo.model.IltNetworkElement"["type"=YOUR_NEW_TYPE_NAME]["objectState.Bellcore.State"=EnabledActive] {
  sourceImage: '@|image("newType_enabledActive.png")';
  alarmColorLevel: 128;
}
object."ilog.tgo.model.IltNetworkElement"["type"=YOUR_NEW_TYPE_NAME]["objectState.Bellcore.State"=DisabledActive] {
  sourceImage: '@|image("newType_disabledActive.png")';
  alarmColorLevel: 140;
}
How to Define a Network Element Type from an Image

This section explains how JViews TGO processes images to produce various representations for a network element depending on its associated state and alarm.

If the base style is Carrying Traffic no alarms, the representation is the original image. For example:

images/ne001.gif

Figure 3.7 Sample Original Image

In all other cases, the representation is automatically computed by JViews TGO, as follows:

images/ne003.gif

Figure 3.8 Sample with Color

images/ne004.gif

Figure 3.9 Sample Dark and Light Colors

images/ne005.gif

Figure 3.10 Sample Representations

Note that JViews TGO provides the imagecolortuner application to help you find the best values for the thresholds and the gray level. For details, see The imagecolortuner Application.

For the IltNEImageBaseRendererFactory to properly process the supported image types (GIF, PNG and JPG), the only constraint on the image itself is that the number of colors, C, be as follows:

2 <= C <= 256

Note
Transparency is preserved by the IltNEImageBaseRendererFactory and, as such, is not considered a color. Consequently, IltNEImageBaseRendererFactory does not color the transparent pixels of the image. For example, an image that contains the color black as the foreground, and a transparency as the background, will not have the regular coloring scheme applied as it fails to meet the requirement above.

The imagecolortuner Application

The imagecolortuner application can be found in <installdir>/bin where <installdir> is the directory where you have installed JViews TGO. This utility enables you to find the best values for the parameters of IltNEImageBaseRendererFactory quickly and easily.

How to Find the Best Values for the Parameters of IltNEImageBaseRendererFactory
  1. Load your image using the File>Load Image menu item.
  2. Customize the Carrying Traffic with alarm representations. You have to choose the gray level that will be mapped to the normal alarm color. (For details see Customizing Network Element Types From Images.) To do so, you can either display the tab called Row 1 and use the slider or click in the zoomed view on a pixel that has the color you want to be mapped to the normal alarm color.
  3. Customize the No Traffic representation. You have to indicate which details of your original image should have the dark color. (For details see Customizing Network Element Types From Images.) To do so, display the tab called Row 2 and adjust the two sliders. The first slider adjusts the threshold for bright colors: colors of the original image brighter than this threshold will be displayed in the appropriate dark color depending on the state and alarms. The second slider adjusts the threshold for dark colors: colors of the original image darker than this threshold will also be displayed in the appropriate dark color depending on the state and alarms.
  4. Display the sample source code using the File>View Source menu item. The source code needed to create your new type as it is currently represented on screen is displayed. The factory constructor contains the appropriate values. You have to note or copy these values or the entire code and paste it into your JViews TGO application to create your new type.