// 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 ? 40 : context.getWidth();
final int height = context.getHeight() <= 0 ? 40 : context.getHeight();
final IGaService gaService = Graphiti.getGaService();
Polygon polygon;
{
int xy[] = new int[] { 0, 20, 20, 0, 40, 20, 20, 40, 0, 20 };
final Polygon invisiblePolygon = gaService.createPolygon(containerShape, xy);
invisiblePolygon.setFilled(false);
invisiblePolygon.setLineVisible(false);
gaService.setLocationAndSize(invisiblePolygon, context.getX(), context.getY(), width, height);
// create and set visible polygon inside invisible polygon
polygon = gaService.createPolygon(invisiblePolygon, xy);
polygon.setParentGraphicsAlgorithm(invisiblePolygon);
polygon.setStyle(StyleUtil.getStyleForEvent(getDiagram()));
gaService.setLocationAndSize(polygon, 0, 0, width, height);
// create link and wire it
link(containerShape, addedGateway);
}
// This draws the circle inside the rhombus
{
// create and set the circle inside the polygon
final Ellipse circle = gaService.createEllipse(polygon);
circle.setStyle(StyleUtil.getStyleForEvent(getDiagram()));
circle.setLineWidth(3);
circle.setParentGraphicsAlgorithm(polygon);
gaService.setLocationAndSize(circle, 10, 10, 20, 20);
}
{
// add a chopbox anchor to the shape
peCreateService.createChopboxAnchor(containerShape);
final BoxRelativeAnchor boxAnchor = peCreateService.createBoxRelativeAnchor(containerShape);
boxAnchor.setRelativeWidth(0.51);
boxAnchor.setRelativeHeight(0.10);
boxAnchor.setReferencedGraphicsAlgorithm(polygon);
final Ellipse ellipse = ActivitiUiUtil.createInvisibleEllipse(boxAnchor, gaService);
gaService.setLocationAndSize(ellipse, 0, 0, 0, 0);
}
{
// add a another chopbox anchor to the shape
peCreateService.createChopboxAnchor(containerShape);
final BoxRelativeAnchor boxAnchor2 = peCreateService.createBoxRelativeAnchor(containerShape);
boxAnchor2.setRelativeWidth(0.51);
boxAnchor2.setRelativeHeight(0.93);
boxAnchor2.setReferencedGraphicsAlgorithm(polygon);
final Ellipse ellipse = ActivitiUiUtil.createInvisibleEllipse(boxAnchor2, gaService);
gaService.setLocationAndSize(ellipse, 0, 0, 0, 0);
}
// call the layout feature
layoutPictogramElement(containerShape);