Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic getOrigin/DestinationAnchor after loading a file (Read 2648 times)
billcollis
YaBB Newbies
*
Offline


I love mindfusion

Posts: 19
Location: Auckland, NZ
Joined: Jun 4th, 2011
getOrigin/DestinationAnchor after loading a file
Jul 16th, 2015 at 6:02am
Print Post  
I am getting some strange results with finding anchors.
The functions getOrigin/DestinationAnchor works as expected with a diagram before it is saved. However after reopening the file the results are confusing. The anchor pattern itself does not change, it is always the same
I cannot find any issues with my code so far, but will continue looking.

var ilinks = node.getIncomingLinks();
if (ilinks.length > 0) {
var orig = ilinks[0].getOriginAnchor();
var apt = ilinks[0].getOrigin().getAnchorPattern();
}
var olinks = node.getOutgoingLinks();
if (olinks.length > 0) {
var dest = olinks[0].getDestinationAnchor();
var apt = olinks[0].getDestination().getAnchorPattern();
}
  

MFAnchor.jpg (Attachment deleted)
Back to top
 
IP Logged
 
billcollis
YaBB Newbies
*
Offline


I love mindfusion

Posts: 19
Location: Auckland, NZ
Joined: Jun 4th, 2011
Re: getOrigin/DestinationAnchor after loading a file
Reply #1 - Jul 17th, 2015 at 3:08am
Print Post  
I have reworked the code to stop using getOrigin/DestinationAnchor so much, I only call it once to make the link. It seems to be working fine so far.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: getOrigin/DestinationAnchor after loading a file
Reply #2 - Jul 17th, 2015 at 8:34am
Print Post  
Apparently the anchor point indices aren't serialized at all, and the values you are seeing correspond to where the new link instance would align before loading coordinates from JSON. For time being you can reset index values from loaded link points like this:

Code
Select All
diagram.fromJson(...);

var ArrayList = MindFusion.Collections.ArrayList;
ArrayList.forEach(diagram.links, function (link)
{
	link.originConnection.anchorPointDetails =
			link.originConnection.getNearestAnchor(link.getStartPoint(), link, false);
	link.destinationConnection.anchorPointDetails =
			link.destinationConnection.getNearestAnchor(link.getEndPoint(), link, true);
}); 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
billcollis
YaBB Newbies
*
Offline


I love mindfusion

Posts: 19
Location: Auckland, NZ
Joined: Jun 4th, 2011
Re: getOrigin/DestinationAnchor after loading a file
Reply #3 - Jul 17th, 2015 at 7:08pm
Print Post  
Stoyo

Thank you so much;
You have a fantastic product and even better service!!!
Bill
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint