| Business Objects and Data Sources > Shelves and Cards > Ports > Creating a Port with the API |
Creating a Port with the API |
INDEX
PREVIOUS
NEXT
|
This section shows how to create a port using the API and how to add it to the data source.
When you create a port with the API, you must provide its type, which can be set through the constructor or through the setAttributeValue method; the following sample shows how to create a port of type Centronics_36f:
// Create a shelf, set its position and add to datasource
IltShelf s1 = new IltShelf(2, 65, 3, 20, 0);
s1.setAttributeValue(IltShelf.PositionAttribute, new IlpPoint(20, 50));
dataSource.addObject(s1);
// create a card, set its position (relative to s1) and
// add to datasource
IltCard c1 = new IltCard();
c1.setAttributeValue(IltCard.PositionAttribute,
new IlpShelfItemPosition(0, 1, 1, 1));
dataSource.addObject(c1);
// create shelf item, set its position (relative to c1) and
// add it to datasource
IltPort port = new IltPort("port", IltPort.Type.Centronics_36f, null);
port.setAttributeValue(IltPort.PositionAttribute,
new IlpRelativePoint(33, 10));
dataSource.addObject(port);
// set relationship
dataSource.setParent(port.getIdentifier(), c1.getIdentifier());
dataSource.setParent(c1.getIdentifier(), s1.getIdentifier());
The result looks like this:
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. All rights reserved. Legal terms. | PREVIOUS NEXT |