@Override
public PictogramElement add(IAddContext context) {
Lane lane = (Lane) context.getNewObject();
IPeCreateService peCreateService = Graphiti.getPeCreateService();
ContainerShape containerShape = peCreateService.createContainerShape(context.getTargetContainer(), true);
IGaService gaService = Graphiti.getGaService();
int width = context.getWidth() > 0 ? context.getWidth() : 600;
int height = context.getHeight() > 0 ? context.getHeight() : 100;
Rectangle rect = gaService.createRectangle(containerShape);
StyleUtil.applyBGStyle(rect, this);
if (FeatureSupport.isTargetLane(context) || FeatureSupport.isTargetParticipant(context)) {
GraphicsAlgorithm ga = context.getTargetContainer().getGraphicsAlgorithm();
if (getNumberOfLanes(context) == 1) {
gaService.setLocationAndSize(rect, 15, 0, width - 15, height);
for (Shape s : getFlowNodeShapes(context, lane)) {
Graphiti.getPeService().sendToFront(s);
s.setContainer(containerShape);
}
} else {
if (context.getWidth() == -1 || context.getHeight() == -1) {
gaService.setLocationAndSize(rect, 15, ga.getWidth() - 1, ga.getHeight() - 15, height);
// gaService.setLocationAndSize(rect, context.getX(), context.getY(), width, height);
} else {
ILayoutService layoutService = Graphiti.getLayoutService();
ILocation loc = layoutService.getLocationRelativeToDiagram(containerShape);
int x = context.getX() - loc.getX();
int y = context.getY() - loc.getY();
gaService.setLocationAndSize(rect, x - 15, y, ga.getWidth() - 15, height);
}
}
containerShape.setContainer(context.getTargetContainer());
} else {
gaService.setLocationAndSize(rect, context.getX(), context.getY(), width, height);
}
Shape textShape = peCreateService.createShape(containerShape, false);