Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Connection between two figures
Connection between two figures [message #1715266] Fri, 20 November 2015 16:38 Go to next message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 526
Registered: November 2009
Senior Member
http://i.imgur.com/AIBq7aW.png

In the diagram above I am trying to create connection between two figures so that connection start and end are at ellipse anchors. Using code below I am able to connect to figures, however, the connection start and end are not static, but dynamic depending on where shape is moved. What should I do to make connection start and end be on my ellipse anchors? I think it has to do with line peCreateService.createChopboxAnchor(componentContainer);, when I set ChopBoxAnchor on the whole Shape I can initiate connection on that Shape, but that is also where connection starts. If I omit it, then my custom anchors become starting points of the connection.

ContainerShape invisibleContainer = createService.createContainerShape(container, true);
ContainerShape componentContainer = createService.createContainerShape(invisibleContainer, true);

Rectangle createInvisibleRectangle = createService.createInvisibleRectangle(invisibleContainer);
gaService.setLocationAndSize(createInvisibleRectangle, 0, 30, container.getGraphicsAlgorithm().getWidth(), 50);
RoundedRectangle containerShape = createService.createRoundedRectangle(componentContainer, 10, 10);
containerShape.setBackground(manageColor(IColorConstant.WHITE));
containerShape.setLineWidth(1);
//containerShape.setStyle(StyleUtil.getStyleForChannelComponentContainer(getDiagram()));
layoutService.setLocationAndSize(containerShape, 5, 5, container.getGraphicsAlgorithm().getWidth() - 10, 40);
		
setColumnIcon(gaService, containerShape, (ColumnType) newObject);
		
link(invisibleContainer, newObject);
link(componentContainer, newObject);
	
peCreateService.createChopboxAnchor(componentContainer);
createAnchor(invisibleContainer, containerShape, AnchorType.LEFT);

if(TableType.SOURCE == tableType){
	createAnchor(invisibleContainer, containerShape, AnchorType.RIGHT);
}
return invisibleContainer;
Re: Connection between two figures [message #1715566 is a reply to message #1715266] Tue, 24 November 2015 11:47 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1886
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Alex,

you should keep the chopbox anchor on your shape to enable users to start the connection on the complete shape. Inside your create connection feature you can change the passed create connection context instance and set the anchors you would like to use (e.g. the ones in the ellipses). You will have to cast the ICreateConnectionContext instance to the implementing class to have access to the setters for the anchors.

HTH,
Michael
Re: Connection between two figures [message #1716163 is a reply to message #1715566] Tue, 01 December 2015 19:59 Go to previous message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 526
Registered: November 2009
Senior Member
Thanks Michael, great help as always.
Previous Topic:Building and testing first build
Next Topic:Button pad is hidden when mouse hovers over anchor
Goto Forum:
  


Current Time: Sat Apr 21 11:50:08 GMT 2018

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

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