本文整理汇总了Java中prefuse.data.Graph.nodes方法的典型用法代码示例。如果您正苦于以下问题:Java Graph.nodes方法的具体用法?Java Graph.nodes怎么用?Java Graph.nodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prefuse.data.Graph
的用法示例。
在下文中一共展示了Graph.nodes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import prefuse.data.Graph; //导入方法依赖的package包/类
private void init(Graph g, Rectangle2D b) {
initSchema(g.getNodes());
temp = b.getWidth() / 10;
forceConstant = 0.75 *
Math.sqrt(b.getHeight()*b.getWidth()/g.getNodeCount());
// initialize node positions
Iterator nodeIter = g.nodes();
Random rand = new Random(42); // get a deterministic layout result
double scaleW = ALPHA*b.getWidth()/2;
double scaleH = ALPHA*b.getHeight()/2;
while ( nodeIter.hasNext() ) {
NodeItem n = (NodeItem)nodeIter.next();
Params np = getParams(n);
np.loc[0] = b.getCenterX() + rand.nextDouble()*scaleW;
np.loc[1] = b.getCenterY() + rand.nextDouble()*scaleH;
}
}
示例2: calcRepulsion
import prefuse.data.Graph; //导入方法依赖的package包/类
public void calcRepulsion(Graph g, NodeItem n1) {
Params np = getParams(n1);
np.disp[0] = 0.0; np.disp[1] = 0.0;
for (Iterator iter2 = g.nodes(); iter2.hasNext();) {
NodeItem n2 = (NodeItem) iter2.next();
Params n2p = getParams(n2);
if (n2.isFixed()) continue;
if (n1 != n2) {
double xDelta = np.loc[0] - n2p.loc[0];
double yDelta = np.loc[1] - n2p.loc[1];
double deltaLength = Math.max(EPSILON,
Math.sqrt(xDelta*xDelta + yDelta*yDelta));
double force = (forceConstant*forceConstant) / deltaLength;
if (Double.isNaN(force)) {
System.err.println("Mathematical error...");
}
np.disp[0] += (xDelta/deltaLength)*force;
np.disp[1] += (yDelta/deltaLength)*force;
}
}
}
示例3: finish
import prefuse.data.Graph; //导入方法依赖的package包/类
private void finish(Graph g) {
Iterator nodeIter = g.nodes();
while ( nodeIter.hasNext() ) {
NodeItem n = (NodeItem)nodeIter.next();
Params np = getParams(n);
setX(n, null, np.loc[0]);
setY(n, null, np.loc[1]);
}
}