Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » [Spray] Problem with anchors
[Spray] Problem with anchors [message #1385168] Wed, 04 June 2014 17:35 Go to next message
Simone Di Cola is currently offline Simone Di Cola
Messages: 46
Registered: February 2014
Member
Hi all,
I will use pseudo code to describe the problem.

I have two shape definitions as follows:

Shape A {
anchor {
position (xoffset=0.5, yoffset=0.0) // middle-top
position (xoffset=0.5, yoffset=1.0) // middle-bottom
}
}

Shape B {
anchor {
position (xoffset=0.5, yoffset=0.0) // middle-top
position (xoffset=0.5, yoffset=1.0) // middle-bottom
}
}

I have a connection that connects these two types. Somehow, every new connection that is created ALWAYS attachs the 'middle-top' anchor.

Note that both anchor points are visible and I can alter the connections (source/target points) after that to attach to the middle-bottom anchor.

The problem comes from this method

protected Anchor getDslShapeAnchor(PictogramElement pe) {
if (pe == null) {
return null;
}
Shape dslShape = SprayLayoutService.findDslShape(pe);
if (dslShape != null) {
EList<Anchor> anchors = dslShape.getAnchors();
if (!anchors.isEmpty()) {
return anchors.get(0); //<-------- ALWAYS THE FIRST
}
}
return null;
}

that returns always the first anchor.

How do you solve this problem in Graphiti? I mean, how do you get the anchor closer to the mouse pointer?

Thanks for your help
Simone
Re: [Spray] Problem with anchors [message #1385227 is a reply to message #1385168] Thu, 05 June 2014 05:24 Go to previous messageGo to next message
Soeren M is currently offline Soeren M
Messages: 77
Registered: September 2011
Member
You are not asking for the mouse position to receive any anchor, you always return the same?
I wrote an editor for a grammar, where its necessary where the connection ends/starts, so I wrote an extra popup for it.
In your case you can ask for the relative coordinates of the anchor and compare it with the mouse position? Maybe that helps.
Re: [Spray] Problem with anchors [message #1385300 is a reply to message #1385227] Thu, 05 June 2014 13:30 Go to previous messageGo to next message
Simone Di Cola is currently offline Simone Di Cola
Messages: 46
Registered: February 2014
Member
Soern,
I think you misunderstood the question. That method is created by Spray, and it does return always the first anchor (that is wrong).
Now, if you have a shape with two anchors, how do you get the anchor near the mouse position?
I was thinking about drag&drop, but Spray has bugs even there.

Re: [Spray] Problem with anchors [message #1385813 is a reply to message #1385168] Wed, 11 June 2014 11:33 Go to previous message
Michael Wenz is currently offline Michael Wenz
Messages: 1612
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi Simone,

in plain Graphiti you would check the mouse location at the time the
connection is created and compare to the locations of the available anchors.
Then you would not use the anchor provided in the create connection context
(usually the chopbox anchor or the first anchor of the shape) but the one
you determined.

But I don't know if and how that procedure is applicable to Spray.

Michael
Previous Topic:Rotate GraphicsAlgorithm
Next Topic:Possible bug with BoxRelativeAnchor
Goto Forum:
  


Current Time: Mon Oct 20 21:19:29 GMT 2014

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

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