Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Connect Lines to Anchor Points (Read 4563 times)
mclellan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 45
Location: London, Ontario
Joined: Feb 11th, 2008
Connect Lines to Anchor Points
Apr 15th, 2008 at 3:42am
Print Post  
Hello,

In my code, I am dropping shapes into my digram and using the create link option and letting FlowChart.net connect my lines for me.

After I am done calling the .Arrange method to have my flowchart logically arranged for me, I am running into some issues where I will have two nodes vertical from each other, however the connector line is not connecting at the middle of the object (where I assume the anchor's are), but off to the side.

As well, if I have 3 lines connecting to the same node, is it possible to have the connect arrow for all three connect at the same anchor point of the node?

Thanks!
Barry
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Connect Lines to Anchor Points
Reply #1 - Apr 15th, 2008 at 10:15am
Print Post  
Hi,

By default, the layout classes ignore anchor points. Use the Anchoring property to specify whether the connections to anchor points should be preserved, ignored, or reassigned.

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


I love YaBB 1G - SP1!

Posts: 45
Location: London, Ontario
Joined: Feb 11th, 2008
Re: Connect Lines to Anchor Points
Reply #2 - Apr 15th, 2008 at 10:42pm
Print Post  
Thanks again!

Do you have a small example you could show me, or where in the help file to look?


Barry
  
Back to top
 
IP Logged
 
mclellan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 45
Location: London, Ontario
Joined: Feb 11th, 2008
Re: Connect Lines to Anchor Points
Reply #3 - Apr 16th, 2008 at 4:16am
Print Post  
Ok, think I find it, however in looking at it again, I don't think this may be my problem.

If I have (for example) two lines coming into a decision box, they stay spaced apart, so I have one line coming in on the top left of the decision box, and the other coming in on the top right, however the desired solution would be that both lines connect at the center point of the decision box.

I am exporting to pdf as well, if I send this, would that help explain better?

Thanks!
Barry
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Connect Lines to Anchor Points
Reply #4 - Apr 16th, 2008 at 10:03am
Print Post  
That property is considered only if your nodes' AnchorPattern property is set. Either set it, or after the layout, iterate over the nodes and align their incoming links to their centers. That can be done by setting the link.ControlPoints[link.ControlPoints.Count - 1] point to the top-middle of the node.

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


I love YaBB 1G - SP1!

Posts: 45
Location: London, Ontario
Joined: Feb 11th, 2008
Re: Connect Lines to Anchor Points
Reply #5 - Apr 16th, 2008 at 8:04pm
Print Post  
Thanks Stoyo.... I need the line to anchor to the closest center point of the shape.

i.e. if it is close to the top, anchor top center if on the right side, anchor center on the right? Not sure if that make sense or not.


Barry
  
Back to top
 
IP Logged
 
mclellan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 45
Location: London, Ontario
Joined: Feb 11th, 2008
Re: Connect Lines to Anchor Points
Reply #6 - Apr 16th, 2008 at 8:34pm
Print Post  
I think I am close to your suggestion:

       Dim myLink As DiagramLink
       Dim aNode As DiagramNode
       For Each aNode In VectorDiagram.Nodes
           For Each myLink In aNode.IncomingLinks
               iT1 = aNode.IncomingLinks.Count
               'not sure what to set here to move the anchor

           Next
       Next
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Connect Lines to Anchor Points
Reply #7 - Apr 17th, 2008 at 7:31am
Print Post  
Find the top-middle point of the node:

dim mp as PointF = aNode.Bounds.Location
mp.X = mp.X + aNode.Bounds.Width / 2

Assign that point to myLink.ControlPoints(myLink.ControlPoints.Count - 1) and call myLink.UpdateFromPoints().

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


I love YaBB 1G - SP1!

Posts: 45
Location: London, Ontario
Joined: Feb 11th, 2008
Re: Connect Lines to Anchor Points
Reply #8 - Apr 17th, 2008 at 8:46pm
Print Post  
Thanks Stoyan,

Your example worked, however I think I may have explained it wrong.... sorry

I need to say... if a node has a line connecting to it and it is not centered (either left, right, top, or bottom) move to the nearest center point (not necessarily the center at the top of the node) as well, if our node is connecting to another node, connect at the closest center to you, if it is not connected to a center node already.

Maybe something like.... is this link connected to an anchor point? If no, connect to the closest anchor point of that object.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Connect Lines to Anchor Points
Reply #9 - Apr 18th, 2008 at 5:56am
Print Post  
If you need your links to always connect to the centers of the node sides, try this:

- create a new AnchorPattern in your form_load event
- add 4 points to it, at positions (50,0), (100, 50), (50, 100), (0, 50)
- assign that to the AnchorPattern property of all nodes
- set the Anchoring property of the layout object you are using to Reassign

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


I love YaBB 1G - SP1!

Posts: 12
Joined: Jul 23rd, 2008
Re: Connect Lines to Anchor Points
Reply #10 - Sep 11th, 2008 at 9:31am
Print Post  
I also need to acheive this, but with a flow layout. Unfortunately Flow Layout does not have an Anchoring property like the other layouts. Do you have some sample code on how I could acheive this with a flow layout?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Connect Lines to Anchor Points
Reply #11 - Sep 11th, 2008 at 12:46pm
Print Post  
Loop over Diagram.Links after applying the layout, and either set the positions of the first and last points in the ControlPoints collection so they are at the middle of the corresponding side of the node, or just set the link's OriginAnchor and DestinationAnchor properties if the node.AnchorPattern is set.

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