Perforce JViews TGO Sample: Network Component - Bandwidth
Description
This sample shows how to use the state features of the Perforce JViews TGO network component. network component.
How to Use the Sample
And custom interactors:
In this sample, the default interactor is the Automatic Magnifying Glass, which magnifies randomly the network elements displayed in the component.
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-bandwidth.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
- Initializing a JTGO application using a deployment descriptor
- Creating a data source
- Creating a network component and configuring it using a CSS configuration file
- Associating the data source with the network component
- Creating business objects and adding them into a data source using the API
- Defining a default view interactor using CSS
- Customizing the State representation
- Using Performance states
Detailed Description
This sample shows how to create a network component and use its state and customization features. The code of this sample can be found in the doSample
method. To create a network component, the sample includes the following steps:
- Initialize the application using the method ilog.tgo.IltSystem.Init. You can pass a deployment descriptor file to this method. This file contains information about global settings for the application.
In this sample, the descriptor is called deploy and contains directories to be added to the search path. These directories are necessary to locate:- the background file of the network and other bitmaps in the
resources
directory, - the network configuration files in the
data
directory.
- the background file of the network and other bitmaps in the
- Customize the performance states configuration using ilog.tgo.resource.IltSettings.SetValue.
You can customize the graphic representation of each predefined performance state by defining the decoration (Gauge, Chart, Counter) that should be used. In this example, the graphic representation of states
IltPerformance.SecState.In
andIltPerformance.SecState.Bandwidth
are changed so that their values are represented by a counter and a chart,respectively. The chart decoration is also customized in order to use different colors according to the current value set. See ilog.tgo.graphic.IltChartMapping and ilog.tgo.graphic.IltCounterMapping for details. - Create a standard data source of class ilog.tgo.datasource.IltDefaultDataSource.
- Create predefined JTGO business objects and add them to the data source. In this sample, network elements and links are used to illustrate a management system.
- Create a network component and load its configuration from a CSS file.
The network component is of class ilog.cpl.IlpNetwork. In its constructor, or later through the method ilog.cpl.IlpNetwork.setStyleSheets, you pass the name of a configuration file (network) which describes the:
- View configuration
For a list of available properties, see the ilog.cpl.network.renderer.IlpViewRenderer class. - Buttons to add to the toolbar
For a list of available predefined buttons, see the ilog.cpl.network.renderer.IlpToolBarRenderer class. - Default interactor to use
This should be the name of one of the buttons of the toolbar or the default view interactor instance. See the ilog.cpl.network.renderer.IlpInteractorRenderer class. - Background file to load
For a list of available background file types, see the ilog.cpl.network.renderer.IlpBackgroundsRenderer class. - Object representation properties
- View configuration
- Attach the network component to the data source. Use the ilog.cpl.IlpNetwork.setDataSource method.
- Add the network to your Swing application.
IlpNetwork
is a SwingJComponent
, which means that it can be added to your application like any other Swing component.
Installation Directory
The Network Component - Bandwidth sample is installed here.
Classes Involved
-
ilog.tgo.IltSystem
The class that initializes a JViews TGO application.
-
ilog.tgo.datasource.IltDefaultDataSource
The default datasource implementation.
-
ilog.cpl.IlpNetwork
The network component.
-
ilog.tgo.model.IltPerformance
The Performance state system.
-
ilog.tgo.resource.IltSettings
The global settings.
-
ilog.tgo.graphic.IltChartMapping
The chart configuration for secondary states.
-
ilog.tgo.graphic.IltCounterMapping
The counter configuration for secondary states.
-
ilog.cpl.graphic.views.IlpViewsViewInteractor
The view interactor implementation.
-
ilog.cpl.model.IlpObject
The business object definition.
-
ilog.cpl.network.renderer.IlpViewRenderer
This class gives control over the view of a network component.
-
ilog.cpl.network.renderer.IlpToolBarRenderer
This class gives control over the toolbar of a network component.
-
ilog.cpl.network.renderer.IlpInteractorRenderer
This class gives control over the interactors of a network component.
-
ilog.cpl.network.renderer.IlpBackgroundsRenderer
This class gives control over the backgrounds of a network component.
Source Files
-
bandwidth.Main
The entry point of the sample.
-
bandwidth.Magnify
The action to set a magnify glass view interactor.
-
bandwidth.AutoMagnify
The action to set an automatic magnify glass view interactor.
-
bandwidth.Simulator
The simulator implementation to change the object states during execution.