Prevent edge overlap


https://www.nevron.com/Forum/Topic7648.aspx
Print Topic | Close Window

By Aravin S - 11 Years Ago
Hi,

I am trying to create a directed graph with 2 links between a source and a target. I am using a NDynamic port with DynamicPortGlueMode.GlueToRotatedBounds. However, the edges are overlapping each other (pic1). Is there a way to show both edges with a slight separation so that it is easy to see both of the edges (pic2)?
By Nevron Support - 11 Years Ago

Hi,

To prevent the connectors from overlapping, you should modify the offset of their start and end plugs. Take a look at the following example and especially on the lines in bold:

NBasicShapesFactory factory = new NBasicShapesFactory();

factory.DefaultSize = new NSizeF(100, 100);

 

NShape shape1 = factory.CreateShape(BasicShapes.Rectangle);

shape1.Text = "Shape 1";

shape1.Location = new NPointF(100, 100);

document.ActiveLayer.AddChild(shape1);

 

NShape shape2 = factory.CreateShape(BasicShapes.Rectangle);

shape2.Text = "Shape 2";

shape2.Location = new NPointF(300, 100);

document.ActiveLayer.AddChild(shape2);

 

NLineShape line1 = new NLineShape();

line1.StyleSheetName = "Connectors";

line1.StartPlug.Offset = new NSizeF(0, -10);

line1.EndPlug.Offset = new NSizeF(0, -10);

document.ActiveLayer.AddChild(line1);

line1.FromShape = shape1;

line1.ToShape = shape2;

 

NLineShape line2 = new NLineShape();

line2.StyleSheetName = "Connectors";

line2.StartPlug.Offset = new NSizeF(0, 10);

line2.EndPlug.Offset = new NSizeF(0, 10);

document.ActiveLayer.AddChild(line2);

line2.FromShape = shape2;

line2.ToShape = shape1;

This piece of code will result in the following diagram (which exactly fulfils your requirements):

Nevron Diagram Offsetted Connectors

By Aravin S - 11 Years Ago
Hi,

Thank you for the response. I tried this approach. However, when I move the nodes around, the link separation is not uniform (pic). Some even overlap at certain angles. Is there a way to have a uniform separation among the links (e.g. say 2 px)? There is only 1 DynamicPorts on each vertex. Should I add more ports? I need the links to point to the center. Or should I manually set the separation on some event?

Thanks.
By Nevron Support - 11 Years Ago
Hello Aravin,
You should submit a support ticket. Take a look at the technical support options here: http://www.nevron.com/Support.Overview.aspx