Graphic Components > Network Component > Configuring the Network Component > Configuring a Network Component through the API

This section shows you how to configure a network component by coding. Architecture of the Network Component later in this section goes into the details of the classes involved in the architecture of the network component.

The following example shows how to configure the network view through the API. See Network Component Services for programming details on the individual services.

How to Configure the Network View with the API
IlpNetworkView view = network.getView();
 
 //Toolbar
 view.getToolBar().add(new IlpNetworkSelectButton(view));
 view.getToolBar().add(new IlpNetworkZoomResetButton(view));
 // Overview
 view.setOverviewVisible(true);
 // View interactor
 IltSelectInteractor selInteractor = new IltSelectInteractor();
 selInteractor.setEditingAllowed(true);
 IlpViewsViewInteractor viewsInteractor = 
    new IlpViewsViewInteractor(selInteractor);
 view.getController().setViewInteractor(viewsInteractor); 
 // Zoom policy
 view.setZoomPolicy(
   new IltMixedZoomPolicy() {{
     setZoomThreshold(2.0);
   }});
 // Layout
 view.setNodeLayout(new IlvGridLayout());
 view.setLinkLayout(new IltShortLinkLayout());
 // Background
 view.addBackgroundURL(
   context.getURLAccessService().getFileLocation(
     "data/images/europe.jpg"));
 // LayerPolicy
 view.getCompositeGrapher().setLayerPolicy(myLayerPolicy)
 // Position
 view.setPositionConverter(
   new IlpGeographicPositionConverter(projection,true));
How to Configure the Network Adapter with the API

The following example shows how to configure the network adapter through the API. See Network Component Services for programming details on the individual services.

IlpNetworkAdapter adapter = network.getAdapter();
 
// Filter
IlpFilter myFilter = new MyFilter();
// (it is the same as network.setFilter(myFilter);)
adapter.setFilter(myFilter);
 
// Origin
List myOrigins = new ArrayList();
myOrigins.add(objectID_1);
myOrigins.add(objectID_2);
:
:
myOrigins.add(objectID_n);
// in this case we want to display the origins
boolean showOrigin = true;
adapter.setOrigins(myOrigins, showOrigin);
 
// Expansion Strategy Factory
// Usually the expansion strategy factory relies
// on the adapter to access the data source and
// to load/release objects
IlpExpansionStrategyFactory myExpFactory = new 
  MyExpansionStrategyFactory(adapter);
adapter.setExpansionStrategyFactory(myExpFactory);
 
// Position Attribute
// Here, imagine that MyObject implements IlpObject
// interface and defines "Placement" as the 
// IlpAttribute that defines the object position
IlpClass myObjectClass = MyObject.getIlpClass();
IlpAttribute myPosAttrib = MyObject.Placement;
adapter.setPositionAttribute(myObjectClass, myPosAttrib);
 
// Node and Link Factory
IlpNetworkNodeFactory myNodeFactory = new MyNodeFactory();
adapter.setNodeFactory(myNodeFactory);
 
IlpNetworkLinkFactory myLinkFactory = new MyLinkFactory();
adapter.setLinkFactory(myLinkFactory);