@Deprecated protected void moveConnectionBendpoints(FreeFormConnection connection, int deltaX, int deltaY) { List<Point> points = connection.getBendpoints(); for (int i = 0; i < points.size(); i++) { Point point = points.get(i); int oldX = point.getX(); int oldY = point.getY(); points.set(i, Graphiti.getGaCreateService().createPoint(oldX + deltaX, oldY + deltaY)); } }
Anchor execute(RelationConnection startConnection, EObject bo, ICustomContext context) { RelationShape relationShape = ActordiagramFactory.eINSTANCE.createRelationShape(); relationShape.setVisible(true); relationShape.setActive(true); int x = context.getX(); if (x < 0) x = 200; int y = context.getY(); if (y < 0) y = 200; GraphicsAlgorithm relationGa = Graphiti.getGaCreateService().createEllipse(relationShape); Graphiti.getGaService() .setLocationAndSize( relationGa, x - RELATION_SIZE / 2, y - RELATION_SIZE / 2, RELATION_SIZE, RELATION_SIZE); ChopboxAnchor anchor = Graphiti.getPeCreateService().createChopboxAnchor(relationShape); anchor.setReferencedGraphicsAlgorithm(relationGa); // Rectangle relationGa = // Graphiti.getGaCreateService().createInvisibleRectangle(relationShape); // int x = context.getX(); if (x < 0) x = 200; // int y = context.getY(); if (y < 0) y = 200; // Graphiti.getGaService().setLocationAndSize(relationGa, x, y, RELATION_SIZE, RELATION_SIZE); // GraphicsAlgorithm relationShapeGa = Graphiti.getGaCreateService().createEllipse(relationGa); // Graphiti.getGaService().setLocationAndSize(relationShapeGa, x, y, RELATION_SIZE, // RELATION_SIZE); // BoxRelativeAnchor anchor = // Graphiti.getPeCreateService().createBoxRelativeAnchor(relationShape); // anchor.setReferencedGraphicsAlgorithm(relationGa); // anchor.setRelativeHeight(0.5); // anchor.setRelativeWidth(0.5); // Rectangle anchorGa = Graphiti.getGaCreateService().createInvisibleRectangle(anchor); // Graphiti.getGaService().setLocationAndSize(anchorGa, -1, -1, 3, 3); relationShape.setContainer(startConnection.getParent()); RelationConnection endConnection = addRelationFeature.createRelationConnection(anchor, startConnection.getEnd()); startConnection.setEnd(anchor); // check class, in case RelationConnection does not subclass it if (startConnection instanceof FreeFormConnection) { splitBendPoints((FreeFormConnection) startConnection, endConnection, x, y); } link(relationShape, bo); link(endConnection, bo); return anchor; }
@Override public PictogramElement add(IAddContext context) { // TODO Auto-generated method stub IAddConnectionContext addConContext = (IAddConnectionContext) context; AdviceEdge edge = (AdviceEdge) context.getNewObject(); IPeCreateService peCreateService = Graphiti.getPeCreateService(); Connection connection = peCreateService.createFreeFormConnection(getDiagram()); connection.setStart(addConContext.getSourceAnchor()); connection.setEnd(addConContext.getTargetAnchor()); IGaService gaService = Graphiti.getGaService(); Polyline polyline = gaService.createPlainPolyline(connection); polyline.setStyle(StyleUtil.getStyleForElement(getDiagram())); polyline.setLineStyle(LineStyle.DOT); link(connection, edge); // add dynamic text decorator for the reference name ConnectionDecorator textDecorator = peCreateService.createConnectionDecorator(connection, true, 0.5, true); Text text = gaService.createPlainText(textDecorator); text.setStyle(StyleUtil.getStyleForTextDecorator((getDiagram()))); gaService.setLocation(text, 10, 0); text.setValue(edge.getAdvicetype().toString()); ConnectionDecorator cd; cd = peCreateService.createConnectionDecorator(connection, false, 1.0, true); int[] xy = {getPointCutR() * 2, 0, 0, -getPointCutR() * 2, 0, 0, 0, getPointCutR() * 2}; Polygon polygon = Graphiti.getGaCreateService().createPolygon(cd, xy); polygon.setStyle(StyleUtil.getStyleForElement(getDiagram())); polygon.setLineStyle(LineStyle.DOT); return connection; }