}
@Override
public PictogramElement add(IAddContext context) {
final Pool addedPool = (Pool) context.getNewObject();
final ContainerShape parent = context.getTargetContainer();
// CONTAINER SHAPE WITH ROUNDED RECTANGLE
final IPeCreateService peCreateService = Graphiti.getPeCreateService();
final ContainerShape containerShape = peCreateService.createContainerShape(parent, true);
// check whether the context has a size (e.g. from a create feature)
// otherwise define a default size for the shape
final int width = context.getWidth() <= 0 ? 500 : context.getWidth();
final int height = context.getHeight() <= 0 ? 150 : context.getHeight();
final IGaService gaService = Graphiti.getGaService();
{
// create invisible outer rectangle expanded by
// the width needed for the anchor
final Rectangle invisibleRectangle = gaService.createInvisibleRectangle(containerShape);
gaService.setLocationAndSize(invisibleRectangle, context.getX(), context.getY(), width, height);
// create and set visible rectangle inside invisible rectangle
Rectangle rectangle = gaService.createRectangle(invisibleRectangle);
rectangle.setParentGraphicsAlgorithm(invisibleRectangle);
rectangle.setStyle(StyleUtil.getStyleForPool(getDiagram()));
gaService.setLocationAndSize(rectangle, 0, 0, width, height);
// create link and wire it
link(containerShape, addedPool);
}
// SHAPE WITH TEXT
{
// create shape for text
final Shape shape = peCreateService.createShape(containerShape, false);
// create and set text graphics algorithm
final Text text = gaService.createDefaultText(getDiagram(), shape, addedPool.getName());
text.setStyle(StyleUtil.getStyleForEvent(getDiagram()));
text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
text.setVerticalAlignment(Orientation.ALIGNMENT_MIDDLE);
gaService.setLocationAndSize(text, 0, 0, 20, height);
text.setAngle(-90);