Perforce JViews TGO Sample: Network Component - Decoration


Description

This sample shows how to extend predefined business objects and how to represent the new information in your object using the Perforce JViews TGO network component.

How to Use the Sample

The main frame contains a simple network component, with several different types of nodes and links. A network component has a default toolbar with a set of predefined interactors:

How to Run the Sample as an Application

This sample can be run as an application. The installation directory contains an executable JAR file, network-decoration.jar, that allows you to execute the sample with a double click from a file browser. Note that if you are using Internet Explorer, you can open the installation directory and execute the JAR file from the browser. This technique may not work in other Web browsers.

Alternatively, you can run the sample application from the command line. First check that the Ant utility is properly configured. If not, see the instructions on how to configure Ant for Perforce JViews.

Then, go to the installation directory of the sample and type:

ant run

Topics Covered

Detailed Description

This sample differs from the basic sample in that it shows instances of a custom business class that extends the predefined business class ilog.tgo.model.IltNetworkElement.

This new class defines a business attribute, called comments, which is used to illustrate how to add new decorations to a predefined business object graphic representation. The new business class is declared and instantiated in customClasses.

The comments attribute is mapped to a decoration by using a style sheet. New decorations for predefined business objects are customized using the following properties:

These properties are illustrated in network.

In this example, the attribute comments is graphically represented as a small red triangle, which is added to the bottom left of the network element. This decoration is only added to the object if the attribute value is set.

When you click the new icon decoration, a comment window is displayed showing the value of the attribute value. This window is customized using cascading style sheets.

Tooltips can also be defined using the following properties:

New decorations can also be customized to be placed in specific layers or to have different visibility thresholds which make them invisible according to the zoom level. In order to enable these configurations, the decoration must be identified by a decoration name. The steps to assign a decoration name are listed below:

The following example illustrates the style sheet configuration for the new comments decoration:

#commentIcon {
  class: 'ilog.views.graphic.IlvIcon';
  image: '@|image("commentIcon.png")';
  ILPATTRIBUTE: "comments";
  ILPDECORATIONNAME: "Comments";
}

Once the decoration has been identified with the decoration name, it is possible to customize its layer by creating a new layer policy. The layer policy defines the layer in which each decoration of an object representation will be placed. This is illustrated in decoration.CustomLayerPolicy.

The visiblity threshold of the decoration can be specified also in the style sheet configuration when the zoom policy is Physical or Mixed. This configuration is achieved using properties decorationNames and visibilityThresholds, as illustrated below:

Zooming {
  type: "Physical";
  decorationNames[0]: Comments;
  visibilityThresholds[0]: 0.5;
}

Installation Directory

The Network Component - Decoration sample is installed here.

Classes Involved

Source Files

Copyright © 2021 Rogue Wave Software, Inc., a Perforce company. All rights reserved. Legal terms.