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


Java PBounds.getY方法代码示例

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


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

示例1: handleReturnBeadButton

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
 * When the "Return Bead" button is clicked,
 * move the bead to the button's position and hide the button.
 */
private void handleReturnBeadButton() {

    // Determine the button's coordinates
    PBounds b = _returnBeadButtonWrapper.getFullBoundsReference();
    double x = b.getX() + ( b.getWidth() / 2 );
    double y = b.getY() + ( b.getHeight() / 2 );
    OTModelViewTransform modelViewTransform = _model.getModelViewTransform();
    Point2D p = modelViewTransform.viewToModel( x, y );

    // Move the bead to the button's position
    Bead bead = _model.getBead();
    bead.setMotionEnabled( false );
    bead.setPosition( p );
    bead.setMotionEnabled( true );

    // Hide the button
    _returnBeadButtonWrapper.setVisible( false );
    _returnBeadButtonWrapper.setPickable( false );
    _returnBeadButtonWrapper.setChildrenPickable( false );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:25,代码来源:DNACanvas.java

示例2: updateLayout

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的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: fullPaint

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
 * Overrides the camera's full paint method to do the fast rendering when
 * possible.
 * 
 * @param paintContext Paint Contex in which the painting is done
 */
public void fullPaint(final PPaintContext paintContext) {
    if (imageAnimate) {
        final PBounds fRef = getFullBoundsReference();
        final PBounds viewBounds = getViewBounds();
        final double scale = getFullBoundsReference().getWidth() / imageAnimateBounds.getWidth();
        final double xOffset = (viewBounds.getX() - imageAnimateBounds.getX()) * scale;
        final double yOffset = (viewBounds.getY() - imageAnimateBounds.getY()) * scale;
        final double scaleW = viewBounds.getWidth() * scale;
        final double scaleH = viewBounds.getHeight() * scale;
        paintContext.getGraphics().drawImage(paintBuffer, 0, 0, (int) Math.ceil(fRef.getWidth()),
                (int) Math.ceil(fRef.getHeight()), (int) Math.floor(xOffset), (int) Math.floor(yOffset),
                (int) Math.ceil(xOffset + scaleW), (int) Math.ceil(yOffset + scaleH), null);
    }
    else {
        super.fullPaint(paintContext);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:24,代码来源:PCacheCamera.java

示例4: getMoleculeAreaInBlackBox

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
 * @return Molecule area. Excludes the area in the black box where the 3D button needs to go
 */
private PBounds getMoleculeAreaInBlackBox() {
    PBounds blackBoxFullBounds = blackBox.getFullBounds();
    return new PBounds(
            blackBoxFullBounds.getX(),
            blackBoxFullBounds.getY(),
            blackBoxFullBounds.getWidth() - BLACK_BOX_PADDING_FOR_3D - button3dWidth, // leave room for 3d button on RHS
            blackBoxFullBounds.getHeight()
    );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:CollectionBoxNode.java

示例5: getLayoutBounds

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
public PBounds getLayoutBounds() {
    PBounds bounds = getFullBounds();
    return new PBounds( bounds.getX() - paddingLeft,
                        bounds.getY() - paddingTop,
                        bounds.getWidth() + paddingLeft + paddingRight,
                        bounds.getHeight() + paddingTop + paddingBottom );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:GeneralLayoutNode.java

示例6: getRandomPoint

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
private Point2D getRandomPoint( PBounds bounds ) {
    double x = bounds.getX() + ( Math.random() * bounds.getWidth() );
    double y = bounds.getY() + ( Math.random() * bounds.getHeight() );
    return new Point2D.Double( x, y );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:6,代码来源:GameRewardNode.java

示例7: getRandomPoint

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
private void getRandomPoint( PBounds bounds, Point2D pOutput ) {
    double x = bounds.getX() + ( _randomCoordinate.nextDouble() * bounds.getWidth() );
    double y = bounds.getY() + ( _randomCoordinate.nextDouble() * bounds.getHeight() );
    pOutput.setLocation( x, y );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:6,代码来源:ParticlesNode.java

示例8: handleSpectrometerSnapshot

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
private void handleSpectrometerSnapshot() {
    
    // increment the counter used to title the snapshots
    _spectrometerSnapshotsCounter++;

    // create the snapshot title
    String title = HAResources.getString( "label.snapshot" ) + " " + _spectrometerSnapshotsCounter + ": ";
    if ( _modeSwitch.isPredictionSelected() ) {
        title += _atomicModelSelector.getSelectionName();
    }
    else {
        title += HAResources.getString( "title.spectrometer.experiment" );
    }

    // create the snapshot's Piccolo node
    final SpectrometerSnapshotNode snapshotNode = _spectrometerNode.getSnapshot( title );
    snapshotNode.addCloseListener( new ActionListener() { 
        public void actionPerformed( ActionEvent event ) {
            _rootNode.removeChild( snapshotNode );
            _spectrometerSnapshotNodes.remove( snapshotNode );
        }
    } );
    _rootNode.addChild( snapshotNode );

    // set the snapshot's position
    PBounds sb = _spectrometerNode.getFullBounds();
    double x = 0;
    double y = 0;
    if ( _spectrometerSnapshotNodes.size() == 0 ) {
        // first snapshot goes directly above spectrometer
        x = sb.getX();
        y = sb.getY() - snapshotNode.getFullBounds().getHeight() - 5;
    }
    else {
        // overlap the most-recently created snapshot, slightly above and to the left 
        PBounds fb = ((PNode)_spectrometerSnapshotNodes.get( _spectrometerSnapshotNodes.size() - 1 )).getFullBounds();
        x = fb.getX() - 30; // far enough to the left that you can see the other snapshot's close button
        y = fb.getY() - 20;
    }
    snapshotNode.setOffset( x, y );
    
    // add to snapshot list *after* setting bounds
    _spectrometerSnapshotNodes.add( snapshotNode );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:45,代码来源:HAModule.java

示例9: getRandomPoint

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
private void getRandomPoint( PBounds bounds, Point2D pOutput ) {
    double x = bounds.getX() + ( randomCoordinate.nextDouble() * bounds.getWidth() );
    double y = bounds.getY() + ( randomCoordinate.nextDouble() * bounds.getHeight() );
    pOutput.setLocation( x, y );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:6,代码来源:RatioDotsNode.java

示例10: getFullBoundsReference

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
@Override public PBounds getFullBoundsReference() {
    PBounds b = super.getFullBoundsReference();
    return new PBounds( b.getX(), b.getY(), b.getWidth() + padding, b.getHeight() + padding );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:5,代码来源:PadBoundsNode.java

示例11: setViewPosition

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
 * We do the same thing we did in getViewPosition above to flip the
 * document-window position relationship
 * 
 * @param x The new x position
 * @param y The new y position
 */
public void setViewPosition(final double x, final double y) {
    if (camera == null)
        return;

    // If a scroll is in progress - we ignore new scrolls - if we
    // didn't, since the scrollbars depend on the camera location
    // we can end up with an infinite loop
    if (scrollInProgress)
        return;

    scrollInProgress = true;

    // Get the union of all the layers' bounds
    final PBounds layerBounds = new PBounds();
    final List layers = camera.getLayersReference();
    for (final Iterator i = layers.iterator(); i.hasNext();) {
        final PLayer layer = (PLayer) i.next();
        layerBounds.add(layer.getFullBoundsReference());
    }

    final PAffineTransform at = camera.getViewTransform();
    at.transform(layerBounds, layerBounds);

    // Union the camera view bounds
    final PBounds viewBounds = camera.getBoundsReference();
    layerBounds.add(viewBounds);

    // Now find the new view position in view coordinates -
    // This is basically the distance from the lower right
    // corner of the window to the upper left corner of the
    // document
    // We then measure the offset from the lower right corner
    // of the document
    final Point2D newPoint = new Point2D.Double(layerBounds.getX() + layerBounds.getWidth()
            - (x + viewBounds.getWidth()), layerBounds.getY() + layerBounds.getHeight()
            - (y + viewBounds.getHeight()));

    // Now transform the new view position into global coords
    camera.localToView(newPoint);

    // Compute the new matrix values to put the camera at the
    // correct location
    final double newX = -(at.getScaleX() * newPoint.getX() + at.getShearX() * newPoint.getY());
    final double newY = -(at.getShearY() * newPoint.getX() + at.getScaleY() * newPoint.getY());

    at.setTransform(at.getScaleX(), at.getShearY(), at.getShearX(), at.getScaleY(), newX, newY);

    // Now actually set the camera's transform
    camera.setViewTransform(at);
    scrollInProgress = false;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:59,代码来源:PrintExample.java

示例12: setViewPosition

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
 * We do the same thing we did in getViewPosition above to flip the
 * document-window position relationship
 * 
 * @param x The new x position
 * @param y The new y position
 */
public void setViewPosition(final double x, final double y) {
    if (camera == null)
        return;

    // If a scroll is in progress - we ignore new scrolls - if we
    // didn't, since the scrollbars depend on the camera
    // location we can end up with an infinite loop
    if (scrollInProgress)
        return;

    scrollInProgress = true;

    // Get the union of all the layers' bounds
    final PBounds layerBounds = new PBounds();
    final java.util.List layers = camera.getLayersReference();
    for (final Iterator i = layers.iterator(); i.hasNext();) {
        final PLayer layer = (PLayer) i.next();
        layerBounds.add(layer.getFullBoundsReference());
    }

    final PAffineTransform at = camera.getViewTransform();
    at.transform(layerBounds, layerBounds);

    // Union the camera view bounds
    final PBounds viewBounds = camera.getBoundsReference();
    layerBounds.add(viewBounds);

    // Now find the new view position in view coordinates -
    // This is basically the distance from the lower right
    // corner of the window to the upper left corner of the
    // document. We then measure the offset from the lower right corner
    // of the document
    final Point2D newPoint = new Point2D.Double(layerBounds.getX() + layerBounds.getWidth()
            - (x + viewBounds.getWidth()), layerBounds.getY() + layerBounds.getHeight()
            - (y + viewBounds.getHeight()));

    // Now transform the new view position into global coords
    camera.localToView(newPoint);

    // Compute the new matrix values to put the camera at the
    // correct location
    final double newX = -(at.getScaleX() * newPoint.getX() + at.getShearX() * newPoint.getY());
    final double newY = -(at.getShearY() * newPoint.getX() + at.getScaleY() * newPoint.getY());

    at.setTransform(at.getScaleX(), at.getShearY(), at.getShearX(), at.getScaleY(), newX, newY);

    // Now actually set the camera's transform
    camera.setViewTransform(at);
    scrollInProgress = false;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:58,代码来源:ScrollingExample.java

示例13: setViewPosition

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
 * Set the view position in a manner consistent with standardized scrolling.
 * 
 * @param x The new x position
 * @param y The new y position
 */
public void setViewPosition(final double x, final double y) {
    // Bail out if scrollInProgress because we can end up with an infinite
    // loop since the scrollbars depend on the camera location
    if (camera == null || scrollInProgress) {
        return;
    }

    scrollInProgress = true;

    // Get the union of all the layers' bounds
    final PBounds layerBounds = new PBounds();
    final List layers = camera.getLayersReference();
    for (final Iterator i = layers.iterator(); i.hasNext();) {
        final PLayer layer = (PLayer) i.next();
        layerBounds.add(layer.getFullBoundsReference());
    }

    final PAffineTransform at = camera.getViewTransform();
    at.transform(layerBounds, layerBounds);

    // Union the camera bounds
    final PBounds viewBounds = camera.getBoundsReference();
    layerBounds.add(viewBounds);

    // Now find the new view position in view coordinates
    final Point2D newPoint = new Point2D.Double(layerBounds.getX() + x, layerBounds.getY() + y);

    // Now transform the new view position into global coords
    camera.localToView(newPoint);

    // Compute the new matrix values to put the camera at the
    // correct location
    final double newX = -(at.getScaleX() * newPoint.getX() + at.getShearX() * newPoint.getY());
    final double newY = -(at.getShearY() * newPoint.getX() + at.getScaleY() * newPoint.getY());

    at.setTransform(at.getScaleX(), at.getShearY(), at.getShearX(), at.getScaleY(), newX, newY);

    // Now actually set the camera's transform
    camera.setViewTransform(at);
    scrollInProgress = false;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:48,代码来源:PDefaultScrollDirector.java


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