| Business Objects and Data Sources > Groups > Creating a Group With the API |
Creating a Group With the API |
INDEX
PREVIOUS
NEXT
|
This section shows how to create groups using the JViews TGO API and add them to a data source.
Depending on the group class, the shape of a group is defined either by IlpPolygon, IlpRect, or IlpPolyline. See Group Shapes for details.
IltRectGroup rectgroup = new IltRectGroup(new IltOSIObjectState(),
"RectGroup");
rectgroup.setAttributeValue(IltObject.PositionAttribute, new IlpRect(100, 200,
100, 50));
IltPolyGroup polygroup = new IltPolyGroup (new IltBellcoreObjectState(),
"PolyGroup");
polygroup.setAttributeValue(IltObject.PositionAttribute,
new IlpPolygon(new IlvPoint[] {
new IlvPoint(50, 20),
new IlvPoint(140, 20),
new IlvPoint(140, 100),
new IlvPoint(90, 100),
new IlvPoint(90, 140),
new IlvPoint(20, 140),
new IlvPoint(20, 90)
}));
IltLinearGroup lineargroup = new IltLinearGroup (new IltBellcoreObjectState(),
"LinearGroup");
lineargroup.setAttributeValue(IltObject.PositionAttribute,
new IlpPolyline(new IlvPoint[] {
new IlvPoint(350, 100),
new IlvPoint(400, 100),
new IlvPoint(420, 50),
new IlvPoint(450, 50)
}));
IltDefaultDataSource dataSource = new IltDefaultDataSource();
dataSource.addObject(rectgroup);
dataSource.addObject(polygroup);
dataSource.addObject(lineargroup);
The group constructor has two arguments:
IltObjectState from the class corresponding to the chosen standard.
In addition to the group name, an icon can be set to each group instance. This icon will be displayed above the group label and plinth, if any. The following code extract shows how the ILOG logo is set on one of the groups of the sample.
IlpContext context = IltSystem.GetDefaultContext();
IlpImageRepository imageRep = context.getImageRepository();
Image groupImage = imageRep.getImage("ilog.png");
group.setIcon(groupImage);
Here the image is obtained from a disk file.
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. All rights reserved. Legal terms. | PREVIOUS NEXT |