Create automatic decoration between two pictogram elements [message #1511937] |
Mon, 15 December 2014 09:47 |
raffaele bologna Messages: 5 Registered: November 2014 |
Junior Member |
|
|
Hi everyone,
i am using Graphiti to create a graphical editor.
I want to create a decoration between two pictogram elements without it moves via drag & drop, but using an automatic decoration.
I can not to create the arrow to connect two pictogram elements.
I use this code : ConnectionDecorator arrow = peCreateService.createConnectionDecorator(connection, true, 1.0, true) .
But it just creates tip of the arrow.
How can i solve this problem? Can someone help me?
In the following the code i have implemented.
public PictogramElement add(IAddContext context) {
IAddConnectionContext addConContext = (IAddConnectionContext) context;
Include addedInclude = (Include) context.getNewObject();
IPeCreateService peCreateService = Graphiti.getPeCreateService();
// CONNECTION WITH POLYLINE
Connection connection = peCreateService.createFreeFormConnection(getDiagram());
connection.setStart(addConContext.getSourceAnchor());
connection.setEnd(addConContext.getTargetAnchor());
IGaService gaService = Graphiti.getGaService();
Polyline polyline = gaService.createPolyline(connection);
polyline.setLineWidth(2);
polyline.setForeground(manageColor(INCLUDE_FOREGROUND));
// create link and wire it
link(connection, addedInclude);
// add dynamic text decorator for the association name
ConnectionDecorator textDecorator = peCreateService.createConnectionDecorator(connection, true, 0.5, true);
Text text = gaService.createDefaultText(getDiagram(),textDecorator);
text.setForeground(manageColor(IColorConstant.BLACK));
gaService.setLocation(text, 10, 0);
// set string <<Include>> as text decorator
text.setValue("<<Include>>");
// add static graphical decorator (composition and navigable)
ConnectionDecorator arrow = peCreateService.createConnectionDecorator(connection, true, 1.0, true);
createArrow(arrow);
return connection;
}
private Polyline createArrow(GraphicsAlgorithmContainer gaContainer) {
IGaService gaService = Graphiti.getGaService();
Polyline polyline = gaService.createPolyline(gaContainer,new int[] {-15, 10, 0, 0, -15, -10});
polyline.setForeground(manageColor(INCLUDE_FOREGROUND));
polyline.setLineWidth(2);
return polyline;
}
this is the result of this code:
Thanks
Raffaele
-
Attachment: Diagram.jpg
(Size: 23.56KB, Downloaded 486 times)
[Updated on: Fri, 19 December 2014 13:44] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03763 seconds