Creating a group with the API
Depending on the group class, the shape of a group is defined either by
IlpPolygon,
IlpRect, or
IlpPolyline. See
Group shapes for details.
How to create a group with the API
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:
A newly created
IltObjectState from the class corresponding to the chosen standard.
A name that is displayed at the center of the group representation.
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 a logo (logo.png) is set on one of the groups of the sample.
IlpContext context = IltSystem.GetDefaultContext();
IlpImageRepository imageRep = context.getImageRepository();
Image groupImage = imageRep.getImage("logo.png");
group.setIcon(groupImage);
Here the image is obtained from a disk file.
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.