您用的是JUNG包构建网络么?* z6 l$ @8 P3 N' S1 x) }
JUNG中可视化设置:
1 a" k% E; M' }) j' v8 |4 S//1. 初始化一个图g----(例如:Graph<V,E> g=new SparseGraph<V,E>(); 2 z+ X0 g3 u; t- v
//2. 书写节点&连线添加规则(应该就是楼大自己构建的网络)( d! f3 A- ~4 B" J6 z* x2 E/ c: P
//3 创建布局管理器
1 V, c" B, V0 q! i2 r Layout<V,E> layout = new KKLayout(g);(这只是其中一种布局方式,具体的楼大请见api)
: s6 u2 N+ {2 t3 c! j6 L( |//4. 添加面板类BasicVisualizationServer' {5 C: s: o, i& h# d. V
BasicVisualizationServer<V,E> vv = new BasicVisualizationServer<V,E>(layout);6 ]9 t/ C) X+ m0 M* u- k
//5. 将上述对象放置在一个JFrame框架中并显示之/ I- y6 L+ v. i& q2 d' F; a
frame.getContentPane().add(vv);
; k! o3 K6 v% ~ ~4 d" q5 b/ G frame.pack();- Q1 l' Y( q' a
frame.setVisible(true);
- n. d3 G6 y v2 b4 }+ Q% f/ e& ?2 }+ Y5 K( Z3 Z& Q6 O, A
希望对您有用…… |