Skip to main content



      Home
Home » Modeling » Graphiti » Programatically create connection bend points
Programatically create connection bend points [message #668289] Wed, 04 May 2011 17:10 Go to next message
Eclipse UserFriend
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 03:30 Go to previous messageGo to next message
Eclipse UserFriend
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 16:39 Go to previous messageGo to next message
Eclipse UserFriend
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 09:14 Go to previous messageGo to next message
Eclipse UserFriend
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 10:07 Go to previous message
Eclipse UserFriend
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: Tue Jul 08 22:12:00 EDT 2025

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

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

Back to the top