Creating a shelf with the API

All you have to do is create a shelf using the class IltShelf and add it to a data source, as shown in the following example.

How to create a linear shelf with the API

IltShelf s1 = new IltShelf(10,//Number of slots in the shelf
   20,//Width of all the slots in the shelf
   100,//Height of all the slots in the shelf
   0);//Value of the first slot number
IlpDataSource dataSource = new IltDefaultDataSource();
dataSource.addObject(s1);
The result looks like this:
Image1.gif
A linear shelf without cards

How to create an array shelf with the API

The following code creates an empty 4x3 array shelf:
IltShelf s1 = new IltShelf(4,//Number of slots along the x axis
   25,//Width of a slot on the x axis
   3,//Number of slots along the y axis
   30,//Width of a slot on the y axis
   0);//Value of the first slot number
s1.setAttributeValue(IltShelf.PositionAttribute, new IlpPoint(50, 50));
IlpDataSource dataSource = new IltDefaultDataSource();
dataSource.addObject(s1);
The result looks like this:
figure2.gif
An empty 4x3 array shelf with fixed-width slots