Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Create source Anchor while starting Connection
Create source Anchor while starting Connection [message #1256549] Tue, 25 February 2014 14:56 Go to next message
Martin Hanysz is currently offline Martin HanyszFriend
Messages: 30
Registered: November 2013
Member
Hello Graphiti community,

I have a rather simple question that I can't find an answer to: How can I create the source Anchor of a Connection when the user does the first click with an activated ConnectionFeature.

What I want to achieve is to allow the user to start connections anywhere on the diagram. An intuitive way to do this would be to select a ConnectionFeature from the palette and simply click anywhere on the Diagram to start a Connection at that point. In addition, the visual feedback that the user is creating a Connection (the Connection that starts at the source Anchor and ends at the mouse cursor) should be displayed.

What I tried so far is to add a ChopboxAnchor to the diagram itself and create a FixPointAnchor in the ICreateConnection#create() method of my CreateConnectionFeature but that does not give me the visual feedback of creating a Connection.
I also tried to have my CreateConnectionFeature to return true whenever ICreateConnection#canStartConnection() is called, which turns the mouse cursor into the well known "Connection allowed" symbol when the user hovers over the Diagram. But I am unable to create a FixPointAnchor that is used as the source of the Connection AND the start of the line that follows the mouse cursor during Connection creation (i.e. between the first click to select the source and the second click to select the target) once the user performs the first click.

I hope you can give me some hints on how to have a Connection start anywhere on the Diagram.

Best regards,
Martin
Re: Create source Anchor while starting Connection [message #1258653 is a reply to message #1256549] Thu, 27 February 2014 15:56 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Martin,

I guess you will have to create a (dummy) shape with a GA containing the
anchor. Anchors directly on the diagram are not supported.

Michael
Re: Create source Anchor while starting Connection [message #1273762 is a reply to message #1256549] Thu, 20 March 2014 13:59 Go to previous message
Martin Hanysz is currently offline Martin HanyszFriend
Messages: 30
Registered: November 2013
Member
Hi Michael,

in fact I am currently using Anchors directly on the Diagram. Since the Diagram class eventually extends AnchorContainer it is possible to create them and I am currently able to use them as target Anchors for my Connections. This is necessary for a use case where the user of the diagram editor starts a Connection on a Shape and wants it to end at a point on the Diagram that is not covered by another Shape (i.e. a "Connection to nowhere").

Similar to the "Connection to nowhere" use case I want my Users to be able to create a "Connection from nowhere" to a Shape. To achieve this, I tried what you suggested and created a Shape with an invisible Rectangle as its GraphicsAlgorithm and a ChopboxAnchor as its Anchor in the AbstractCreateConnectionFeature#attachedToSource(ICreateConnectionContext) method. In order to make the other methods of this Feature process this newly created Anchor, I set it as the source Anchor of the given CreateConnectionContext, but in the subsequent call to AbstractCreateConnectionFeature#canCreate(ICreateConnectionContext) the given Context has no source Anchor again.

So my question remains: How do I create the source Anchor of a Connection "on the fly" when the user clicks on the Diagram with the create connection tool. Which method would be an adequate point to create the new source Anchor (and maybe a new Shape that contains it)? How do I make the rest of the features use this newly created Anchor?

Best regards,
Martin
Previous Topic:Shape, Connection & Properties View
Next Topic:CDO Transaction Problem
Goto Forum:
  


Current Time: Thu Apr 25 09:54:10 GMT 2024

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

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

Back to the top