本文整理汇总了Java中prefuse.visual.NodeItem.getChild方法的典型用法代码示例。如果您正苦于以下问题:Java NodeItem.getChild方法的具体用法?Java NodeItem.getChild怎么用?Java NodeItem.getChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prefuse.visual.NodeItem
的用法示例。
在下文中一共展示了NodeItem.getChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sortedChildren
import prefuse.visual.NodeItem; //导入方法依赖的package包/类
private Iterator sortedChildren(final NodeItem n) {
double base = 0;
// update base angle for node ordering
NodeItem p = (NodeItem)n.getParent();
if ( p != null ) {
base = normalize(Math.atan2(p.getY()-n.getY(), p.getX()-n.getX()));
}
int cc = n.getChildCount();
if ( cc == 0 ) return null;
NodeItem c = (NodeItem)n.getFirstChild();
// TODO: this is hacky and will break when filtering
// how to know that a branch is newly expanded?
// is there an alternative property we should check?
if ( !c.isStartVisible() ) {
// use natural ordering for previously invisible nodes
return n.children();
}
double angle[] = new double[cc];
final int idx[] = new int[cc];
for ( int i=0; i<cc; ++i, c=(NodeItem)c.getNextSibling() ) {
idx[i] = i;
angle[i] = normalize(-base +
Math.atan2(c.getY()-n.getY(), c.getX()-n.getX()));
}
ArrayLib.sort(angle, idx);
// return iterator over sorted children
return new Iterator() {
int cur = 0;
public Object next() {
return n.getChild(idx[cur++]);
}
public boolean hasNext() {
return cur < idx.length;
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}