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


Java NodeItem.get方法代码示例

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


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

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

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

示例3: initSimulator

import prefuse.visual.NodeItem; //导入方法依赖的package包/类
/**
 * Loads the simulator with all relevant force items and springs.
 * @param fsim the force simulator driving this layout
 */
protected void initSimulator(ForceSimulator fsim) {     
    // make sure we have force items to work with
    TupleSet ts = m_vis.getGroup(m_nodeGroup);
    if ( ts == null ) return;
    try {
        ts.addColumns(FORCEITEM_SCHEMA);
    } catch ( IllegalArgumentException iae ) { /* ignored */ }
    
    float startX = (referrer == null ? 0f : (float)referrer.getX());
    float startY = (referrer == null ? 0f : (float)referrer.getY());
    startX = Float.isNaN(startX) ? 0f : startX;
    startY = Float.isNaN(startY) ? 0f : startY;
   
    Iterator iter = m_vis.visibleItems(m_nodeGroup);
    while ( iter.hasNext() ) {
        VisualItem item = (VisualItem)iter.next();
        ForceItem fitem = (ForceItem)item.get(FORCEITEM);
        fitem.mass = getMassValue(item);
        double x = item.getEndX();
        double y = item.getEndY();
        fitem.location[0] = (Double.isNaN(x) ? startX : (float)x);
        fitem.location[1] = (Double.isNaN(y) ? startY : (float)y);
        fsim.addItem(fitem);
    }
    if ( m_edgeGroup != null ) {
        iter = m_vis.visibleItems(m_edgeGroup);
        while ( iter.hasNext() ) {
            EdgeItem  e  = (EdgeItem)iter.next();
            NodeItem  n1 = e.getSourceItem();
            ForceItem f1 = (ForceItem)n1.get(FORCEITEM);
            NodeItem  n2 = e.getTargetItem();
            ForceItem f2 = (ForceItem)n2.get(FORCEITEM);
            float coeff = getSpringCoefficient(e);
            float slen = getSpringLength(e);
            fsim.addSpring(f1, f2, (coeff>=0?coeff:-1.f), (slen>=0?slen:-1.f));
        }
    }
}
 
开发者ID:luox12,项目名称:onecmdb,代码行数:43,代码来源:ForceDirectedLayout.java

示例4: getParams

import prefuse.visual.NodeItem; //导入方法依赖的package包/类
private Params getParams(NodeItem item) {
    Params rp = (Params)item.get(PARAMS);
    if ( rp == null ) {
        rp = new Params();
        item.set(PARAMS, rp);
    }
    if ( rp.number == -2 ) {
        rp.init(item);
    }
    return rp;
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:12,代码来源:NodeLinkTreeLayout.java

示例5: getParams

import prefuse.visual.NodeItem; //导入方法依赖的package包/类
private Params getParams(NodeItem n) {
    Params np = (Params)n.get(PARAMS);
    if ( np == null ) {
        np = new Params();
        n.set(PARAMS, np);
    }
    return np;
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:9,代码来源:BalloonTreeLayout.java

示例6: run

import prefuse.visual.NodeItem; //导入方法依赖的package包/类
/**
    * @see prefuse.action.Action#run(double)
    */
   public void run(double frac) {
       Graph g = (Graph)m_vis.getGroup(m_group);
       initSchema(g.getNodes());
       
       m_origin = getLayoutAnchor();
       NodeItem n = getLayoutRoot();
       Params np = (Params)n.get(PARAMS);

g.getSpanningTree(n);
       
       // calc relative widths and maximum tree depth
       // performs one pass over the tree
       m_maxDepth = 0;
       calcAngularWidth(n, 0);
       
       if ( m_autoScale ) setScale(getLayoutBounds());
       if ( !m_setTheta ) calcAngularBounds(n);
               
       // perform the layout
       if ( m_maxDepth > 0 )
           layout(n, m_radiusInc, m_theta1, m_theta2);
       
       // update properties of the root node
       setX(n, null, m_origin.getX());
       setY(n, null, m_origin.getY());
       np.angle = m_theta2-m_theta1;
   }
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:31,代码来源:RadialTreeLayout.java

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

示例8: setSelectedValue

import prefuse.visual.NodeItem; //导入方法依赖的package包/类
@Override
public void setSelectedValue( Object object )
{
    if( object == null )
    {
        return;
    }

    NodeItem item = null;

    Iterator iter = m_vis.items( GRAPH_NODES );
    while( iter.hasNext() )
    {
        NodeItem tItem = (NodeItem) iter.next();
        Object tObj = tItem.get( USER_OBJECT );
        if( tObj.equals( object ) )
        {
            item = tItem;
            break;
        }
    }

    if( item != null )
    {
        int depth = item.getDepth();
        boolean relayout = false;
        if( depth > stackedLayout.getZoom() )
        {
            stackedLayout.zoom( depth );
            relayout = true;
        }

        TupleSet ts = m_vis.getFocusGroup( Visualization.FOCUS_ITEMS );
        ts.setTuple( item );
        if( relayout )
        {
            run();
        }
        else
        {
            m_vis.run( AUTO_PAN_ACTION );
        }
    }
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:45,代码来源:StackedGraphDisplay.java

示例9: initSimulator

import prefuse.visual.NodeItem; //导入方法依赖的package包/类
protected void initSimulator(ForceSimulator fsim) {	 
	// make sure we have force items to work with
	TupleSet ts = m_vis.getGroup(m_nodeGroup);
	if ( ts == null ) return;
	try {
		ts.addColumns(FORCEITEM_SCHEMA);
	} catch ( IllegalArgumentException iae ) { /* ignored */ }
	
	float startX = (referrer == null ? 0f : (float)referrer.getX());
	float startY = (referrer == null ? 0f : (float)referrer.getY());
	startX = Float.isNaN(startX) ? 0f : startX;
	startY = Float.isNaN(startY) ? 0f : startY;
	
	ArrayList<EdgeItem> edges = new ArrayList<EdgeItem>();
	
	Iterator<?> iter = m_vis.items(m_nodeGroup, m_filter);
	while ( iter.hasNext() ) {
		NodeItem item = (NodeItem)iter.next();
		ForceItem fitem = (ForceItem)item.get(FORCEITEM);
		fitem.mass = getMassValue(item);
		double x = item.getEndX();
		double y = item.getEndY();
		fitem.location[0] = (Double.isNaN(x) ? startX : (float)x);
		fitem.location[1] = (Double.isNaN(y) ? startY : (float)y);
		fsim.addItem(fitem);
		
		for (Iterator<?> it=item.outEdges(); it.hasNext();) {
			EdgeItem edge = (EdgeItem) it.next();
			NodeItem adjacent = edge.getAdjacentItem(item);
			
			if (adjacent.getBoolean("is_local"))
				edges.add(edge);
		}
	}

	iter = edges.iterator();
	while ( iter.hasNext() ) {
		EdgeItem  e  = (EdgeItem)iter.next();
		NodeItem  n1 = e.getSourceItem();
		ForceItem f1 = (ForceItem)n1.get(FORCEITEM);
		NodeItem  n2 = e.getTargetItem();
		ForceItem f2 = (ForceItem)n2.get(FORCEITEM);
		float coeff = getSpringCoefficient(e);
		float slen = getSpringLength(e);
		fsim.addSpring(f1, f2, (coeff>=0?coeff:-1.f), (slen>=0?slen:-1.f));
	}
}
 
开发者ID:codydunne,项目名称:netgrok,代码行数:48,代码来源:LocalHostLayout.java


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