Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Create automatic decoration between two pictogram elements
Create automatic decoration between two pictogram elements [message #1511937] Mon, 15 December 2014 09:47
raffaele bologna is currently offline raffaele bolognaFriend
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:

index.php/fa/20227/0/

Thanks
Raffaele


  • Attachment: Diagram.jpg
    (Size: 23.56KB, Downloaded 350 times)

[Updated on: Fri, 19 December 2014 13:44]

Report message to a moderator

Previous Topic:SelectionInfo in ToolBehaviorProvider is null
Next Topic:Properties view doesn't work for DnD element
Goto Forum:
  


Current Time: Fri Jan 19 01:54:55 GMT 2018

Powered by FUDForum. Page generated in 0.01882 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software