Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Offsetting diagram link endpoints through ConnectionPoint-override (Read 3349 times)
stefski
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 31
Location: Norway
Joined: Jul 17th, 2009
Offsetting diagram link endpoints through ConnectionPoint-override
Apr 22nd, 2015 at 1:52pm
Print Post  
Hi,

in our application we have modified the visual points of connection of the DiagramNodes so that after the user has connected a DiagramLink to an anchor point on a node, the link end is offset by a few units outside the node. We close the gap between the node edge and the link endpoint by custom-drawing on the node.

The offset is controlled by our ConnectionPoint-derived class, in which we override the GetAnchorPos() and GetEndPoint() methods.

For the most part this works nicely. However, one remaining problem is that when the user makes a connection, it seems like our ConnectionPoint implementation is not immediately having any effect, as the end of the diagram link object is not offset. Only when the user moves or rotates the node, the link end snaps in place.

We experience this in version 5.7, but also in the trial version of 6.3.2 (hoping to get a purchase through shortly).

Do we need to override additional methods in our ConnectionPoint-derived class? I thought of overriding the GetInitialPoint() method, but at the time that is called, the link does not yet have valid anchor indexes, so I have no way of knowing which gap to fill (between the link end and the anchor point on the node). Sad

  

Kind regards

Steffen Skov
OLGA Application Architect
Schlumberger Information Solutions AS
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Offsetting diagram link endpoints through ConnectionPoint-override
Reply #1 - Apr 23rd, 2015 at 8:44am
Print Post  
Hi,

I can't see any way to implement the offset via ConnectionPoint overrides. If using anchor points, can't you implement the offset by setting anchor positions outside of the node boundaries? Since v6.0.4 you can also specify anchor positions as fixed coordinates rather than percentage via the XUnit and YUnit properties of AnchorPoint class.

It should be also possible to implement the initial offset by moving link.ControlPoints[0] and calling UpdateFromPoints from an override of the StartDraw method of behavior classes.

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


I love YaBB 1G - SP1!

Posts: 31
Location: Norway
Joined: Jul 17th, 2009
Re: Offsetting diagram link endpoints through ConnectionPoint-override
Reply #2 - Apr 24th, 2015 at 7:12am
Print Post  
Hi Stoyan,

we have considered placing the anchor points outside the node boundaries, but there are two concerns associated with that:

1) Depending on the size of the offset, determined by our UX designer, placing the anchor points at that offset, there might be a visible gap between the boundaries and the anchor points, which might cause confusion for the user.

2) As the offset is a fixed size, not proportional to the size of the node, it will not be possible to correctly position the anchors on the "outside" of the offset, as the positions would become wrong when the user re-sizes the node.

I am a bit surprised that a ConnectionPoint-derived class should not be able to solve this. According to the documentation I got the impression that this was right in its playing field. Also, with our current code, it works very nicely, except for that initial positioning being wrong, and which snaps into place as soon as the user moves or rotates the node.

The fixed anchor point coordinates sounds interesting. Is it possible to dynamically update these coordinates on node re-sizing? And will connected links adjust themselves to the updated coordinates?

  

Kind regards

Steffen Skov
OLGA Application Architect
Schlumberger Information Solutions AS
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Offsetting diagram link endpoints through ConnectionPoint-override
Reply #3 - Apr 27th, 2015 at 10:55am
Print Post  
Hi Steffen,

Quote:
1) Depending on the size of the offset, determined by our UX designer, placing the anchor points at that offset, there might be a visible gap between the boundaries and the anchor points, which might cause confusion for the user.


To me it sounds more confusing to show links connected to a different position than one indicated by anchor point marks Smiley but if you need visual offset too you should be able to custom-draw it from DrawAnchorPoint event handler.

Quote:
I am a bit surprised that a ConnectionPoint-derived class should not be able to solve this. According to the documentation I got the impression that this was right in its playing field. Also, with our current code, it works very nicely, except for that initial positioning being wrong, and which snaps into place as soon as the user moves or rotates the node.


At this time ConnectionPoint is used to abstract links from node types and their child items (e.g. table rows), but not from node's AnchorPattern. Alignment to anchor points is handled by nodes themselves, so you can't override it via custom ConnectionPoint class. We could probably move the alignment logic to ConnectionPoint too for next release if you prefer applying offsets there instead of moving the anchor points.

Quote:
The fixed anchor point coordinates sounds interesting. Is it possible to dynamically update these coordinates on node re-sizing? And will connected links adjust themselves to the updated coordinates?


It seems possible via NodeModifying event handler:

Code
Select All
private void diagram_NodeModifying(object sender, NodeValidationEventArgs e)
{
	var pattern = e.Node.AnchorPattern;
	if (pattern != null)
	{
		foreach (var ap in pattern.Points)
			if ("right".Equals(ap.Tag))
				ap.X = e.Node.Bounds.Width + 10;
	}
}

private void diagram_NodeCreated(object sender, NodeEventArgs e)
{
	e.Node.AnchorPattern = new AnchorPattern(new[]
 	{
 		new AnchorPoint(e.Node.Bounds.Width + 10, 10) { Tag = "right", XUnit = UnitType.Fixed }
 	});
} 



Having Fixed-unit coordinates relative to right or bottom node sides looks useful, we'll implement some out-of-the-box support for them for next release.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Offsetting diagram link endpoints through ConnectionPoint-override
Reply #4 - Jun 10th, 2015 at 12:01pm
Print Post  
This build now lets you override ConnectionPoint.NearestAnchorPoint method, and the control calls it at beginning of link creation instead of the node's one:
https://mindfusion.eu/_beta/connection_anchor.zip

If you need to offset the link end point from the actual position of anchor point, you must also override the GetEndPoint method.

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