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


Java PNode.getChildrenCount方法代码示例

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


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

示例1: updateNumberOfMoleculeNodes

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void updateNumberOfMoleculeNodes( PNode parent, int count, double diameter, float transparency, Color color ) {

        // remove nodes
        while ( count < parent.getChildrenCount() && count >= 0 ) {
            parent.removeChild( parent.getChildrenCount() - 1 );
        }

        // add nodes
        while ( count > parent.getChildrenCount() ) {
            DotNode node = new DotNode( diameter, color, transparency );
            Point2D p = getRandomPoint();
            double x = p.getX() - ( node.getFullBoundsReference().getWidth() / 2 );
            double y = p.getY() - ( node.getFullBoundsReference().getHeight() / 2 );
            node.setOffset( x, y );
            parent.addChild( node );
        }
        
        assert( count == parent.getChildrenCount() );
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:DotsNode.java

示例2: updateNumberOfMoleculeNodes

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void updateNumberOfMoleculeNodes( PNode parent, int count, double scale, float transparency, Image image ) {

        // remove nodes
        while ( count < parent.getChildrenCount() && count >= 0 ) {
            parent.removeChild( parent.getChildrenCount() - 1 );
        }

        // add nodes
        while ( count > parent.getChildrenCount() ) {
            ImageNode node = new ImageNode( image, scale, transparency );
            Point2D p = getRandomPoint();
            double x = p.getX() - ( node.getFullBoundsReference().getWidth() / 2 );
            double y = p.getY() - ( node.getFullBoundsReference().getHeight() / 2 );
            node.setOffset( x, y );
            parent.addChild( node );
        }

        assert( count == parent.getChildrenCount() );
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:ImagesNode.java

示例3: updateMoleculeNodes

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void updateMoleculeNodes( PNode parent, Molecule molecule, int count ) {

        // remove nodes
        while ( count < parent.getChildrenCount() && count >= 0 ) {
            parent.removeChild( parent.getChildrenCount() - 1 );
        }

        // add nodes
        while ( count > parent.getChildrenCount() ) {
            // create node
            PImage node = new PImage( molecule.getImage() );
            node.setScale( MOLECULE_IMAGE_SCALE );
            parent.addChild( node );
            // move to a random location
            Point2D p = getRandomPoint();
            double x = p.getX() - ( node.getFullBoundsReference().getWidth() / 2 );
            double y = p.getY() - ( node.getFullBoundsReference().getHeight() / 2 );
            node.setOffset( x, y );
        }

        assert( count == parent.getChildrenCount() );
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:23,代码来源:MoleculesNode.java

示例4: PreviewMoleculesCanvas

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Constructor that displays any set of molecules.
 * Molecules are displayed in an grid, in row-major order.
 * Canvas is automatically sized so that all nodes are visible.
 *
 * @param parentFrame color chooser dialog will be parented to this frame
 * @param background  background color of the canvas
 * @param columns     number of columns in the grid
 * @param xSpacing    horizontal spacing between molecules
 * @param ySpacing    vertical spacing between molecules
 * @param margin      margin around the edge of the play area
 * @param molecules   molecules to display
 */
public PreviewMoleculesCanvas( Frame parentFrame, Color background, int columns, int xSpacing, int ySpacing, int margin, Molecule[] molecules ) {
    super();
    setBackground( background );

    // parent node of all molecule nodes
    PNode parent = new PNode();
    addWorldChild( parent );

    // molecule nodes
    for ( Molecule molecule : molecules ) {
        parent.addChild( new LabeledMoleculeNode( molecule ) );
    }

    // control for changing canvas color
    PSwing colorControl = new PSwing( new CanvasColorControl( parentFrame, this ) );
    addWorldChild( colorControl );

    // layout
    for ( int i = 0; i < parent.getChildrenCount(); i++ ) {
        PNode child = parent.getChild( i );
        double x = margin + ( ( i % columns ) ) * xSpacing;
        double y = margin + ( ( i / columns ) ) * ySpacing;
        child.setOffset( x, y );
    }
    colorControl.setOffset( margin, parent.getFullBoundsReference().getMaxY() + 10 );

    // compute preferred size
    int width = (int) parent.getFullBoundsReference().getMaxX() + margin;
    int height = (int) colorControl.getFullBoundsReference().getMaxY() + margin;
    setPreferredSize( new Dimension( width, height ) );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:45,代码来源:PreviewMoleculesCanvas.java

示例5: centerItems

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void centerItems() {
    for ( int i = 0; i < panels.size(); i++ ) {
        PNode pNode = (PNode) panels.get( i );
        for ( int k = 0; k < pNode.getChildrenCount(); k++ ) {
            PNode child = pNode.getChild( k );
            if ( child instanceof DefaultDragNode ) {
                child.setOffset( getMaxPanelWidth() / 2 - child.getFullBounds().getWidth() / 2, child.getOffset().getY() );
            }
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:12,代码来源:CalorieDragStrip.java

示例6: removeLineNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private static void removeLineNode( Line line, PNode parent ) {
    for ( int i = 0; i < parent.getChildrenCount(); i++ ) {
        PNode node = parent.getChild( i );
        if ( node instanceof LineNode ) {
            LineNode lineNode = (LineNode) node;
            if ( lineNode.line == line ) {
                parent.removeChild( node );
                break;
            }
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:LineFormsGraphNode.java

示例7: compare

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public int compare( final PNode node1, final PNode node2 ) {
    final int count1 = node1.getChildrenCount();
    final int count2 = node2.getChildrenCount();
    if ( count1 > count2 ) {
        return 1;
    }
    else if ( count1 < count2 ) {
        return -1;
    }
    else {
        return 0;
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:14,代码来源:IMoleculeLayeringStrategy.java

示例8: updateDiameter

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private static void updateDiameter( PNode parent, double diameter ) {
    for ( int i = 0; i < parent.getChildrenCount(); i++ ) {
        PNode child = parent.getChild( i );
        if ( child instanceof DotNode ) {
            ( (DotNode) child ).setDiameter( diameter );
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:DotsNode.java

示例9: updateTransparency

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
protected void updateTransparency( PNode parent, float transparency ) {
    for ( int i = 0; i < parent.getChildrenCount(); i++ ) {
        PNode child = parent.getChild( i );
        if ( child instanceof DotNode ) {
            ( (DotNode) child ).setTransparency( transparency );
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:DotsNode.java

示例10: updateDotColor

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private static void updateDotColor( Color color, PNode parent ) {
    for ( int i = 0; i < parent.getChildrenCount(); i++ ) {
        PNode child = parent.getChild( i );
        if ( child instanceof DotNode ) {
            ( (DotNode) child ).setPaint( color );
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:DotsNode.java

示例11: updateScale

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private static void updateScale( PNode parent, double scale ) {
    for ( int i = 0; i < parent.getChildrenCount(); i++ ) {
        PNode child = parent.getChild( i );
        if ( child instanceof ImageNode ) {
            ( (ImageNode) child ).setScale( scale );
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:ImagesNode.java

示例12: updateTransparency

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
protected void updateTransparency( PNode parent, float transparency ) {
    for ( int i = 0; i < parent.getChildrenCount(); i++ ) {
        PNode child = parent.getChild( i );
        if ( child instanceof ImageNode ) {
            ( (ImageNode) child ).setTransparency( transparency );
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:ImagesNode.java

示例13: transparifySwing

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Make it so you can see through all the swing components, so the panel background color shows through.
 *
 * @param node
 */
private void transparifySwing( PNode node ) {
    for ( int i = 0; i < node.getChildrenCount(); i++ ) {
        PNode child = node.getChild( i );
        if ( child instanceof PSwing ) {
            SwingUtils.setBackgroundDeep( ( (PSwing) child ).getComponent(), new Color( 0, 0, 0, 0 ),
                                          new Class[] { JTextComponent.class,
                                                  JComboBox.class//have to ignore this one or the drop down button color changes (usually for the worse)
                                          }, false );
        }
        transparifySwing( child );
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:18,代码来源:ControlPanelNode.java

示例14: PeriodicTableNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Creates a new periodic table node with the specified background color and cell factory
 *
 * @param backgroundColor color to use for the background for each cell in the periodic table, may be different if highlighted
 * @param cellFactory     for creating cells to add as Piccolo nodes to show in the periodic table
 */
public PeriodicTableNode( Color backgroundColor, CellFactory cellFactory ) {

    //See http://www.ptable.com/
    final PNode table = new PNode();
    for ( int i = 1; i <= 56; i++ ) {
        addElement( table, i, cellFactory, backgroundColor );
    }
    // Add in a single entry to represent the lanthanide series.
    addElement( table, 57, cellFactory, backgroundColor );
    for ( int i = 72; i <= 88; i++ ) {
        addElement( table, i, cellFactory, backgroundColor );
    }
    // Add in a single entry to represent the actinide series.
    addElement( table, 89, cellFactory, backgroundColor );
    for ( int i = 104; i <= 112; i++ ) {
        addElement( table, i, cellFactory, backgroundColor );
    }

    //Notify the cells that the rest of the table is complete.  This is so they highlighted or larger cells can move in front if necessary, to prevent clipping
    for ( int i = 0; i < table.getChildrenCount(); i++ ) {
        PNode child = table.getChild( i );
        if ( child instanceof ElementCell ) {
            ( (ElementCell) child ).tableInitComplete();
        }
    }
    addChild( table );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:34,代码来源:PeriodicTableNode.java

示例15: update

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void update( PNode node ) {
    if ( node instanceof Updatable ) {
        Updatable updatable = (Updatable) node;
        updatable.update();
    }

    for ( int i = 0; i < node.getChildrenCount(); i++ ) {
        update( node.getChild( i ) );
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:11,代码来源:PhetPCanvas.java


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