Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Applying Spring layout continuously (Read 4850 times)
jf2020
Junior Member
**
Offline


I love FlowChart!

Posts: 63
Joined: Feb 23rd, 2006
Applying Spring layout continuously
Feb 23rd, 2006 at 10:31am
Print Post  
Hi,

I'm trying to have  a diagram constantly rearranged using the spring layout while still letting the user interact with it.  Can this be achieved? Should the arrange() be called in another thread or using a timer?

Thanks in advance for your help with this!

Jean-Francois
  
Back to top
 
IP Logged
 
jf2020
Junior Member
**
Offline


I love FlowChart!

Posts: 63
Joined: Feb 23rd, 2006
Re: Applying Spring layout continuously
Reply #1 - Feb 23rd, 2006 at 12:21pm
Print Post  
Hum, I'm replying to myself and I apologize for maybe asking a question without better testing first.

I got it to work using a timer that calls the arrange() every 100ms. 

However is it the best way to achive it?  What is a good combination of timer update / number of iterations for the layout on each timer event?

Thanks!

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Applying Spring layout continuously
Reply #2 - Feb 23rd, 2006 at 12:22pm
Print Post  
Hi,

I dont know whether this will work well. The SpringLayout updates some state variables after each iteration (e.g. simulated node speeds), so calling the Arrange method N times with 1 iteration won't produce the same layout as calling it once with N iterations. I guess our developers could add a NextIteration method to let you advance the layout algorithm from a timer event, updating the internal state as needed.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Applying Spring layout continuously
Reply #3 - Feb 23rd, 2006 at 12:29pm
Print Post  
Well, great if it works for you like that. Probably it would be better to call Arrange 3-4 times in a second,  but with more iterations. Each call to Arrange does some housekeeping work such as analyzing how many unconnected graphs are there in the diagram, so the fewer times you call it the better...
« Last Edit: Feb 23rd, 2006 at 1:52pm by Stoyo »  
Back to top
 
IP Logged
 
jf2020
Junior Member
**
Offline


I love FlowChart!

Posts: 63
Joined: Feb 23rd, 2006
Re: Applying Spring layout continuously
Reply #4 - Feb 24th, 2006 at 6:53am
Print Post  
Hi Stoyo,

First thanks for the quick answer.

I tried to apply your suggestion of having less frequent calls with more iterations. The problem is that it gives a much more "chopy" or "stuttering" behavior as a large number of iterations are applied and then there's a pause.
Having a nextIteration() as you proposed would certainly be great in achieving a smooth behavior. I think that nextIteration() could simply be like a call to arrange() that would not reset the internal state, but still if needed execute more than one iteration in order not to have to be called too frequently.

I have a second problem that right now is more annoying for my application. I need to be able to fix the position of some nodes while still applying the spring Layout. I tried to set the IgnoreLayout property, but then it seems that the node is no longer included at all in the springLayout algorithm meaning that the connected nodes are "jumping" to strange positions.
Basically what I'm trying to achieve is something like the clustered layout, but I need to be able to fix the position of some key nodes.

Jean-Francois

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Applying Spring layout continuously
Reply #5 - Feb 24th, 2006 at 8:07am
Print Post  
Hi  Jean-Francois,

We will have to alter the SpringLayout implementation if you need some nodes to stay fixed and still influence the positions of other nodes. I guess we could reuse the Locked property for that or change the type of IgnoreLayout to enumeration with a member that specifies that condition.

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