skip to main content
TGO > Programmers documentation > Styling > Customizing shelves and cards > Customizing various aspects of ports
 
Customizing various aspects of ports
Customizing port types
In JViews TGO, the port type attribute determines how the object base is represented. Each port 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 port objects either by using an implementation of a predefined base renderer, such as IltPortImageBaseRendererFactory or IltPortSVGBaseRendererFactory, or by defining a new implementation of IltPortBaseRenderer. The principle to create a new IltPortBaseRenderer is the same as to create a new IltNEBaseRenderer.
For details, refer to Extending the class IltNEBaseRenderer.
How to create and register a port type (using the API)
 
IltPort.Type MyType = new IltPort.Type("MyType");
IltSettings.SetValue("Port.Type.MyType.Renderer",
                     new IltBaseRendererFactory() {
                       public IltBaseRenderer createValue() {
                         return new MyPortTypeBaseRenderer();
                       }
                     });
How to create and register a port type (using CSS)
You can also create new port types by using global CSS settings as shown in the following example.
 
setting."ilog.tgo.model.IltPort"{
   types[0]: @+portType0;
}
Subobject#portType0 {
  class: 'ilog.tgo.model.IltPort.Type';
  name: "MyType";
}
For more information, see Using global settings.
How to customize and register a port type (using CSS)
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 MyPortRendererFactory.
 
setting."ilog.tgo.model.IltPort.Type"[name="MyType"] {
   renderer: @+portRendererFactory;
}
Subobject#portRendererFactory {
   class: 'MyPortRendererFactory';
}
How to create a new port type with an image (using the API)
The following code sample shows how to create a new port type and associate it with an image.
The full application is provided as part of the JViews TGO demonstration software at <installdir> /samples/equipment/imageRenderer.
 
    String fileName = "plug.png";
    // create the new type that will be associated with an image
    IltPort.Type portType = new IltPort.Type("Plug");
 
    try {
      // Retrieve the image using the Image Repository
      Image img =
IltSystem.GetDefaultContext().getImageRepository().getImage(fileName);
      // then map the renderer factory created using the image with the new
type
      IltPortImageBaseRendererFactory factory =
        new IltPortImageBaseRendererFactory(img, 255, 32, 165);
      IltSettings.SetValue("Port.Type.Plug.Label", "Plug");
      IltSettings.SetValue("Port.Type.Plug.Renderer", factory);
      // Note: the numerical values above have been adjusted using the
      // Image Color Tuner application provided with JTGO.
    } catch (Exception e) {
      e.printStackTrace();
    }
How to create a new port type with one image per base style
You can represent a type with images by specifying 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 port using one image per base style:
*Create a new type of port
Using the API:
 
IltPort.Type portType = new IltPort.Type("Plug");
or, using global CSS settings:
 
setting."ilog.tgo.model.IltPort"{
   types[0]: @+portType0;
}
 
Subobject#portType0 {
   class: 'ilog.tgo.model.IltPort.Type';
   name: "Plug";
}
*Map an IltPortDirectImageBaseRendererFactory to the new type
Using the API SetValue:
 
IltSettings.SetValue("Port.Type.Plug.Label", "Plug");
IltSettings.SetValue("Port.Type.Plug.Renderer",
    new IltPortDirectImageBaseRendererFactory());
or, using global CSS settings:
 
setting."ilog.tgo.model.IltPort.Type"[name="Plug"] {
   renderer: @+portRendererFactory;
   label: Plug;
}
 
Subobject#portRendererFactory {
   class: 'ilog.tgo.graphic.renderer.IltPortDirectImageRendererFactory';
}
*Define an image and an alarm color or gray-level parameter in CSS for each required base style
 
object."ilog.tgo.model.IltPort"["type"=Plug]["objectState.Bellcore.State"=En
abledIdle] {
  sourceImage: '@|image("PortPlug_EnabledIdle.png")';
  alarmColorLevel: 128;
}
object."ilog.tgo.model.IltPort"["type"=Plug]["objectState.Bellcore.State"=Di
sabledIdle] {
  sourceImage: '@|image("PortPlug_DisabledIdle.png")';
  alarmColorLevel: 140;
}
For details about how to create image base renderers, refer to Creating network element types from images and customizing them.
Customizing port names
By default, port 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 IltPort instances.
For a complete list of properties that apply to the port name representation, refer to Customizing the label of a business object.
Label and tooltip for port types
The predefined port types have a label and a tooltip specified in the JViews TGO resource bundle. For details, see About globalization.
The resources that apply to port types are identified as:
*ilog.tgo.Port_Type_<TYPE NAME> : port type labels
*ilog.tgo.Port_Type_<TYPE NAME>_ToolTip : port type tooltips
You can edit the values directly in the JViews TGO resource bundle files.
When you create new port 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 port types, register the corresponding entries in the resource bundle file, as follows.
Considering that you have created the following new port type:
 
IltPort.Type portType = new IltPort.Type("Plug");
You should declare the following properties in the JTGOMessages.properties file:
*ilog.tgo.Port_Type_Plug=Plug
*ilog.tgo.Port_Type_Plug_ToolTip=Plug Port
How to make a port label visible
 
object."ilog.tgo.model.IltPort" {
  labelVisible: true;
}
Customizing port tiny types
As with network elements, the tiny representation of ports 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 port states and alarms
Ports display state and alarm information in the same way as other predefined business objects. For a complete list of the relevant properties, refer to Customizing object and alarm states of predefined business objects.

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.