2007年11月22日星期四

SWT图模型可视化工具包

以前在Swing下用prefuse很爽,如今需要用SWT了,只好又在sf.net上寻觅良久,终于找到了"梦中情人"――JUNG
也许,图模型可视化算法在计算机图形学或计算机模拟中也是一个问题吧。记得当时看到prefuse里面有Force类,Spring类,很诧异它何苦为了一点交互可视化效果引入如此sophisticated的力学模型。印象最深刻的是,作者在NBodyForce 类的注释中非常学术地写道:
/**
* <p>Force function which computes an n-body force such as gravity,
* anti-gravity, or the results of electric charges. This function implements
* the the Barnes-Hut algorithm for efficient n-body force simulations,
* using a quad-tree with aggregated mass values to compute the n-body
* force in O(N log N) time, where N is the number of ForceItems.</p>
*
* <p>The algorithm used is that of J. Barnes and P. Hut, in their research
* paper <i>A Hierarchical  O(n log n) force calculation algorithm</i>, Nature,
*  v.324, December 1986. For more details on the algorithm, see one of
*  the following links --
* <ul>
*   <li><a href=" http://www.cs.berkeley.edu/~demmel/cs267/lecture26/lecture26.html">James Demmel's UC Berkeley lecture notes</a>
*   <li><a href=" http://www.physics.gmu.edu/~large/lr_forces/desc/bh/bhdesc.html">Description of the Barnes-Hut algorithm</a>
*   <li><a href=" http://www.ifa.hawaii.edu/~barnes/treecode/treeguide.html">Joshua Barnes' recent implementation</a>
* </ul></p>
*
* @author <a href="http://jheer.org ">jeffrey heer</a>
*/

如今的"用户"比较仁慈,他说不需要交互,我终于大松一口气,可以不用再去管弹簧啦!
然而打开JUNG的Layout引擎的代码,我又被他折服了。先看看类定义,非常OO
public class FRLayout extends AbstractLayout implements LayoutMutable
再看一眼注释,非常简短两行
/**
* Implements the Fruchterman-Reingold algorithm for node layout.
*
* @author Scott White, Yan-Biao Boey, Danyel Fisher
*/

搜一下这个算法,发现也是有来路滴~
T. Fruchterman and E. Reingold
Graph drawing by force-directed placement.
Software--Practice & Experience, 21 (11), pp. 1129-1164, 1991.


没有评论: