一种方法可能是添加JForcePanel,即
Swing组件,用于Force在
给定的框架中配置功能参数ForceSimulator。
在制作可视化文件时对探索不同的参数设置很有用。
这可能有助于您找到在的
实现中使用的最佳参数
getForceSimulator()。
ForceSimulator fsim = ((ForceDirectedLayout) layout.get(0)).getForceSimulator();JForcePanel fpanel = new JForcePanel(fsim);frame.add(fpanel, BorderLayout.SOUTH);
其中demos包括prefuse.demos.GraphView一个完整的示例。根据经验,某些参数似乎
取决于所选数据集具有或多或少的作用。
附录:仔细观察,我发现您的方法使内部状态fdl保持不变。而是创建一个新文件ForceSimulator,并在
布局和强制面板中使用它。下面的示例将defaultLengtha的SpringForce从更改DEFAULT_SPRING_LENGTH为42。
ForceDirectedLayout fdl = new ForceDirectedLayout("graph");ForceSimulator fs = new ForceSimulator();fs.addForce(new NBodyForce());fs.addForce(new DragForce());fs.addForce(new SpringForce(DEFAULT_SPRING_COEFF, 42));fdl.setForceSimulator(fs);另外,更新的SpringForce直接
ForceDirectedLayout fdl = new ForceDirectedLayout("graph");ForceSimulator fs = fdl.getForceSimulator();Force[] forces = fs.getForces();SpringForce sf = (SpringForce) forces[2];sf.setParameter(SPRING_LENGTH, 42);


