protected void adjustPosition(Shape targetShape, IRepositionContext context) { Point newTargetPosition = getAdjustedPosition(targetShape, context); performMove(targetShape, newTargetPosition); GraphicsUtil.sendToFront(targetShape); }
@Override protected ContainerShape createPictogramElement(IAddContext context, IRectangle bounds) { T addedGateway = getBusinessObject(context); IGaService gaService = Graphiti.getGaService(); IPeService peService = Graphiti.getPeService(); int x = bounds.getX(); int y = bounds.getY(); int width = bounds.getWidth(); int height = bounds.getHeight(); // Create a container for the gateway-symbol final ContainerShape newShape = peService.createContainerShape(context.getTargetContainer(), true); final Rectangle gatewayRect = gaService.createInvisibleRectangle(newShape); gaService.setLocationAndSize(gatewayRect, x, y, width, height); Shape gatewayShape = peService.createShape(newShape, false); Polygon gateway = GraphicsUtil.createGateway(gatewayShape, width, height); StyleUtil.applyStyle(gateway, addedGateway); gaService.setLocationAndSize(gateway, 0, 0, width, height); return newShape; }
@Override public int getDefaultHeight() { return GraphicsUtil.getGatewaySize(this.getDiagram()).getHeight(); }
protected ContainerShape createNewShape( ModelHandler mh, ContainerShape oldShape, EClass newType) { ILayoutService layoutService = Graphiti.getLayoutService(); boolean horz = Bpmn2Preferences.getInstance().isHorizontalDefault(); ILocation loc = layoutService.getLocationRelativeToDiagram(oldShape); int x = loc.getX(); int y = loc.getY(); int xOffset = 0; int yOffset = 0; GraphicsAlgorithm ga = oldShape.getGraphicsAlgorithm(); int width = ga.getWidth(); int height = ga.getHeight(); BPMN2FeatureProvider fp = (BPMN2FeatureProvider) getFeatureProvider(); AbstractCreateFeature createFeature = (AbstractCreateFeature) fp.getCreateFeatureForBusinessObject(newType.getInstanceClass()); CreateContext createContext = new CreateContext(); createContext.putProperty(AbstractCreateFlowElementFeature.SKIP_ADD_GRAPHICS, true); createContext.setTargetContainer(oldShape.getContainer()); FlowElement newObject = null; if (createFeature != null) { newObject = (FlowElement) createFeature.create(createContext)[0]; } else { newObject = (FlowElement) mh.create(newType); } ContainerShape containerShape = oldShape.getContainer(); if (containerShape != getDiagram()) { // we are adding a new shape to a control (e.g a SubProcess) // so we need to adjust the location to be relative to the // control instead of the diagram loc = layoutService.getLocationRelativeToDiagram(containerShape); xOffset = loc.getX(); yOffset = loc.getY(); } BaseElement oldObject = BusinessObjectUtil.getFirstElementOfType(oldShape, BaseElement.class); if (oldObject instanceof Lane) { ((Lane) oldObject).getFlowNodeRefs().add((FlowNode) newObject); } AddContext ac = new AddContext(new AreaContext(), newObject); AbstractAddBpmnShapeFeature af = (AbstractAddBpmnShapeFeature) getFeatureProvider().getAddFeature(ac); int w = af.getDefaultWidth(); int h = af.getDefaultHeight(); if (horz) { x += width + 50 + w / 2; y += height / 2; boolean done = false; while (!done) { done = true; List<Shape> shapes = getFlowElementChildren(containerShape); for (Shape s : shapes) { if (GraphicsUtil.intersects(s, x - w / 2, y - h / 2, w, h)) { y += 100; done = false; break; } } } } else { x += width / 2; y += height + 50 + h / 2; boolean done = false; while (!done) { done = true; List<Shape> shapes = getFlowElementChildren(containerShape); for (Shape s : shapes) { if (GraphicsUtil.intersects(s, x - w / 2, y - h / 2, w, h)) { x += 100; done = false; break; } } } } ac.setX(x - xOffset); ac.setY(y - yOffset); ac.setTargetContainer(oldShape.getContainer()); return (ContainerShape) getFeatureProvider().addIfPossible(ac); }