Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to prevent overlapping of link labels? (Read 3986 times)
Necroman
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
How to prevent overlapping of link labels?
Nov 27th, 2009 at 9:41am
Print Post  
Hi, after a long time I'm still facing this issue: how to prevent overlapping of link labels without the explicit need of re-layouting our diagram?
The problem occurs, if there is more then one link with same source and destination node.

This is how the situation looks:


The solution might allowing other connection points, then the top middle and bottom middle one, but that might screw up the layout...
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to prevent overlapping of link labels?
Reply #1 - Nov 27th, 2009 at 10:05am
Print Post  
And how do you expect such links and labels to be laid out?
  
Back to top
 
IP Logged
 
Necroman
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Re: How to prevent overlapping of link labels?
Reply #2 - Nov 27th, 2009 at 12:08pm
Print Post  
Maybe in some way draw the labels next to each other.
I'm not sure either, how to solve this, but definitely current solution is not the way user wants to read the link labels.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to prevent overlapping of link labels?
Reply #3 - Nov 27th, 2009 at 1:31pm
Print Post  
You might custom-draw the labels:

Code
Select All
private void diagram_LinkCreated(object sender, LinkEventArgs e)
{
	DiagramLink link = e.Link;
	if (link.Origin == link.Destination)
	{
		link.TextColor = Color.Transparent;
		link.CustomDraw = CustomDraw.Additional;
		link.Text = "test test";
	}
}

private void diagram_DrawLink(object sender, DrawLinkEventArgs e)
{
	if (e.Link.Origin != e.Link.Destination)
		return;

	int selfLoopCounter = -1;
	foreach (DiagramLink link in e.Link.Origin.OutgoingLinks)
	{
		if (link.Origin == link.Destination)
			selfLoopCounter++;
		if (link == e.Link)
			break;
	}
	PointF p = e.Link.ControlPoints[1];
	p.Y -= selfLoopCounter * 3;
	e.Graphics.DrawString(e.Link.Text, e.Link.Font, Brushes.Black, p);
}
 



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


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Re: How to prevent overlapping of link labels?
Reply #4 - Dec 15th, 2009 at 12:02pm
Print Post  
Yes, that helped, thanks Smiley

I've just generalized the method for any situation, where two or more links with same source and destination might occur.
  
Back to top
 
IP Logged
 
Necroman
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Re: How to prevent overlapping of link labels?
Reply #5 - Dec 15th, 2009 at 2:58pm
Print Post  
Just a small question, is it possible for these custom drawn labels to catch (double)clicking in the same way double-click is being catched on standard link label and/or the line itself?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to prevent overlapping of link labels?
Reply #6 - Dec 15th, 2009 at 4:10pm
Print Post  
There's nothing built-in to help you with that... You might try storing the positions where labels were last drawn in a Dictionary<link,labelRect> and find which rectangle/link contains the point in the DiagramClicked event. Another option is to use nodes attached to the links as labels.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint