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


Java NodeItem类代码示例

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


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

示例1: itemDragged

import prefuse.visual.NodeItem; //导入依赖的package包/类
/**
 * @see Control#itemDragged(VisualItem, MouseEvent)
 */
public void itemDragged( VisualItem item, MouseEvent e )
{
	if ( !UILib.isButtonPressed( e, button ) )
		return;
	if ( !( item instanceof NodeItem ) )
		return;

	Display d = (Display)e.getComponent();
	tmp = d.getAbsoluteCoordinate( e.getPoint(), tmp );
	double dx = tmp.getX() - down.getX();
	double dy = tmp.getY() - down.getY();

	updateLocations( (NodeItem)item, dx, dy );

	down.setLocation( tmp );
	item.getVisualization().repaint();
}
 
开发者ID:kartoFlane,项目名称:hiervis,代码行数:21,代码来源:SubtreeDragControl.java

示例2: updateLocations

import prefuse.visual.NodeItem; //导入依赖的package包/类
private void updateLocations( NodeItem n, double dx, double dy )
{
	double x = n.getX(), y = n.getY();
	n.setStartX( x );
	n.setStartY( y );
	x += dx;
	y += dy;
	n.setX( x );
	n.setY( y );
	n.setEndX( x );
	n.setEndY( y );

	Iterator<?> children = n.children();
	while ( children.hasNext() ) {
		updateLocations( (NodeItem)children.next(), dx, dy );
	}
}
 
开发者ID:kartoFlane,项目名称:hiervis,代码行数:18,代码来源:SubtreeDragControl.java

示例3: getColor

import prefuse.visual.NodeItem; //导入依赖的package包/类
@Override
public int getColor( VisualItem item )
{
    if( item instanceof NodeItem )
    {
        NodeItem nItem = (NodeItem) item;
        if( m_vis.isInGroup( nItem, Visualization.FOCUS_ITEMS ) )
        {
            int c = CMAP.getColor( nItem.getDepth() );
            return ColorLib.darker( c );
        }
        return CMAP.getColor( nItem.getDepth() );
    }
    else
    {
        return CMAP.getColor( 0 );
    }
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:19,代码来源:StackedGraphDisplay.java

示例4: run

import prefuse.visual.NodeItem; //导入依赖的package包/类
@Override
public void run( double frac )
{
    // setup
    NodeItem root = getLayoutRoot();
    layout( root, 0, 0 );

    Rectangle2D bounds = root.getBounds();
    Display display = this.getVisualization().getDisplay( 0 );
    Dimension size = new Dimension( (int) bounds.getWidth(), (int) bounds.getHeight() );
    display.setSize( size );

    if( !display.isValid() )
    {
        display.validate();
    }
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:18,代码来源:StackedLayout.java

示例5: handleAggregate

import prefuse.visual.NodeItem; //导入依赖的package包/类
public static void handleAggregate(Visualization vis, int id, String nodeType, String edgeType, boolean enable) {
	
	AggregateTable at = (AggregateTable) vis.getGroup("aggregates");
	
	System.out.println("Aggregate: " + nodeType + ":" + enable);
	
	Iterator iter = vis.items(new FieldMatchGroupPredicate("graph.nodes", "type", nodeType));
	while(iter.hasNext()) {
		VisualItem item = (VisualItem) iter.next();
		Iterator aggregates = at.getAggregates(item);
		if (!aggregates.hasNext()) {
			addAggregate(id, (NodeItem)item, (AggregateItem) at.addItem(), enable);
		} else {
			while(aggregates.hasNext()) {
				addAggregate(id, (NodeItem)item, (AggregateItem) aggregates.next(), enable);
			}
		}
	}
}
 
开发者ID:luox12,项目名称:onecmdb,代码行数:20,代码来源:AggregateControl.java

示例6: run

import prefuse.visual.NodeItem; //导入依赖的package包/类
/**
 * @see prefuse.action.Action#run(double)
 */
public void run(double frac) {
    // setup
    NodeItem root = getLayoutRoot();
    Rectangle2D b = getLayoutBounds();
    m_r.setRect(b.getX(), b.getY(), b.getWidth()-1, b.getHeight()-1);
    
    // process size values
    computeAreas(root);
    // layout root node
    setX(root, null, 0);
    setY(root, null, 0);        
    root.setBounds(0, 0, m_r.getWidth(), m_r.getHeight());

    // layout the tree
    updateArea(root, m_r);
    layout(root, m_r);
}
 
开发者ID:codydunne,项目名称:netgrok,代码行数:21,代码来源:SquarifiedHostTreeMapLayout.java

示例7: updateLocations

import prefuse.visual.NodeItem; //导入依赖的package包/类
/**
     * @see prefuse.controls.Control#itemDragged(prefuse.visual.VisualItem, java.awt.event.MouseEvent)
     */
//    public void itemDragged(VisualItem item, MouseEvent e) {
//        if (!SwingUtilities.isLeftMouseButton(e)) return;
//        if ( !(item instanceof NodeItem) ) return;
//        PDisplay d = (PDisplay)e.getComponent();
//        tmp = d.getAbsoluteCoordinate(e.getPoint(), tmp);
//        double dx = tmp.getX()-down.getX();
//        double dy = tmp.getY()-down.getY();
//        updateLocations((NodeItem)item, dx, dy);
//        down.setLocation(tmp);
//        item.getVisualization().repaint();
//    }
    
    private void updateLocations(NodeItem n, double dx, double dy) {
        double x = n.getX(), y = n.getY();
        n.setStartX(x); n.setStartY(y);
        x += dx; y += dy;
        n.setX(x);    n.setY(y);
        n.setEndX(x); n.setEndY(y);

        Iterator children = n.children();
        while ( children.hasNext() )
            updateLocations((NodeItem)children.next(), dx, dy);
    }
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:27,代码来源:SubtreeDragControl.java

示例8: visitDescendants

import prefuse.visual.NodeItem; //导入依赖的package包/类
/**
 * Traverse tree descendents.
 */
private void visitDescendants(NodeItem p, NodeItem skip) {
    int lidx = ( skip == null ? 0 : p.getChildIndex(skip) );
    
    Iterator children = p.children();
    
    p.setExpanded(children.hasNext());
    
    for ( int i=0; children.hasNext(); ++i ) {
        NodeItem c = (NodeItem)children.next();
        if ( c == skip ) { continue; }             
        
        int doi = (int)(p.getDOI()-1);            
        visit(c, c, doi, Math.abs(lidx-i));      
        if ( doi > m_threshold )
            visitDescendants(c, null);   
    }
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:21,代码来源:FisheyeTreeFilter.java

示例9: 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());
       
       Arrays.fill(m_depths, 0);
       m_maxDepth = 0;
       
       Point2D a = getLayoutAnchor();
       m_ax = a.getX();
       m_ay = a.getY();
       
       NodeItem root = getLayoutRoot();
       Params rp = getParams(root);

g.getSpanningTree(root);
       
       // do first pass - compute breadth information, collect depth info
       firstWalk(root, 0, 1);
       
       // sum up the depth info
       determineDepths();
       
       // do second pass - assign layout positions
       secondWalk(root, null, -rp.prelim, 0);
   }
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:29,代码来源:NodeLinkTreeLayout.java

示例10: secondWalk

import prefuse.visual.NodeItem; //导入依赖的package包/类
private void secondWalk(NodeItem n, NodeItem p, double m, int depth) {
    Params np = getParams(n);
    setBreadth(n, p, np.prelim + m);
    setDepth(n, p, m_depths[depth]);
    
    if ( n.isExpanded() ) {
        depth += 1;
        for ( NodeItem c = (NodeItem)n.getFirstChild();
              c != null; c = (NodeItem)c.getNextSibling() )
        {
            secondWalk(c, n, m + np.mod, depth);
        }
    }
    
    np.clear();
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:17,代码来源:NodeLinkTreeLayout.java

示例11: setDepth

import prefuse.visual.NodeItem; //导入依赖的package包/类
private void setDepth(NodeItem n, NodeItem p, double d) {
    switch ( m_orientation ) {
    case Constants.ORIENT_LEFT_RIGHT:
        setX(n, p, m_ax + d);
        break;
    case Constants.ORIENT_RIGHT_LEFT:
        setX(n, p, m_ax - d);
        break;
    case Constants.ORIENT_TOP_BOTTOM:
        setY(n, p, m_ay + d);
        break;
    case Constants.ORIENT_BOTTOM_TOP:
        setY(n, p, m_ay - d);
        break;
    default:
        throw new IllegalStateException();
    }
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:19,代码来源:NodeLinkTreeLayout.java

示例12: run

import prefuse.visual.NodeItem; //导入依赖的package包/类
/**
 * @see prefuse.action.Action#run(double)
 */
public void run(double frac) {
    // setup
    NodeItem root = getLayoutRoot();
    Rectangle2D b = getLayoutBounds();
    m_r.setRect(b.getX(), b.getY(), b.getWidth()-1, b.getHeight()-1);
    
    // process size values
    computeAreas(root);
    
    // layout root node
    setX(root, null, 0);
    setY(root, null, 0);        
    root.setBounds(0, 0, m_r.getWidth(), m_r.getHeight());

    // layout the tree
    updateArea(root, m_r);
    layout(root, m_r);
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:22,代码来源:SquarifiedTreeMapLayout.java

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

示例14: init

import prefuse.visual.NodeItem; //导入依赖的package包/类
private void init(Graph g, Rectangle2D b) {
    initSchema(g.getNodes());
    
    temp = b.getWidth() / 10;
    forceConstant = 0.75 * 
        Math.sqrt(b.getHeight()*b.getWidth()/g.getNodeCount());
    
    // initialize node positions
    Iterator nodeIter = g.nodes();
    Random rand = new Random(42); // get a deterministic layout result
    double scaleW = ALPHA*b.getWidth()/2;
    double scaleH = ALPHA*b.getHeight()/2;
    while ( nodeIter.hasNext() ) {
        NodeItem n = (NodeItem)nodeIter.next();
        Params np = getParams(n);
        np.loc[0] = b.getCenterX() + rand.nextDouble()*scaleW;
        np.loc[1] = b.getCenterY() + rand.nextDouble()*scaleH;
    }
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:20,代码来源:FruchtermanReingoldLayout.java

示例15: calcAttraction

import prefuse.visual.NodeItem; //导入依赖的package包/类
public void calcAttraction(EdgeItem e) {
    NodeItem n1 = e.getSourceItem();
    Params n1p = getParams(n1);
    NodeItem n2 = e.getTargetItem();
    Params n2p = getParams(n2);
    
    double xDelta = n1p.loc[0] - n2p.loc[0];
    double yDelta = n1p.loc[1] - n2p.loc[1];

    double deltaLength = Math.max(EPSILON, 
            Math.sqrt(xDelta*xDelta + yDelta*yDelta));
    double force = (deltaLength*deltaLength) / forceConstant;

    if (Double.isNaN(force)) {
        System.err.println("Mathematical error...");
    }

    double xDisp = (xDelta/deltaLength) * force;
    double yDisp = (yDelta/deltaLength) * force;
    
    n1p.disp[0] -= xDisp; n1p.disp[1] -= yDisp;
    n2p.disp[0] += xDisp; n2p.disp[1] += yDisp;
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:24,代码来源:FruchtermanReingoldLayout.java


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