Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Custom DiagramNode with variable AnchorPoints (Read 2291 times)
VENSION
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 2
Joined: Sep 28th, 2011
Custom DiagramNode with variable AnchorPoints
Sep 28th, 2011 at 9:42pm
Print Post  
I created a custom DiagramNode named FlowStepNode that inherits from the DiagramNode object. Basically, it is a wrapper node that stores an object that implements a custom interface of mine. This interface exposes an Input object and an Outputs collection. I am trying to resize the FlowstepNode and generate the AnchorPoints based on these properties (Input/Outputs). The problem I’m running into is that the existing DiagramLinks don’t seem to keep in line with the AnchorPoint they were originally assigned to.

Please see the attached screenshots for an example:

Nodes correctly linked.

Additional outputs for the FlowStep were added, and therefore additional AnchorPoints were added and the DiagramNode was resized.

The DiagramLink's were deleted and recreated manually to reassociate them with the correct AnchorPoints.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom DiagramNode with variable AnchorPoints
Reply #1 - Sep 29th, 2011 at 6:21am
Print Post  
If you are adding AnchorPoints to an AnchorPattern dynamically, keep in mind that the X and Y coordinates are percents of the node's width and height. If the initial point had Y set to 50 (half the node height), you will have to replace it with one that reflects the new relative position, say 25 (quarter of the height).

Other options you might consider are deriving from TableNode and associating links with table rows (possibly with rows' AnchorPattern set), or creating a ConnectionPoint derived class that keeps the Output/Input index associated with a link and returns the absolute position from the GetEndPoint() override.

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


I love YaBB 1G - SP1!

Posts: 2
Joined: Sep 28th, 2011
Re: Custom DiagramNode with variable AnchorPoints
Reply #2 - Sep 29th, 2011 at 2:49pm
Print Post  
That's what I thought at first, but it doesn't appear to be the case (unless I'm missing something).
In the image below, the AnchorPoints for the DiagramLink labeled Output has the following positions:
  • Origin: X = 92.0, Y = 62.5
  • Destination: X=8.0, Y=25.0

And the AnchorPoints for the DiagramLink labeled MaxRetries has these positions:
  • Origin: X = 92.0, Y = 25.0
  • Destination: X=8.0, Y=62.5






It appears that the AnchorPoints have the correct position, just that the DiagramLinks are pointing to where the AnchorPoint used to be before I updated it. Any ideas?


Also, I did not dismiss your idea of inheriting from a TableNode. Right now this project is more of a proof of concept, and I cant really commit the amount of time it would take to learn how the TableNode works and make all of the necessary changes. As far as the ConnectionPoint solution, I wouldnt have any idea where to start.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom DiagramNode with variable AnchorPoints
Reply #3 - Sep 29th, 2011 at 3:22pm
Print Post  
Have you assigned 25 to AnchorPoint.Y after the node has been resized? AnchorPoints were not designed to be that dynamic and changing their coordinates won't force the link to move to the new position. I think links realign to anchor points when a node is moved or resized, so it should work if you change the point position before setting node.Bounds.

Alternatively, you could reset the link's OriginIndex or DestinationIndex value after changing the AnchorPoint coordinates - that should realign the link too:

Code
Select All
int index = link.OriginAnchor;
link.OriginAnchor = -1;
link.OriginAnchor = index; 



Regarding TableNodes, the "Entities" sample project shows something very similar to what you are doing, using tables and anchor points associated with rows.

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