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


Java NodeItem.getParent方法代码示例

本文整理汇总了Java中prefuse.visual.NodeItem.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java NodeItem.getParent方法的具体用法?Java NodeItem.getParent怎么用?Java NodeItem.getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在prefuse.visual.NodeItem的用法示例。


在下文中一共展示了NodeItem.getParent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: layoutRow

import prefuse.visual.NodeItem; //导入方法依赖的package包/类
private Rectangle2D layoutRow(List row, double w, Rectangle2D r) {        
    double s = 0; // sum of row areas
    Iterator rowIter = row.iterator();
    while ( rowIter.hasNext() )
        s += ((VisualItem)rowIter.next()).getDouble(AREA);
    double x = r.getX(), y = r.getY(), d = 0;
    double h = w==0 ? 0 : s/w;
    boolean horiz = (w == r.getWidth());
    
    // set node positions and dimensions
    rowIter = row.iterator();
    while ( rowIter.hasNext() ) {
        NodeItem n = (NodeItem)rowIter.next();
        NodeItem p = (NodeItem)n.getParent();
        if ( horiz ) {
            setX(n, p, x+d);
            setY(n, p, y);
        } else {
            setX(n, p, x);
            setY(n, p, y+d);
        }
        double nw = n.getDouble(AREA)/h;
        if ( horiz ) {
            setNodeDimensions(n,nw,h);
            d += nw;
        } else {
            setNodeDimensions(n,h,nw);
            d += nw;
        }
    }
    // update space available in rectangle r
    if ( horiz )
        r.setRect(x,y+h,r.getWidth(),r.getHeight()-h);
    else
        r.setRect(x+h,y,r.getWidth()-h,r.getHeight());
    return r;
}
 
开发者ID:codydunne,项目名称:netgrok,代码行数:38,代码来源:SquarifiedHostTreeMapLayout.java

示例2: getPoint

import prefuse.visual.NodeItem; //导入方法依赖的package包/类
private Point2D getPoint(NodeItem n, boolean start) {
    // find the visible ancestor
    NodeItem p = (NodeItem)n.getParent();
    if ( start )
        for (; p!=null && !p.isStartVisible(); p=(NodeItem)p.getParent());
    else
        for (; p!=null && !p.isEndVisible(); p=(NodeItem)p.getParent());
    if ( p == null ) {
        m_point.setLocation(n.getX(), n.getY());
        return m_point;
    }
    
    // get the vanishing/appearing point
    double x = start ? p.getStartX() : p.getEndX();
    double y = start ? p.getStartY() : p.getEndY();
    Rectangle2D b = p.getBounds();
    switch ( m_orientation ) {
    case Constants.ORIENT_LEFT_RIGHT:
        m_point.setLocation(x+b.getWidth(), y);
        break;
    case Constants.ORIENT_RIGHT_LEFT:
        m_point.setLocation(x-b.getWidth(), y);
        break;
    case Constants.ORIENT_TOP_BOTTOM:
        m_point.setLocation(x, y+b.getHeight());
        break;
    case Constants.ORIENT_BOTTOM_TOP:
        m_point.setLocation(x, y-b.getHeight());
        break;
    case Constants.ORIENT_CENTER:
        m_point.setLocation(x, y);
        break;
    }
    return m_point;
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:36,代码来源:CollapsedSubtreeLayout.java

示例3: ancestor

import prefuse.visual.NodeItem; //导入方法依赖的package包/类
private NodeItem ancestor(NodeItem vim, NodeItem v, NodeItem a) {
    NodeItem p = (NodeItem)v.getParent();
    Params vimp = getParams(vim);
    if ( vimp.ancestor.getParent() == p ) {
        return vimp.ancestor;
    } else {
        return a;
    }
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:10,代码来源:NodeLinkTreeLayout.java

示例4: layoutRow

import prefuse.visual.NodeItem; //导入方法依赖的package包/类
private Rectangle2D layoutRow(List<NodeItem> row, double w, Rectangle2D r) {        
    double s = 0; // sum of row areas
    Iterator<NodeItem> rowIter = row.iterator();
    while ( rowIter.hasNext() )
        s += rowIter.next().getDouble(AREA);
    double x = r.getX(), y = r.getY(), d = 0;
    double h = w==0 ? 0 : s/w;
    boolean horiz = (w == r.getWidth());
    
    // set node positions and dimensions
    rowIter = row.iterator();
    while ( rowIter.hasNext() ) {
        NodeItem n = rowIter.next();
        NodeItem p = (NodeItem)n.getParent();
        if ( horiz ) {
            setX(n, p, x+d);
            setY(n, p, y);
        } else {
            setX(n, p, x);
            setY(n, p, y+d);
        }
        double nw = n.getDouble(AREA)/h;
        if ( horiz ) {
            setNodeDimensions(n,nw,h);
            d += nw;
        } else {
            setNodeDimensions(n,h,nw);
            d += nw;
        }
    }
    // update space available in rectangle r
    if ( horiz )
        r.setRect(x,y+h,r.getWidth(),r.getHeight()-h);
    else
        r.setRect(x+h,y,r.getWidth()-h,r.getHeight());
    return r;
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:38,代码来源:SquarifiedTreeMapLayout.java

示例5: calcAngularBounds

import prefuse.visual.NodeItem; //导入方法依赖的package包/类
/**
 * Calculates the angular bounds of the layout, attempting to
 * preserve the angular orientation of the display across transitions.
 */
private void calcAngularBounds(NodeItem r) {
    if ( m_prevRoot == null || !m_prevRoot.isValid() || r == m_prevRoot )
    {
        m_prevRoot = r;
        return;
    }
    
    // try to find previous parent of root
    NodeItem p = m_prevRoot;
    while ( true ) {
        NodeItem pp = (NodeItem)p.getParent();
        if ( pp == r ) {
            break;
        } else if ( pp == null ) {
            m_prevRoot = r;
            return;
        }
        p = pp;
    }

    // compute offset due to children's angular width
    double dt = 0;
    Iterator iter = sortedChildren(r);
    while ( iter.hasNext() ) {
        Node n = (Node)iter.next();
        if ( n == p ) break;
        dt += ((Params)n.get(PARAMS)).width;
    }
    double rw = ((Params)r.get(PARAMS)).width;
    double pw = ((Params)p.get(PARAMS)).width;
    dt = -MathLib.TWO_PI * (dt+pw/2)/rw;

    // set angular bounds
    m_theta1 = dt + Math.atan2(p.getY()-r.getY(), p.getX()-r.getX());
    m_theta2 = m_theta1 + MathLib.TWO_PI;
    m_prevRoot = r;     
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:42,代码来源:RadialTreeLayout.java

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