当前位置: 首页>>代码示例>>Java>>正文


Java NodeItem.getChildCount方法代码示例

本文整理汇总了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);
        }
    }
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:26,代码来源:SquarifiedTreeMapLayout.java

示例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;
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:30,代码来源:RadialTreeLayout.java

示例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;
    }
    
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:29,代码来源:RadialTreeLayout.java

示例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;
        }
    }
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:42,代码来源:NodeLinkTreeLayout.java

示例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();
        }
    };
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:44,代码来源:RadialTreeLayout.java


注:本文中的prefuse.visual.NodeItem.getChildCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。