I would like to animate the layout process, so that the actual motions of moving nodes is clearly visible to the user. I tried injecting delays of various types, including in the updatePositions (by overriding the ForceDirectedAutoLayout class), but to no avail. Any insight would be appreciated.
The LayoutDemo sample does that for the force-directed autolayout. Have you looked at that code?
I’ve read in the docs that you could override the layoutnodesandlinks and
someway call (updatePositions ?) until it reaches the final iteration. I
couldn’t test it yet because I’m using a demo license and the splash
message don’t let me see the animation (soon I maybe purchasing the
license 8) ).
But my question lies here: I’m not been able to get different results
setting the forces, mass, lengh … attributes. Don’t know if it’s because of
my demo license or I’m doing something wrong.
I get the JGoNetwork from my document and after that I iterate links and
nodes setting the attributes… So I call my constructor of my forcedirected
class and call performlayout. The results are all the same.
Am I missing something ?
Thanks in advance,
The evaluation kit provides the complete functionality, except for the message box that appears.
Basically you need to override certain methods on JGoForceDirectedAutoLayout to change the behavior. This is done, for example, by the SimpleFDAL class in the LayoutDemo example.
thanks for your quick response.
I did exactly what you have told but with no success. I’ve tried overriding
the constructor methods, specially that with JGoNetwork as parameter.
Then I tried overriding all the constructors. All methods but the “get”
methods which I found unnecessary to my case. Until now I haven’t
understood quite well the layoutdemo example . How the colored nodes
are set, their forces, masses…
I’d be grateful if you could point me some directions… I’m trying to make
a 2d hyperbolic graph.
But overriding the “get…” methods are exactly what’s needed to customize the forces.
For example, look at how SimpleFDAL overrides getGravitationalMass to look at the node’s color to decide what value to return.
Great ! Now I understand everything. My mistake.
Thanks a lot.
Ok. I purchased a license of jGoLayout and I’m trying to animate the Force
I tried overriding the layoutNodesAndLinks and call the
comitNodesAndLinks more than just when isfinal = true, but with no
I tried call my performlayout method each node and link I put in the view,
but didn’t work also.
You said that layout demo should be helpful but I haven’t found the
overridden layoutNodesAndLinks there…
I’m certainly missing something.
Thanks in advance again,
I don’t think you need to override layoutNodesAndLinks, but progressUpdate.
Take a look at the definition of SimpleFDAL.progressUpdate in the LayoutDemo example.
I’ve only chosen this way because the documentation says: “One reason to
override this method would be to accomodate an animated layout
algorithm. The layoutNodesAndLinks method is called once each
iteration and one final time. At a minimum, sub-classes that override this
method should perform getNetwork().commitNodesAndLinks() on the
final call to layoutNodesAndLinks.”
But I’ve tried also overriding the progressUpdate method and it’s not
I noticed the view.paintImmediately(view.getViewRect()) and tried to put
some of it in my code, but I’m still seen NO animation or results until the
final graph is set. No screen updates in between.
Any clues ?
I have some news.
Minutes ago I had an idea: test the applet on Windows… So: the
animation is working there !
But I’m developing this app on MacOS X Panther and here, no animation
until the graph is set and with the final layout.
My client wants this to work on Mac also… Is there any chance that he’ll
be satisfied ?
That’s interesting. I wonder if that’s a bug in Apple’s implementation of Java and Swing.
Ok. More news…
Just upgraded to java 1.4.2 update 2 and the animation works on MacOS