Java client in telecommunications network management (3)

xiaoxiao2021-03-05  22

Java client in telecommunications network management (3)

1 Overview

The following describes how to develop telecommunications network management interface systems with Java. This article continues to explain how to use TWAVER components to make simple network topology.

2.Twaver component structure

TWAVER is a set of Java Swing telecommunications network topology rendering components. The components are designed in accordance with the MVC architecture. Among them, we put the various telecommunications network graphics objects (such as various nodes, connections, etc.) that will be created, directly in a memory container class (called DATABOX), and various graphics components for displaying data (eg, a map , Tree map, table, etc.) are directly connected to the container. This structure is similar to the relationship between TableModel and JTABLE in swing, and various telecommunications network objects are similar to various Objects placed in the table. JTable has special Editor and Renderer to edit and render each Cell's Object, and TWAVER also uses a similar mechanism; its internal use of different UI classes "drawing" for different types of data objects.

3.Twaver component example

With the above basic concepts, it is easy to use TWAVER. Its basic process is:

· Create a data container;

· Create a variety of views (map / tree map) and connect to the container;

· Create a variety of network objects and set its properties, and put them into the container;

· Dynamic changes to the various properties of the object, real-time update of data;

Below we will use a simple code to demonstrate the creation process. First we create a simple interface that consists of the middle webmap, the left tree and the attribute table on the right. They respectively correspond to TWAVER TNETWORK controls, TTREE controls, and TPropertySheet controls. At the same time, they share a unified data container TDATABOX. code show as below:

Import java.aw. *; import javax.swing. *; import TWAVER. *; Import TWAVER.TABLE. *; Import TWAVER.TREE. *;

Public class test extends jframe {

Private borderLayout Layout = new borderlayout ();

// Create a data container and give a name

Private TDATABOX BOX = New TDATABOX ("My NetWork");

// Create a variety of graphics components, including maps, trees, and attributes. Connect the data container at the same time.

Private TNETWORK NETWORK = New TNETWORK (BOX);

Private ttree tree = new ttree (box);

Private tpropertySheet Sheet =

New TPropertySheet (New TpropertySheetModel (NetWork);

// Create a split window and scroll window

JSPLITPANE ROOTSPLITPANE = New JSPLITPANE ();

JSPLITPANE Rightsplitpane = New JSPLITPANE ();

Jscrollpane treescroll = new jscrollpane ();

JscrollPane Sheetscroll = new jscrollpane ();

Public test () {

INIT ();

}

Void init () {

This.SetTitle ("TWAVER TEST");

THIS.GETCONTENTPANE (). setLayout (layout); rootsplitpane.setborder (null);

Rootsplitpane.setContinuousLayout (TRUE);

Rightsplitpane.setBorder (NULL);

Rightsplitpane.setContinuousLayout (TRUE);

THIS.GETCONTENTPANE (). add (rootsplitpane, borderlayout.center);

Rootsplitpane.Add (Rightsplitpane, Jsplitpane.right);

Rightsplitpane.Add (Sheetscroll, JSPLITPANE.RIGHT);

Rightsplitpane.Add (Network, Jsplitpane.Left);

Sheetscroll.getViewPort (). add (sheet, null);

Rootsplitpane.Add (TreeScroll, JSPLITPANE.LEFT);

Treescroll.getViewPort (). Add (Tree, NULL);

Rootsplitpane.setdividerLocation (100);

}

Public static void main (String [] args) {

Test test = new test ();

Test.setbounds (200, 200, 450, 300);

Test.show ();

}

}

The above code has created an interface and showing an empty web map. Run as shown below:

In order to place data, we add a function initData to initialize the network data.

Private void initdata () {node cloud = new node (); // Create a Node object cloud.setimage ("cloud.png"); // uses a cloud map as a picture Cloud.setLocation (60, 100); // Setting Its X, Y Coordinate Cloud.setName ("PSTN"); // Setting the node display name // Setting the node properties, changing the longitudinal display position of the name tag. // By default, its label is displayed below the node; this is raised by 30 pixels, placing it in the center of the node. Cloud.putClientProperty ("label.yoffset", new integer (-30)); // Sets the node properties to change its label font. Cloud.putClientProperty ("Label.Font", New Font ("Arial", font.bold, 12)); // Sets the node properties to change its label text color. Cloud.putClientProperty ("Label.color", Color.White); // put the node into the container Box.Addelement (Cloud);

/ / Create n nodes around the cloud map and connected to the cloud map through a LINK.

For (int i = 0; i <10; i ) {

// Create a normal node and set its location.

Node node = new node ();

INT x = 20 Cloud.getLocation (). x

(int) (70 * math.cos (2 * math.pi / 10 * i));

INT Y = Cloud.getLocation (). Y (int) (100 * math.sin (2 * math.pi / 10 * i));

Node.setlocation (x, y);

Box.addelement (node);

// Create a link and let it connect to the cloud map

Link Link = New Link (Node, Cloud);

Box.addeElement (LINK);

}

}

At this point, the program will be displayed as follows:

You can observe that the object on the map is displayed in accordance with the location we set, and can be selected by the mouse, and you can use the operation. At the same time, the hierarchical relationship between the objects is also shown, and the property sheet shows the collection of properties of the currently selected object.

In addition, TWAVER components also provide scaling, translation, monitoring various events, setting various filters and other functions. Since TWAVER is designed specifically for telecommunications industries, it directly provides support for the alarm, event, automatic layout and other functions.

4. Integrated example

After reading an example, I believe that you have had a preliminary understanding of TWAVER. Here is a complicated example. Although the network structure is more complicated, the use of TWAVER is also equally simple. The following figure is a complicated network topology map created by TWAVER various objects in the actual project:

How, isn't it good? Don't forget it, it is a static topology drawing of a Java Swing, interactive, instead of using a tool such as Visio. If the network structure in our software project is presented, I believe that customers will be very satisfied!

5. End

The next time you will introduce how to create, load, and rendering a web map through XML data.

6. Appendix

Please click here to download the relevant code;

Please click here to open the Applet page;

Please click here to download the executable JAR package;

转载请注明原文地址:https://www.9cbs.com/read-36363.html

New Post(0)