Configuring an equipment component through the API

For details of the classes involved in the architecture of the equipment component, see Architecture of the equipment component.
The following example shows how to configure the equipment view through the API. For programming details on the individual services, see Equipment component services.

How to configure the equipment view with the API

// Instantiates equipment component
IlpEquipment equipment = new IlpEquipment();
// Sets Toolbar visible
equipment.setToolBarVisible(true);
// Set overview window visible
equipment.setOverviewVisible(true);
// Set default view interactor
IlpSelectInteractor select = new IlpSelectInteractor();
select.setEditingAllowed(true);
equipment.setViewInteractor(select);
// Set zoom policy to mixed
IltMixedZoomPolicy mixed = new IltMixedZoomPolicy();
mixed.setZoomThreshold(2.0);
equipment.setZoomPolicy(mixed);
// Sets Horizontal Scroll Bar invisible
equipment.setHorizontalScrollBarVisible(false);

How to configure the equipment adapter with the API

The following example shows how to configure the equipment adapter through the API. See Equipment component services for programming details on the individual services.
IlpEquipmentAdapter adapter = equipment.getAdapter();

// Filter
IlpFilter myFilter = new MyFilter();
// (it is the same as equipment.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 Factory
IlpEquipmentNodeFactory myNodeFactory = new MyNodeFactory();
adapter.setNodeFactory(myNodeFactory);