public class AddUseCaseFeature extends AbstractAddShapeFeature {
public AddUseCaseFeature(IFeatureProvider fp) {
super(fp);
}
public PictogramElement add(IAddContext context) {
Diagram targetDiagram = (Diagram) context.getTargetContainer();
IPeCreateService peCreateService = Graphiti.getPeCreateService();
ContainerShape containerShape =
peCreateService.createContainerShape(targetDiagram, true);
int width = context.getWidth() < 100 ? 100 : context.getWidth();
int height = context.getHeight() < 40 ? 40 : context.getHeight();
IGaService gaService = Graphiti.getGaService();
// create ellipse
GraphicsAlgorithm e = gaService.createEllipse(containerShape);
e.setWidth(width);
e.setHeight(height);
// create style and set attributes
Style style = gaService.createStyle(getDiagram(), "Test1");
style.setBackground(manageColor(IColorConstant.WHITE));
style.setLineVisible(true);
// set line width to 10
style.setLineWidth(10);
// set style on ellipse
e.setStyle(style);
gaService.setLocationAndSize(e, context.getX(), context.getY(),
width, height);
layoutPictogramElement(containerShape);
return containerShape;
}