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


Java PNode.getParent方法代码示例

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


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

示例1: listenForCanvas

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Attaches a listener to the specified node and all its parents to listen
 * for a change in the PSwingCanvas. Only PROPERTY_PARENT listeners are
 * added so this code wouldn't handle if a PLayer were viewed by a different
 * PCamera since that constitutes a child change.
 * 
 * @param node The child node at which to begin a parent-based traversal for
 *            adding listeners.
 */
private void listenForCanvas(final PNode node) {
    // need to get the full tree for this node
    PNode p = node;
    while (p != null) {
        listenToNode(p);

        final PNode parent = p;
        // System.out.println( "parent = " + parent.getClass() );
        if (parent instanceof PLayer) {
            final PLayer player = (PLayer) parent;
            // System.out.println( "Found player: with " +
            // player.getCameraCount() + " cameras" );
            for (int i = 0; i < player.getCameraCount(); i++) {
                final PCamera cam = player.getCamera(i);
                if (cam.getComponent() instanceof PSwingCanvas) {
                    updateCanvas((PSwingCanvas) cam.getComponent());
                    break;
                }
            }
        }
        p = p.getParent();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:33,代码来源:PSwing.java

示例2: hasCanvasAsParent

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Walk up the scene graph, looking to see if we are a (grand)child of a canvas
 *
 * @return If an ancestor is a BuildAMoleculeCanvas
 */
private boolean hasCanvasAsParent() {
    PNode node = this;
    while ( node.getParent() != null ) {
        node = node.getParent();
        if ( node instanceof PhetRootPNode ) {
            return true;
        }
    }
    return false;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:16,代码来源:CollectionPanel.java

示例3: getRampWorld

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private RampWorld getRampWorld() {
    PNode parent = getParent();
    while ( parent != null ) {
        if ( parent instanceof RampWorld ) {
            return (RampWorld) parent;
        }
        parent = parent.getParent();
    }
    return null;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:11,代码来源:ForceArrowGraphic.java

示例4: setChild

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void setChild( PNode node, boolean visible ) {
    if ( container == null ) {
        return;
    }
    if ( visible && node.getParent() == null ) {
        container.addChild( node );
    }
    if ( !visible && node.getParent() != null ) {
        container.removeChild( node );
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:12,代码来源:TectonicsTimeControl.java

示例5: propertyChange

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public void propertyChange( PropertyChangeEvent evt ) {
    PNode parent = jFreeChartNode.getParent();
    while ( parent != null ) {
        parent.removePropertyChangeListener( PNode.PROPERTY_TRANSFORM, updater );
        parent.removePropertyChangeListener( PNode.PROPERTY_PARENT, updateParent );
        parent.addPropertyChangeListener( PNode.PROPERTY_TRANSFORM, updater );
        parent.addPropertyChangeListener( PNode.PROPERTY_PARENT, updateParent );
        parent = parent.getParent();
        update();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:12,代码来源:JFreeChartCursorNode.java

示例6: isNodeVisible

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Determines if a node is visible.
 * A node is visible if it and and all of its ancestors is visible.
 *
 * @param node
 * @return true or value
 */
public static boolean isNodeVisible( final PNode node ) {
    boolean visible = node.getVisible();
    PNode aNode = node;
    while ( visible && aNode != null ) {
        aNode = aNode.getParent();
        if ( aNode != null ) {
            visible = aNode.getVisible();
        }
    }
    return visible;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:AbstractHelpItem.java

示例7: updateWatchList

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void updateWatchList() {
    clearWatchList();
    PNode node = _pswing;
    while ( node != null ) {
        node.addPropertyChangeListener( this );
        _watchList.add( node );
        node = node.getParent();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:AbstractHelpItem.java

示例8: descendsFromLayer

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Returns true if the provided layer has a PLayer ancestor.
 * 
 * @param node node being tested
 * 
 * @return true if node is a descendant of a PLayer
 */
private boolean descendsFromLayer(final PNode node) {
    PNode searchNode = node;
    while (searchNode != null) {
        searchNode = searchNode.getParent();
        if (searchNode instanceof PLayer) {
            return true;
        }
    }
    return false;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:18,代码来源:PSwingEventHandler.java

示例9: 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));
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:40,代码来源:POcclusionDetection.java

示例10: addChild

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Adds a child to the end of the node list.
 * 
 * @param child child to be added
 * @param constraints constraints the layout manager uses when laying out
 *            the child
 * @param anchor specifies the location from which layout takes place
 */
public void addChild(final PNode child, final Object constraints, final Anchor anchor) {
    // NOTE: since PNode.addChild(PNode) is implemented in terms of
    // PNode.addChild(int index), we must do the same.
    int index = getChildrenCount();
    // workaround a flaw in PNode.addChild(PNode), they should have handled
    // this in PNode.addChild(int index).
    if (child.getParent() == this) {
        index--;
    }
    addChild(index, child, constraints, anchor);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:SwingLayoutNode.java

示例11: EnergySkateParkModule

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public EnergySkateParkModule( IUserComponent userComponent, String name, PhetFrame phetFrame, EnergySkateParkOptions options, boolean limitNumberOfTracks, boolean useTimeSlider ) {
    super( userComponent, name, phetFrame, options, true, true, Floor.DEFAULT_FRICTION, true /* hasZoomControls */, 1.0, limitNumberOfTracks, useTimeSlider );

    energySkateParkControlPanel = new EnergySkateParkControlPanel( this );
    setControlPanel( energySkateParkControlPanel );

    final HelpBalloon trackHelp = new HelpBalloon( getDefaultHelpPane(), EnergySkateParkResources.getString( "help.grab-a-track" ), HelpBalloon.TOP_CENTER, 20 );
    getDefaultHelpPane().add( trackHelp );
    trackHelp.pointAt( energySkateParkSimulationPanel.getRootNode().getSplineToolbox(), energySkateParkSimulationPanel );

    final HelpBalloon skateHelp = new HelpBalloon( getDefaultHelpPane(), EnergySkateParkResources.getString( "help.drag-the-skater" ), HelpBalloon.RIGHT_CENTER, 20 ) {
        public Point2D mapLocation( PNode node, PCanvas canvas ) {
            if ( node == null || node.getParent() == null ) {
                return new Point2D.Double( 0, 0 );
            }
            else {
                return super.mapLocation( node, canvas );
            }
        }
    };
    getDefaultHelpPane().add( skateHelp );
    skateHelp.pointAt( energySkateParkSimulationPanel.getRootNode().getSkaterNode( 0 ), energySkateParkSimulationPanel );
    energyModel.addEnergyModelListener( new EnergySkateParkModel.EnergyModelListenerAdapter() {
        public void bodyCountChanged() {
            if ( energySkateParkSimulationPanel.getRootNode().numBodyGraphics() > 0 ) {
                skateHelp.pointAt( energySkateParkSimulationPanel.getRootNode().getSkaterNode( 0 ), energySkateParkSimulationPanel );
            }
        }
    } );

    final HelpBalloon trackClickHelp = new HelpBalloon( getDefaultHelpPane(), EnergySkateParkResources.getString( "help.right-click-for-options" ), HelpBalloon.BOTTOM_CENTER, 20 );
    getDefaultHelpPane().add( trackClickHelp );
    trackClickHelp.pointAt( 0, 0 );

    energyModel.addEnergyModelListener( new EnergySkateParkModel.EnergyModelListenerAdapter() {
        public void preStep() {//todo: won't update while paused
            if ( energyModel.getNumSplines() > 0 && isHelpEnabled() ) {
                trackHelp.setVisible( isHelpEnabled() );
                SerializablePoint2D pt = energyModel.getSpline( 0 ).getParametricFunction2D().evaluate( 0.25 );
                Point2D w = new Point2D.Double( pt.getX(), pt.getY() );
                energySkateParkSimulationPanel.getRootNode().worldToScreen( w );
                trackClickHelp.pointAt( w );
            }
            else {
                trackHelp.setVisible( false );
            }
        }
    } );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:50,代码来源:EnergySkateParkModule.java


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