Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Drawing links dynamically between nodes (Read 5872 times)
krantir
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Joined: Jan 25th, 2012
Drawing links dynamically between nodes
Feb 2nd, 2012 at 9:44am
Print Post  
Hi,
I have a decision node with anchor pattern
apat1 = new AnchorPattern([                              new AnchorPoint(50, 0, true, false),
           new AnchorPoint(100, 50, true, true),
                   new AnchorPoint(0, 50, true, true)]);
created link using
var dlink = diagram.getFactory().createDiagramLink(
                 originnode,targetnode]);
then created connection points for decision node using
origin.createConnectionPoint(dlink, apat1.points[0],true);
origin.createConnectionPoint(dlink, apat1.points[1], false);
origin.createConnectionPoint(dlink, apat1.points[2], false);

created treelayout
var treeLayout = new TreeLayout();
treeLayout.linkType = TreeLayoutLinkType.Cascading;
treeLayout.anchoring = Anchoring.Reassign;
diagram.arrange(treeLayout);

The issue i am facing is the out going links from the decision node is always originating from the  (100,50) anchor point. I need the out going links from (0,50) and (100,50) points.
I am using the JS 1.3 beta version.
Please guide me on how to fix this.

Thanks
  

Capture.PNG ( 48 KB | 308 Downloads )
Capture.PNG
Back to top
 
IP Logged
 
krantir
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Joined: Jan 25th, 2012
Re: Drawing links dynamically between nodes
Reply #1 - Feb 2nd, 2012 at 1:08pm
Print Post  
I have two decision nodes and i want to create link from (0,50) anchor point from the origin node to (50,0) point of the destination node. Below is my code

apat1 = new AnchorPattern([new AnchorPoint(50, 0, true, false),new AnchorPoint(100, 50, false, true),new AnchorPoint(0, 50, false, true)]);

var diagramNode1 = diagram.getFactor().createShapeNode(bounds);
diagramNode1.setShape("Decision");
diagramNode1.setText("Decision1");
diagramNode1.setAnchorPattern(apat1);

var diagramNode2 = diagram.getFactory().createShapeNode(bounds);
diagramNode2.setShape("Decision");
diagramNode2.setText("Decision2");
diagramNode2.setAnchorPattern(apat1);
var dlink = diagram.getFactory().createDiagramLink(
     diagramNode1,diagramNode2);
diagramNode1.createConnectionPoint(dlink, new point(0, 50), false);
diagramNode2.createConnectionPoint(dlink, new point(50, 0), true);
dlink.route();
var treeLayout = new TreeLayout();
treeLayout.linkType = TreeLayoutLinkType.Cascading;
treeLayout.anchoring = Anchoring.Reassign;
diagram.arrange(treeLayout);

But the link is always drawn from the (100,50) anchor point. what could be the wrong here?Thanks in advance.
  

Capture1.PNG (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drawing links dynamically between nodes
Reply #2 - Feb 2nd, 2012 at 2:40pm
Print Post  
It seems TreeLayout selects the AnchorPoint that is at minimal distance from the origin node's center-bottom point, instead of checking the destination node postions. You could call this after applying TreeLayout as a work-around:

Code
Select All
Array.forEach(diagram.links, function (link)
{
	var connection = link.originConnection;
	connection.chooseBestAnchorPoint(link.getEndPoint());
	link.points[0] = connection.anchorPointDetails.point;
	link.route();
}); 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drawing links dynamically between nodes
Reply #3 - Feb 2nd, 2012 at 2:44pm
Print Post  
Call the link's setOriginAnchor and setDestinationAnchor methods.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint