| Graphic Components > Network Component > Architecture of the Network Component |
Architecture of the Network Component |
INDEX
PREVIOUS
NEXT
|
A graphic component encapsulates a model, a view, and a controller. The network component, like all the other graphic components, is based on the MVC architecture, which means that it has a model, a view and a controller associated with it. For a general introduction to the MVC architecture, see section Architecture of Graphic Components.
This section describes the classes and features of the network component that are specific to each module of the MVC architecture, and also explains the role of the adapter. This section contains the following topics:
The MVC architecture of the network component is implemented by the following classes:
IlpNetwork contains a model, a view, and a controller.
IlpNetworkModel and IlpMutableNetworkModel.
IlpMutableNetworkModel provides API facilities for adding and removing objects. The two network model interfaces are implemented through the class IlpDefaultNetworkModel. Instances of IlpNetwork use the class IlpDefaultNetworkModel.
IlpNetworkNode or IlpNetworkLink interface. Concrete implementations of these interfaces are provided as IlpDefaultNetworkNode and IlpDefaultNetworkLink. You can create subclasses of these representation object classes.
IlpNetworkView defines the network view.
IlpNetworkController defines the network controller.
Figure 2.8 shows the main classes used by the network component.
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 IlpNetworkModel.getChildren. The model provides support for load-on-demand; that is, for adding child objects asynchronously when expanding network objects through the class IlpExpansionStrategy.
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:
IlpNetworkNode for nodes
IlpNetworkLink for links
JViews TGO supplies default implementations of these interfaces.
Figure 2.9 shows the classes used by 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.
IlpDefaultNetworkNode node = new IlpDefaultNetworkNode(MyAttributes,null); network.setPosition(node,new IlpPoint(100,200), IlpPositionSource.BACKEND); model.addRootObject(node);
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);
The view displays a rectangular area of a theoretically infinite plane area. The view performs the following functions:
position in the model
The IlpNetwork class automatically creates the concrete class IlpNetworkView, which is provided for developing the network view. This class provides methods that allow you to configure the view in the following ways:
setHorizontalScrollBarVisible, setVerticalScrollBarVisible
getManagerView().addTransformer
setToolBarVisible (false)
setOverviewVisible (true)
For convenience, these methods are also accessible from the class IlpNetwork. They delegate to IlpNetworkView.
See Configuring a Network Component through a CSS File for how to configure the network view in CSS.
See How to Configure the Network View with the API for how to configure the network view through the API.
Graphic objects display as many details as possible within the limits of the display area and without loss of readability.
The network component uses only composite graphic objects. The graphic objects are created by the view renderer, which calls the appropriate object renderers to obtain the composite graphic objects. The view determines which object renderer is required to draw the graphic object that translates a particular representation object or attribute from the style sheet properties.
The following basic variations of graphic object exist in the network component:
End-user interaction with a graphic object is handled by an object interactor. Object interactors handle the gestures of an end user when performing a task. Gestures consist of one or more mouse events to perform one task.
For more information on object interactors, see Object Interactors.
The graphic representation of each object displayed in the network component is implemented through the IlpGraphic interface. JViews TGO provides predefined network graphic objects that are produced by the default network component renderer. You can customize the rendering of the objects through CSS.
For custom business objects, JViews TGO provides a default representation with a set of properties that can be customized to better represent your objects. If you prefer, you can also specify a new graphic representation by defining an IlvGraphic class in the CSS. For more information, refer to section Customizing User-Defined Business Objects in the Styling documentation. You can also refer to samples.network.compositeGraphic to see how to create a new object representation by using the ILOG JViews composite graphics feature.
Predefined business objects already have a specific graphic representation that can only be changed through CSS customization by setting the object properties. Refer to the Styling documentation for complete lists of business object properties. You can customize the graphic representation by adding new decorations. Refer to the Styling documentation for more information and to samples.network.decoration for how to add new decorations to the objects using CSS.
Object renderers in the network component create one graphic object that translates a complete representation object. No graphic objects are created that correspond to attributes of a representation object. Instead, subcomponents of graphic objects are created from attributes for example, a label can be created from the name attribute.
Such subcomponents are combined into composite graphic objects, like the link with secondary states and a label shown in Figure 2.10 by using attachments.
A composite graphic object constructed in this way looks like one object. The different instances of IlpGraphic used to build the graphic object cannot be distinguished as separate objects in the network. JViews TGO manages only the composite object. You cannot move the label separately from the link.
The controller is used for configuring view parameters, including layout and the background map. It manages the toolbar and the interactors: it determines which interactors are available from the toolbar.
The controller manages end-user interaction, such as object creation or move requests. It forwards these requests to the handler (see The Handler). It forwards all end-user requests to:
and actions triggered by the end user to:
The IlpNetwork class automatically instantiates the class IlpNetworkController.
The normal way of customizing the behavior of the controller is to attach a handler through the API.
The default handler is the IlpNetworkHandlerWithoutDataSource. When a mutable data source is connected to the network component, a new handler, IlpNetworkHandlerWithDataSource, is attached to the controller. You can customize either of these handlers by extending them. To set a new handler, use the method IlpNetworkController.setHandler:
IlpNetwork network = ... IlpNetworkController controller = network.getController(); IlpNetworkHandler myHandler = new MyCustomHandler(); controller.setHandler(myHandler);
Another controller configuration is to set the default view interactor through the method setDefaultViewInteractor. See also Interacting with the Network View.
You can also customize the controller by using CSS rules in the network configuration. The following code gives an example. For more details, see Configuring a Network Component through a CSS File.
Interactor {
name: "Select";
}
This rule selects the default interactor.
In the same way as the adapter passes information about the objects in the data source to the network component, the handler passes information in the opposite direction, that is, from the network component to the data source.
The information notified in this way includes:
The handler has been designed to simplify the customization of user interactions without rewriting the controller.
There are four types of handler:
IlpPositionHandler to handle object position changes.
IlpNodeHandler to handle object additions, removals and updates, as well as relationship changes.
IlpLoadHandler to handle reloading of model objects from an XML file.
IlpExpansionHandler to handle the expansion and collapsing of objects.
The IlpNetworkHandler interface indirectly extends all four types of handler.
The handler has a reference to the data source in the form of an IlpMutableDataSource, and to the network adapter.
You can customize the behavior of the handler by subclassing the class IlpNetworkHandlerWithDataSource. A particular method can be overridden for each of the possible actions.
You can customize the way position changes are propagated by overriding the method propagatePositionToDataSource. In a typical situation where the client is active, position changes are propagated to the data source. Therefore, this method returns true by default. In a situation where the client has read-only access, you may want to allow only user-requested position changes or no position changes at all to be forwarded to the data source. You can achieve this result by allowing the method propagatePositionToDataSource to return false in the appropriate cases.
The handler is most often subclassed to allow you to customize the creation of new objects in the data source. The object interactors may need to be customized in the same way. A customized object creation interactor typically calls the controller method IlpNetworkController.createObject with specific properties. The controller then forwards these properties to the handler. Finally, the method handleCreateObject of the handler parses the additional properties and creates the new objects.
By default, the handler creates new objects in two steps:
createObjectID.
IlpObject corresponding to this ID is created with the method createObject.
You can customize each step separately by overriding these methods in a subclass.
Any user interaction with the network is processed by the network controller which delegates action to the network handler. The handler has two default implementations:
IlpNetworkHandlerWithoutDataSource is attached by default to the controller and performs user interactions directly in the network model.
IlpNetworkHandlerWithDataSource is automatically attached to the controller when a data source is connected with the network component. User interactions are executed inside the data source that will notify the adapter, and the adapter in turn will notify the network model. In this particular use case, changes will be reflected on all network components, if any, connected to the data source.
The network adapter converts business objects into representation objects of type network node and network link. It is defined by the class IlpNetworkAdapter.
Network adapters retrieve structural information (that is, parent/child relationship) about business objects from the associated data source and determine whether an object should appear as a root representation object by examining a list of origins. See Setting a List of Origins for details.
Like the tree adapter, the network adapter supports load on demand.
The following figure shows network adapter classes:
The network adapter creates either a node or a link representation object depending on the value returned by the method IlpDataSource.getLinkInterface(Object). If the return value is not null, then a link is created; otherwise, a node is created.
Nodes are created with an IlpNetworkNodeFactory. By default, this factory is an instance of the class IlpDefaultNetworkNodeFactory, which creates IlpDefaultNetworkNode instances.
Similarly, links are created with an IlpNetworkLinkFactory. By default, this factory is an instance of the class IlpDefaultNetworkLinkFactory, which creates IlpDefaultNetworkLink instances.
The network adapter handles the position or shape of objects. By default, it interprets every object attribute with the name position as denoting the position of the object. You can use the method setPositionAttribute in IlpAbstractNodeAdapter to specify any other attribute to be used instead for all instances of a given IlpClass.
You can create a network adapter implicitly by instantiating the IlpNetwork component as shown in the following example.
IlpNetwork ilpNetwork = new IlpNetwork(); IlpDataSource dataSource = new IlpDefaultDataSource(); ilpNetwork.setDataSource(dataSource);
If you want to configure the adapter, to set its origin for example, you must first retrieve it from the network component and then set it to the data source.
IlpNetwork ilpNetwork = new IlpNetwork();
IlpDataSource dataSource = new IlpDefaultDataSource();
// configure the adapter, for example set an origin
IlpNetworkAdapter adapter = ilpNetwork.getAdapter();
adapter.setOrigins(Collections.singletonList("origin"),false);
adapter.setDataSource(dataSource);
For information on how to configure the adapter in CSS, see The Adapter Rule.
Unlike the tree adapter, the network adapter considers by default that objects are not containers. There are two conditions for an object to be a container: its IlpDataSource.getContainerInterface method should not return null and the property expansion applying to that object should be set to ExpansionType.IN_PLACE. By default, this property is set to ExpansionType.NO_EXPANSION. For information on how to set a property value, see section Introducing Cascading Style Sheets in the Styling documentation.
| Note |
There is no way to represent an object in a network component as a container, if its IlpDataSource.getContainerInterface returns null.
|
The network adapter supports temporary representation objects. These objects are placeholders that can be used in place of permanent representation objects for editing purposes and, more specifically, when new objects are created in the network view. When a business object corresponding to the temporary representation object is added to the data source, this temporary representation object is removed and replaced by the permanent representation of the business object. A filter, defined by IlpFilter, is used to determine when the representation object of a business object added to the data source is a candidate to replace the temporary representation object. Filtering criteria can be of any kind.
The following example shows how to add a temporary representation object to a network adapter.
First you create the temporary representation object, like this:
IlpDefaultNetworkNode temp=
new IlpDefaultNetworkNode(new IlpDefaultAttributeGroup());
Then you add it to the adapter along with the filtering criteria using the method IlpAbstractNodeAdapter.storeTemporaryRepresentationObject:
adapter.storeTemporaryRepresentationObject(temp, null,new IlpFilter() {
public boolean accept(Object o) {
IlpObject ilpO = (IlpObject)o;
return ilpO.getIdentifier().equals("right one");
}
};
The temporary representation object will be replaced by a permanent representation object as soon as a business object satisfying the filtering criteria is added to the data source.
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. All rights reserved. Legal terms. | PREVIOUS NEXT |