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


Java PNode.getFullBounds方法代码示例

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


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

示例1: mapLocation

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Maps the location (upper-left corner) of a PNode on a specified PCanvas to
 * the coordinate system of the parent help pane.
 *
 * @param node
 * @param canvas
 * @return
 */
public Point2D mapLocation( PNode node, PCanvas canvas ) {
    // Determine the node's location in canvas coordinates...
    int x = 0;
    int y = 0;
    {
        // Get the node's full bounds (union of its bounds and all children) in parent node's local coordinates
        Rectangle2D fullBounds = node.getFullBounds();
        // Get the node's global bounds - above the root node's transform, but below the canvas's view transform.
        Rectangle2D globalFullBounds = node.getParent().localToGlobal( fullBounds );

        //TODO: perhaps this code should transform this.globalToLocal(globalFullBounds) to identify the correct location.
        // Apply the canvas' view transform to get bounds in the canvas' coordinate system.
        PCamera camera = canvas.getCamera();
        PAffineTransform transform = camera.getViewTransformReference();
        Rectangle2D bounds = transform.transform( globalFullBounds, null );
        x = (int) bounds.getX();
        y = (int) bounds.getY();
    }

    // Convert the canvas location to a location in the help pane.
    Point2D helpPanePoint = SwingUtilities.convertPoint( canvas, x, y, _helpPane );
    return helpPanePoint;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:32,代码来源:AbstractHelpItem.java

示例2: updateLayout

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void updateLayout() {
    //Find the size (width or height) of the biggest child node so far
    final PNode biggestNode = max( getChildren(), new Comparator<PNode>() {
        public int compare( PNode o1, PNode o2 ) {
            return Double.compare( getMaxDimension.apply( o1.getFullBounds() ), getMaxDimension.apply( o2.getFullBounds() ) );
        }
    } );
    final double maxSize = getMaxDimension.apply( biggestNode.getFullBounds() );

    //Position each child, adding space between it and the previous child.
    double position = 0; //X or Y coordinate, depending on implementation of getNodeDimension
    for ( PNode child : getChildren() ) {
        final PBounds bounds = child.getFullBounds();

        //Subtract out any local translation in the node
        double childOriginX = bounds.getX() - child.getOffset().getX();
        double childOriginY = bounds.getY() - child.getOffset().getY();

        //Determine where to put the node and do so
        Point2D relativePosition = positionStrategy.getRelativePosition( child, maxSize, position );
        child.setOffset( relativePosition.getX() - childOriginX, relativePosition.getY() - childOriginY );

        //Move the position accumulator to the next space for the next node
        position += getNodeDimension.apply( bounds ) + spacing;
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:27,代码来源:Box.java

示例3: BackgroundNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public BackgroundNode( PNode node ) {
    super();
    setPickable( false );
    final double m = BACKGROUND_MARGIN;
    final double r = BACKGROUND_CORNER_RADIUS;
    PBounds b = node.getFullBounds();
    setPathTo( new RoundRectangle2D.Double( b.getX() - m, b.getY() - m, b.getWidth() + ( 2 * m ), b.getHeight() + ( 2 * m ), r, r ) );
    setStroke( BACKGROUND_STROKE );
    setStrokePaint( BACKGROUND_STROKE_COLOR );
    setPaint( BACKGROUND_COLOR );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:12,代码来源:SolutionControlsNode.java

示例4: PNodeFacade

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public PNodeFacade( PNode target ) {
    addChild( target );
    target.setPickable( false );
    target.setChildrenPickable( false );
    PBounds bounds = target.getFullBounds();
    addChild( new PhetPPath( bounds, new Color( 0, 0, 0, 0 ) ) );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:SplineToolboxNode.java

示例5: mapLocation

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Maps to a point that allows us to point to the center of
 * one of the node's edges, instead of its upper-left corner.
 * Which edge is dependent on the arrow position.
 *
 * @param node
 * @param canvas
 */
public Point2D mapLocation( PNode node, PCanvas canvas ) {

    // Map the node's location (upper-left corner) to help pane coordinates...
    Point2D p = super.mapLocation( node, canvas );

    // Determine the node's dimensions, in help pane coordinates...
    Rectangle2D fullBounds = node.getFullBounds(); // in parent's local coordinates
    Rectangle2D globalFullBounds = node.getParent().localToGlobal( fullBounds );
    PCamera camera = canvas.getCamera();
    PAffineTransform transform = camera.getViewTransformReference();
    Rectangle2D bounds = transform.transform( globalFullBounds, null );
    double width = bounds.getWidth();
    double height = bounds.getHeight();

    // Translate the help pane coordinates, using the node's dimensions and arrow position...
    if ( isArrowOnTop() ) {
        p.setLocation( p.getX() + ( width / 2 ), p.getY() + height );
    }
    else if ( isArrowOnBottom() ) {
        p.setLocation( p.getX() + ( width / 2 ), p.getY() );
    }
    else if ( isArrowOnRight() ) {
        p.setLocation( p.getX(), p.getY() + ( height / 2 ) );
    }
    else {
        p.setLocation( p.getX() + width, p.getY() + ( height / 2 ) );
    }

    return p;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:39,代码来源:HelpBalloon.java

示例6: apply

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public Rectangle2D apply( PNode pNode ) {
    return pNode.getFullBounds();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:4,代码来源:SingleCollectionBoxNode.java

示例7: getControlPanelBounds

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
@Override protected PBounds getControlPanelBounds( PNode content ) {
    if ( contentBounds == null ) {
        contentBounds = content.getFullBounds();
    }
    return contentBounds;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:7,代码来源:SolutionControlsNode.java

示例8: InjectorNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public InjectorNode( double rotationAngle, final SimpleObserver inject ) {
    this.inject = inject;

    // Create the root node to which the various constituent parts can be
    // added.
    injectorNode = new PNode();

    // Load the graphic images for this device.  These are offset in order
    // to make the center of rotation be the center of the bulb.
    BufferedImage injectorBodyImage = RESOURCES.getImage( "squeezer_background.png" );
    PNode injectorBodyImageNode = new PImage( injectorBodyImage );
    Rectangle2D originalBodyBounds = injectorBodyImageNode.getFullBounds();
    injectorBodyImageNode.setOffset( -originalBodyBounds.getWidth() / 2, -originalBodyBounds.getHeight() / 2 );
    injectorNode.addChild( injectorBodyImageNode );

    pressedButtonImage = RESOURCES.getImage( "button_pressed.png" );
    unpressedButtonImage = RESOURCES.getImage( "button_unpressed.png" );
    buttonImageNode = new PImage( unpressedButtonImage );
    buttonImageNode.setOffset( BUTTON_OFFSET );
    injectorNode.addChild( buttonImageNode );

    // Rotate and scale the image node as a whole.
    double scale = INJECTOR_HEIGHT / injectorBodyImageNode.getFullBoundsReference().height;
    injectorNode.rotate( -rotationAngle );
    injectorNode.scale( scale );

    // Add the injector image node.  Note that the position has to be
    // tweaked in order to account for the rotation of the node image,
    // since the rotation of the square image enlarges the bounds.
    injectorNode.setOffset( -Math.abs( Math.sin( rotationAngle * 2 ) ) * 30, 0 );
    addChild( injectorNode );

    // Set up the injection point offset. This makes some assumptions
    // about the nature of the image, and will need to be updated if the
    // image is changed.
    distanceCenterToTip = 0.7 * INJECTOR_HEIGHT;
    final double centerOffsetX = 0.4 * INJECTOR_HEIGHT;
    Dimension2D injectionPointOffset = new PDimension();
    injectionPointOffset.setSize( distanceCenterToTip * Math.cos( rotationAngle ) + centerOffsetX,
                                  distanceCenterToTip * Math.sin( -rotationAngle ) );

    // Set up the button handling.
    injectorBodyImageNode.setPickable( false );
    buttonImageNode.setPickable( true );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:46,代码来源:InjectorNode.java

示例9: calculateScaleForTargetSize

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Utility method for calculating the scale factor needed to make a PNode
 * fit within the specified size.
 */
private double calculateScaleForTargetSize( PNode node, Dimension2D desiredSize ) {

    PBounds bounds = node.getFullBounds();

    double xDimensionScale = desiredSize.getWidth() / bounds.width;
    double yDimensionScale = desiredSize.getHeight() / bounds.height;

    return Math.min( xDimensionScale, yDimensionScale );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:14,代码来源:SingleNucleusDecayTimeChart.java

示例10: getControlPanelBounds

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Determine the bounds of the control panel.  This implementation uses the bounds of the content.
 * This may be overridden if subclasses don't want control panel size to change when the contents
 * change.
 *
 * @param content the content PNode in this ControlPanelNode
 * @return the PBounds which the ControlPanelNode should occupy
 */
protected PBounds getControlPanelBounds( PNode content ) {
    return content.getFullBounds();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:12,代码来源:ControlPanelNode.java


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