The model

The model contains the representation objects used to produce the graphic objects in the view. The model describes the end points of links, and as such it models the topology of the network. The model allows the view to access contained objects through the method getChildren. The model provides support for load-on-demand; that is, for adding child objects asynchronously when expanding network objects through the class IlpExpansionStrategy.

Classes of the network model

The interface IlpNetworkModel is implemented by the class IlpDefaultNetworkModel. This class is automatically created when you instantiate IlpNetwork. JViews TGO provides the following interfaces for creating nodes and links:
JViews TGO supplies default implementations of these interfaces.
The following figure shows the classes used by the network model.
tgo_network_model.png
Classes used by the network model

Creating nodes and links in the network model

When you want to create a new node or link, use the default implementations:
To create a linkset, create several links with the same end nodes.
To set the end nodes of a link, apply the methods setFromNode (for the start node) and setToNode (for the end node).
A link cannot be displayed unless it has end nodes, but you can create the link before you create the end nodes.
The following examples show how to use the classes for creating nodes and links.

How to create a node

IlpDefaultNetworkNode node = new IlpDefaultNetworkNode(MyAttributes,null);
network.setPosition(node,new IlpPoint(100,200), IlpPositionSource.BACKEND);
model.addRootObject(node);

How to create a link

IlpDefaultNetworkLink link = new IlpDefaultNetworkLink(MyAttributes,null);
link.setFromNode(node1);
link.setToNode(node2);
model.addRootObject(link);
For convenience, the main methods of IlpNetworkModel and IlpMutableNetworkModel are also accessible from IlpNetwork. Thus, the following statements are equivalent:
network.getModel().addRootObject(node);
and
network.addRootObject(node);