Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Programatically create connection bend points
Programatically create connection bend points [message #668289] Wed, 04 May 2011 21:10 Go to next message
Remo Meng is currently offline Remo MengFriend
Messages: 2
Registered: February 2011
Junior Member
Hi,

is there a way to create bend points on a connection programatically and define the bend degree (e.g. 90°) ?

What I am trying to achieve is to create a connection from the right-hand side of an object to its top in order to visualize a recursive connection. This connection should have two 90 degrees bends.

Thanks, Remo
Re: Programatically create connection bend points [message #668314 is a reply to message #668289] Thu, 05 May 2011 07:30 Go to previous messageGo to next message
Jos Warmer is currently offline Jos WarmerFriend
Messages: 114
Registered: October 2010
Senior Member
Yes there is, here is how I do this::
protected void addBendPoints(FreeFormConnection freeConnection, int firstX, int firstY, int secondX, int seondY) {
        Point bendpoint1 = Graphiti.getCreateService().createPoint(firstX, firstY);
        Point bendpoint2 = Graphiti.getCreateService().createPoint(secondX, seondY);
        freeConnection.getBendpoints().add(bendpoint1);
        freeConnection.getBendpoints().add(bendpoint2);
    }

If you put the bendpoints at the right places, they will have the required 90 degree .

Jos
Re: Programatically create connection bend points [message #669307 is a reply to message #668289] Mon, 09 May 2011 20:39 Go to previous messageGo to next message
Remo Meng is currently offline Remo MengFriend
Messages: 2
Registered: February 2011
Junior Member
Hi Jos,
yes this works perfect. Thanks a lot!
Re: Programatically create connection bend points [message #1194449 is a reply to message #669307] Mon, 18 November 2013 14:14 Go to previous messageGo to next message
Victor Lopez is currently offline Victor LopezFriend
Messages: 21
Registered: August 2013
Junior Member
Hi, I just tryed what you said and Its true. It creates the bending points. The problem is that the X and Y coordinates are global and I am creating the connection inside a container Shape so I Would need to access the local coordinates somehow in order to create a proper connection (it almost goes to the 0,0 and comes back to the target).

Any ideas?
Re: Programatically create connection bend points [message #1194537 is a reply to message #1194449] Mon, 18 November 2013 15:07 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Victor,

the tool behavior provider has methods getAbsoluteLocation that can give you
the location of the container shape, so you could calculate the right
positions. Connection locations are always absolute and refer to the diagram
itself.

Michael
Previous Topic:Property sheet loses memory of selection
Next Topic:Unit testing for graphiti elements
Goto Forum:
  


Current Time: Thu Apr 25 07:23:53 GMT 2024

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

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

Back to the top