本文整理汇总了Java中edu.umd.cs.piccolo.PNode.getChild方法的典型用法代码示例。如果您正苦于以下问题:Java PNode.getChild方法的具体用法?Java PNode.getChild怎么用?Java PNode.getChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.piccolo.PNode
的用法示例。
在下文中一共展示了PNode.getChild方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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 ) );
}
示例2: 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() );
}
}
}
}
示例3: 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;
}
}
}
}
示例4: 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 );
}
}
}
示例5: 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 );
}
}
}
示例6: 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 );
}
}
}
示例7: 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 );
}
}
}
示例8: 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 );
}
}
}
示例9: 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 );
}
}
示例10: 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 );
}
示例11: detectOcclusions
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
* Traverse the pick path determining which parent nodes are occluded by
* their children nodes. Note that this is only detecting a subset of
* occlusions (parent, child), others such as overlapping siblings or
* cousins are not detected.
*
* @param node node from which to detect occlusions
* @param pickPath Pick Path to traverse
*/
public void detectOcclusions(final PNode node, final PPickPath pickPath) {
if (!node.fullIntersects(pickPath.getPickBounds())) {
return;
}
pickPath.pushTransform(node.getTransformReference(false));
final int count = node.getChildrenCount();
for (int i = count - 1; i >= 0; i--) {
final PNode each = node.getChild(i);
if (node.getOccluded()) {
// if n has been occluded by a previous descendant then
// this child must also be occluded
each.setOccluded(true);
}
else {
// see if child each occludes n
detectOcclusions(each, pickPath);
}
}
if (nodeOccludesParents(node, pickPath)) {
final PNode parent = node.getParent();
while (parent != null && !parent.getOccluded()) {
parent.setOccluded(true);
}
}
pickPath.popTransform(node.getTransformReference(false));
}