• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ForceItem类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中prefuse.util.force.ForceItem的典型用法代码示例。如果您正苦于以下问题:Java ForceItem类的具体用法?Java ForceItem怎么用?Java ForceItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

ForceItem类属于prefuse.util.force包,在下文中一共展示了ForceItem类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: reset

点赞 2

import prefuse.util.force.ForceItem; //导入依赖的package包/类
/**
 * Reset the force simulation state for all nodes processed
 * by this layout.
 */
public void reset() {
    Iterator iter = m_vis.visibleItems(m_nodeGroup);
    while ( iter.hasNext() ) {
        VisualItem item = (VisualItem)iter.next();
        ForceItem fitem = (ForceItem)item.get(FORCEITEM);
        if ( fitem != null ) {
            fitem.location[0] = (float)item.getEndX();
            fitem.location[1] = (float)item.getEndY();
            fitem.force[0]    = fitem.force[1]    = 0;
            fitem.velocity[0] = fitem.velocity[1] = 0;
        }
    }
    m_lasttime = -1L;
}
 

开发者ID:luox12,
项目名称:onecmdb,
代码行数:19,
代码来源:ForceDirectedLayout.java

示例2: initSimulator

点赞 2

import prefuse.util.force.ForceItem; //导入依赖的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

示例3: reset

点赞 2

import prefuse.util.force.ForceItem; //导入依赖的package包/类
/**
 * Reset the force simulation state for all nodes processed
 * by this layout.
 */
public void reset() {
	Iterator<?> iter = m_vis.visibleItems(m_nodeGroup);
	while ( iter.hasNext() ) {
		VisualItem item = (VisualItem)iter.next();
		ForceItem fitem = (ForceItem)item.get(FORCEITEM);
		if ( fitem != null ) {
			fitem.location[0] = (float)item.getEndX();
			fitem.location[1] = (float)item.getEndY();
			fitem.force[0]    = fitem.force[1]    = 0;
			fitem.velocity[0] = fitem.velocity[1] = 0;
		}
	}
	m_lasttime = -1L;
}
 

开发者ID:codydunne,
项目名称:netgrok,
代码行数:19,
代码来源:PolarDonutFDRLayout.java

示例4: updateNodePositions

点赞 2

import prefuse.util.force.ForceItem; //导入依赖的package包/类
private void updateNodePositions() {
    Rectangle2D bounds = getLayoutBounds();
    double x1=0, x2=0, y1=0, y2=0;
    if ( bounds != null ) {
        x1 = bounds.getMinX(); y1 = bounds.getMinY();
        x2 = bounds.getMaxX(); y2 = bounds.getMaxY();
    }
    
    // update positions
    Iterator iter = m_vis.visibleItems(m_nodeGroup);
    while ( iter.hasNext() ) {
        VisualItem item = (VisualItem)iter.next();
        ForceItem fitem = (ForceItem)item.get(FORCEITEM);
        
        if ( item.isFixed() ) {
            // clear any force computations
            fitem.force[0] = 0.0f;
            fitem.force[1] = 0.0f;
            fitem.velocity[0] = 0.0f;
            fitem.velocity[1] = 0.0f;
            
            if ( Double.isNaN(item.getX()) ) {
                setX(item, referrer, 0.0);
                setY(item, referrer, 0.0);
            }
            continue;
        }
        
        double x = fitem.location[0];
        double y = fitem.location[1];
        
        if ( m_enforceBounds && bounds != null) {
            Rectangle2D b = item.getBounds();
            double hw = b.getWidth()/2;
            double hh = b.getHeight()/2;
            if ( x+hw > x2 ) x = x2-hw;
            if ( x-hw < x1 ) x = x1+hw;
            if ( y+hh > y2 ) y = y2-hh;
            if ( y-hh < y1 ) y = y1+hh;
        }
        
        // set the actual position
        setX(item, referrer, x);
        setY(item, referrer, y);
    }
}
 

开发者ID:luox12,
项目名称:onecmdb,
代码行数:47,
代码来源:ForceDirectedLayout.java

示例5: updateNodePositions

点赞 2

import prefuse.util.force.ForceItem; //导入依赖的package包/类
private void updateNodePositions() {
	Rectangle2D bounds = getLayoutBounds();
	double x1=0, x2=0, y1=0, y2=0;
	if ( bounds != null ) {
		x1 = bounds.getMinX(); y1 = bounds.getMinY();
		x2 = bounds.getMaxX(); y2 = bounds.getMaxY();
	}

	// update positions
	
	TupleSet ts = m_vis.getGroup(m_nodeGroup);
	
	Iterator<?> iter;

	if (m_filter == null)
		iter = ts.tuples();
	else 
		iter = ts.tuples(m_filter);
	
	while ( iter.hasNext() ) {

		VisualItem item = (VisualItem)iter.next();
		ForceItem fitem = (ForceItem)item.get(FORCEITEM);

		if ( item.isFixed() ) {
			// clear any force computations
			fitem.force[0] = 0.0f;
			fitem.force[1] = 0.0f;
			fitem.velocity[0] = 0.0f;
			fitem.velocity[1] = 0.0f;

			if ( Double.isNaN(item.getX()) ) {
				setX(item, referrer, 0.0);
				setY(item, referrer, 0.0);
			}
			continue;
		}

		double x = fitem.location[0];
		double y = fitem.location[1];

		if ( m_enforceBounds && bounds != null) {
			Rectangle2D b = item.getBounds();
			double hw = b.getWidth()/2;
			double hh = b.getHeight()/2;
			if ( x+hw > x2 ) x = x2-hw;
			if ( x-hw < x1 ) x = x1+hw;
			if ( y+hh > y2 ) y = y2-hh;
			if ( y-hh < y1 ) y = y1+hh;
		}

		// set the actual position
		setX(item, referrer, x);
		setY(item, referrer, y);
	}
}
 

开发者ID:codydunne,
项目名称:netgrok,
代码行数:57,
代码来源:PolarDonutFDRLayout.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)