@Override
public boolean layout(ILayoutContext context) {
ContainerShape containerShape = (ContainerShape) context.getPictogramElement();
GraphicsAlgorithm containerGa = containerShape.getGraphicsAlgorithm();
IGaService gaService = Graphiti.getGaService();
int containerHeight = containerGa.getHeight();
Iterator<Shape> iterator = containerShape.getChildren().iterator();
while (iterator.hasNext()) {
Shape shape = iterator.next();
GraphicsAlgorithm ga = shape.getGraphicsAlgorithm();
IDimension size = gaService.calculateSize(ga);
if (containerHeight != size.getHeight()) {
if (ga instanceof Polyline) {
Polyline line = (Polyline) ga;
Point firstPoint = line.getPoints().get(0);
Point newPoint = gaService.createPoint(firstPoint.getX(), containerHeight);
line.getPoints().set(1, newPoint);
} else if (ga instanceof Text) {
gaService.setHeight(ga, containerHeight);
}
}
}
Shape shape = FeatureSupport.getShape(containerShape, ParticipantMultiplicityUpdateFeature.MULTIPLICITY_MARKER,
Boolean.toString(true));
if (shape != null) {
GraphicsAlgorithm ga = shape.getGraphicsAlgorithm();
int x = (containerGa.getWidth() / 2) - 10;
int y = containerGa.getHeight() - 20;
gaService.setLocation(ga, x, y);
}