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


Java NodeItem.getDouble方法代码示例

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


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

示例3: updateArea

import prefuse.visual.NodeItem; //导入方法依赖的package包/类
private void updateArea(NodeItem n, Rectangle2D r) {
    Rectangle2D b = n.getBounds();
    if ( m_frame == 0.0 ) {
        // if no framing, simply update bounding rectangle
        r.setRect(b);
        return;
    }
    
    // compute area loss due to frame
    double dA = 2*m_frame*(b.getWidth()+b.getHeight()-2*m_frame);
    double A = n.getDouble(AREA) - dA;
    
    // compute renormalization factor
    double s = 0;
    Iterator<NodeItem> childIter = n.children();
    while ( childIter.hasNext() )
        s += childIter.next().getDouble(AREA);
    double t = A/s;
    
    // re-normalize children areas
    childIter = n.children();
    while ( childIter.hasNext() ) {
        NodeItem c = childIter.next();
        c.setDouble(AREA, c.getDouble(AREA)*t);
    }
    
    // set bounding rectangle and return
    r.setRect(b.getX()+m_frame,       b.getY()+m_frame, 
              b.getWidth()-2*m_frame, b.getHeight()-2*m_frame);
    return;
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:32,代码来源:SquarifiedTreeMapLayout.java

示例4: squarify

import prefuse.visual.NodeItem; //导入方法依赖的package包/类
private void squarify(List<NodeItem> c, List<NodeItem> row, double w, Rectangle2D r) {
    double worst = Double.MAX_VALUE, nworst;
    int len;
    
    while ( (len=c.size()) > 0 ) {
        // add item to the row list, ignore if negative area
    	NodeItem item =  c.get(len-1);
        double a = item.getDouble(AREA);
        if (a <= 0.0) {
            c.remove(len-1);
            continue;
        }
        row.add(item);
        
        nworst = worst(row, w);
        if ( nworst <= worst ) {
            c.remove(len-1);
            worst = nworst;
        } else {
            row.remove(row.size()-1); // remove the latest addition
            r = layoutRow(row, w, r); // layout the current row
            w = Math.min(r.getWidth(),r.getHeight()); // recompute w
            row.clear(); // clear the row
            worst = Double.MAX_VALUE;
        }
    }
    if ( row.size() > 0 ) {
        r = layoutRow(row, w, r); // layout the current row
        row.clear(); // clear the row
    }
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:32,代码来源:SquarifiedTreeMapLayout.java

示例5: 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

示例6: compare

import prefuse.visual.NodeItem; //导入方法依赖的package包/类
public int compare(NodeItem o1, NodeItem o2) {
    double s1 = o1.getDouble(AREA);
    double s2 = o2.getDouble(AREA);
    return ( s1>s2 ? 1 : (s1<s2 ? -1 : 0));
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:6,代码来源:SquarifiedTreeMapLayout.java


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