Franklinjagan / jsplumb

Automatically exported from code.google.com/p/jsplumb
0 stars 0 forks source link

Auto anchor: connections overlap #41

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When 
 A connected to B and
 B connected to A
In real world (my case: flow graphs) it is common situation.

AutoDefault anchor selects same port for both connections
and connections overlap (drawn as one)

Original issue reported on code.google.com by astro64m@googlemail.com on 28 Oct 2010 at 1:43

Attachments:

GoogleCodeExporter commented 9 years ago
i guess you would prefer that they choose different paths?  what paths would 
you choose in this example?

Original comment by simon.po...@gmail.com on 30 Oct 2010 at 11:12

GoogleCodeExporter commented 9 years ago
Maybe this way

If source anchor or destination anchor is already occupied
 by other connection, try to choose another: 

try to choose second anchor closest to the center in DynamicAnchor.compute

Original comment by astro64m@googlemail.com on 1 Nov 2010 at 2:23

GoogleCodeExporter commented 9 years ago
ok. let me have a think about this.  turning it into an enhancement.

Original comment by simon.po...@gmail.com on 1 Nov 2010 at 10:19

GoogleCodeExporter commented 9 years ago
targeting 1.2.5; will add the ability to specify the algorithm for this.

Original comment by simon.po...@gmail.com on 25 Nov 2010 at 9:39

GoogleCodeExporter commented 9 years ago

Original comment by simon.po...@gmail.com on 25 Nov 2010 at 9:39

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
1.2.5-RC1 now has support for a user-provided anchor selector in the dynamic 
anchor class.  the method signature is as follows:

// xy - xy loc of the anchor's element
// wh - anchor's element's dimensions
// txy - xy loc of the element of the other anchor in the connection
// twh - dimensions of the element of the other anchor in the connection.

var MyAnchorSelector = function(xy, wh, txy, twh) {
    // do your calculations and return an Anchor.
};

... and you can provide it in a few places:

1. Dynamic Anchor Constructor:

var d = new DynamicAnchor([..anchors..], new MyAnchorSelector());

2. jsPlumb.autoConnect:

jsPlumb.autoConnect({sources:[..], targets:[..], anchors:[..], 
anchorSelector:new MyAnchorSelector()});

3. jsPlumb.makeDynamicAnchor (a wrapper around the DynamicAnchor constructor) :

var d = jsPlumb.makeDynamicAnchor([..anchors..], new MyAnchorSelector());

upon reflection, jsPlumb.makeDynamicAnchor seems kind of useless really.

Original comment by simon.po...@gmail.com on 30 Nov 2010 at 9:35

GoogleCodeExporter commented 9 years ago
could you you please specify trunk revision so I can try it?
(as for r635 this seems to be not yet commited)

Original comment by astro64m@googlemail.com on 1 Dec 2010 at 6:45

GoogleCodeExporter commented 9 years ago
*as for r685

Original comment by astro64m@googlemail.com on 1 Dec 2010 at 6:52

GoogleCodeExporter commented 9 years ago
> 1.2.5-RC1 now has support for a user-provided anchor selector in the dynamic 
anchor class

Some more thoughts: I still won't be able to determine 
if anchor location is occupied 
(if anchor used by another endpoint pinned to same element)
Any advice?

Original comment by astro64m@googlemail.com on 1 Dec 2010 at 1:39

GoogleCodeExporter commented 9 years ago
to determine if anchor used by another endpoint pinned to same element

I have to access to jsPlumb.endpointsByElement inside
 DynamicAnchor.compute (or a  a user-provided anchor selector in future)

no idea how to do this

Original comment by astro64m@googlemail.com on 1 Dec 2010 at 2:10

GoogleCodeExporter commented 9 years ago
do you mean that you might have two dynamic anchors that are sharing an anchor 
between them?  and so at any point in time only one of them can have a 
connection there?

Original comment by simon.po...@gmail.com on 2 Dec 2010 at 6:07

GoogleCodeExporter commented 9 years ago
I want to place connection target to 'free' pinpoint 
(no outgoing connections from that pinpoint)

Original comment by astro64m@googlemail.com on 2 Dec 2010 at 6:43

GoogleCodeExporter commented 9 years ago
i'm sorry.  i just don't really know exactly what you mean.

Original comment by simon.po...@gmail.com on 2 Dec 2010 at 6:46

GoogleCodeExporter commented 9 years ago
To do that I have to select anchor closest to the 'connection center' in 
Dynamic Anchor.compute(): http://pastebin.com/zBe5YmgK
If first closest one is used by connection, I want to select second, 
if that one too, third, etc.

Original comment by astro64m@googlemail.com on 2 Dec 2010 at 6:47

GoogleCodeExporter commented 9 years ago
ok.  so you are talking about making your own anchorSelector and supplying it 
to a DynamicAnchor, right?  then in the compute method you need to be able to 
see what's connected to each of the anchors, so you can choose a free one.

is that correct?

Original comment by simon.po...@gmail.com on 2 Dec 2010 at 6:52

GoogleCodeExporter commented 9 years ago
Yes

Now I have a clue. Just give me some time around r686
thanks

Original comment by astro64m@googlemail.com on 2 Dec 2010 at 6:59

GoogleCodeExporter commented 9 years ago
I blindly used jsPlumb.Connect to create new dynamic anchor per connection 
source/target. Maybe this is my problem

Now I need access to jsPlumb.Endpoint type (outside of the library) to check if 
anchor place is occupied by anchor, which belongs to another connection.
http://pastebin.com/uxGqjj2t
Are there any way?

P.S. btw in order to implement anchorSelector I have to copy-paste _distance 
from jsPlumb, this is not very good

Original comment by astro64m@googlemail.com on 2 Dec 2010 at 7:42

GoogleCodeExporter commented 9 years ago
There is no way to determine, whether candidate anchor is over 
another anchor belonged to any connection

Original comment by astro64m@googlemail.com on 3 Dec 2010 at 8:07

GoogleCodeExporter commented 9 years ago
jsPlumb.addEndpoint returns the Endpoint object. 

Original comment by simon.po...@gmail.com on 5 Dec 2010 at 1:55

GoogleCodeExporter commented 9 years ago
I was able to check anchor position using fake compute call
http://pastebin.com/Yc0vKTtz
and compare anchor position

Now the rule "don't choose anchor which is over another one" applies, 
but only to one  connection endpoint (see screenshot). Why?

From perspective of user  with little knowledge of library internals 
 issue is still not fixed

Original comment by astro64m@googlemail.com on 6 Dec 2010 at 1:29

Attachments:

GoogleCodeExporter commented 9 years ago
*http://pastebin.com/Yc0vKTtz - pastebin post expired
http://pastebin.com/EMh49K5X

Original comment by astro64m@googlemail.com on 7 Dec 2010 at 1:57