本文整理汇总了Java中prefuse.visual.NodeItem.getChildCount方法的典型用法代码示例。如果您正苦于以下问题:Java NodeItem.getChildCount方法的具体用法?Java NodeItem.getChildCount怎么用?Java NodeItem.getChildCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prefuse.visual.NodeItem
的用法示例。
在下文中一共展示了NodeItem.getChildCount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: layout
import prefuse.visual.NodeItem; //导入方法依赖的package包/类
/**
* Compute the tree map layout.
*/
private void layout(NodeItem p, Rectangle2D r) {
// create sorted list of children
Iterator<NodeItem> childIter = p.children();
while ( childIter.hasNext() )
m_kids.add(childIter.next());
Collections.sort(m_kids, s_cmp);
// do squarified layout of siblings
double w = Math.min(r.getWidth(),r.getHeight());
squarify(m_kids, m_row, w, r);
m_kids.clear(); // clear m_kids
// recurse
childIter = p.children();
while ( childIter.hasNext() ) {
NodeItem c = (NodeItem)childIter.next();
if ( c.getChildCount() > 0 && c.getDouble(AREA) > 0 ) {
updateArea(c,r);
layout(c, r);
}
}
}
示例2: calcAngularWidth
import prefuse.visual.NodeItem; //导入方法依赖的package包/类
/**
* Computes relative measures of the angular widths of each
* expanded subtree. Node diameters are taken into account
* to improve space allocation for variable-sized nodes.
*
* This method also updates the base angle value for nodes
* to ensure proper ordering of nodes.
*/
private double calcAngularWidth(NodeItem n, int d) {
if ( d > m_maxDepth ) m_maxDepth = d;
double aw = 0;
Rectangle2D bounds = n.getBounds();
double w = bounds.getWidth(), h = bounds.getHeight();
double diameter = d==0 ? 0 : Math.sqrt(w*w+h*h) / d;
if ( n.isExpanded() && n.getChildCount() > 0 ) {
Iterator childIter = n.children();
while ( childIter.hasNext() ) {
NodeItem c = (NodeItem)childIter.next();
aw += calcAngularWidth(c,d+1);
}
aw = Math.max(diameter, aw);
} else {
aw = diameter;
}
((Params)n.get(PARAMS)).width = aw;
return aw;
}
示例3: layout
import prefuse.visual.NodeItem; //导入方法依赖的package包/类
/**
* Compute the layout.
* @param n the root of the current subtree under consideration
* @param r the radius, current distance from the center
* @param theta1 the start (in radians) of this subtree's angular region
* @param theta2 the end (in radians) of this subtree's angular region
*/
protected void layout(NodeItem n, double r, double theta1, double theta2) {
double dtheta = (theta2-theta1);
double dtheta2 = dtheta / 2.0;
double width = ((Params)n.get(PARAMS)).width;
double cfrac, nfrac = 0.0;
Iterator childIter = sortedChildren(n);
while ( childIter != null && childIter.hasNext() ) {
NodeItem c = (NodeItem)childIter.next();
Params cp = (Params)c.get(PARAMS);
cfrac = cp.width / width;
if ( c.isExpanded() && c.getChildCount()>0 ) {
layout(c, r+m_radiusInc, theta1 + nfrac*dtheta,
theta1 + (nfrac+cfrac)*dtheta);
}
setPolarLocation(c, n, r, theta1 + nfrac*dtheta + cfrac*dtheta2);
cp.angle = cfrac*dtheta;
nfrac += cfrac;
}
}
示例4: firstWalk
import prefuse.visual.NodeItem; //导入方法依赖的package包/类
private void firstWalk(NodeItem n, int num, int depth) {
Params np = getParams(n);
np.number = num;
updateDepths(depth, n);
boolean expanded = n.isExpanded();
if ( n.getChildCount() == 0 || !expanded ) // is leaf
{
NodeItem l = (NodeItem)n.getPreviousSibling();
if ( l == null ) {
np.prelim = 0;
} else {
np.prelim = getParams(l).prelim + spacing(l,n,true);
}
}
else if ( expanded )
{
NodeItem leftMost = (NodeItem)n.getFirstChild();
NodeItem rightMost = (NodeItem)n.getLastChild();
NodeItem defaultAncestor = leftMost;
NodeItem c = leftMost;
for ( int i=0; c != null; ++i, c = (NodeItem)c.getNextSibling() )
{
firstWalk(c, i, depth+1);
defaultAncestor = apportion(c, defaultAncestor);
}
executeShifts(n);
double midpoint = 0.5 *
(getParams(leftMost).prelim + getParams(rightMost).prelim);
NodeItem left = (NodeItem)n.getPreviousSibling();
if ( left != null ) {
np.prelim = getParams(left).prelim + spacing(left, n, true);
np.mod = np.prelim - midpoint;
} else {
np.prelim = midpoint;
}
}
}
示例5: 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();
}
};
}