• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PBounds类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



PBounds类属于edu.umd.cs.piccolo.util包,在下文中一共展示了PBounds类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: updateElectronPosition

import edu.umd.cs.piccolo.util.PBounds; //导入依赖的package包/类
private void updateElectronPosition() {
    
    ElectronNode electronNode = getElectronNode();
    PBounds electronBounds = electronNode.getFullBounds();
    Rectangle2D drawingArea = getDrawingArea();

    final double x = drawingArea.getX() + ( electronBounds.getWidth() / 2 ) + X_MARGIN;
    
    double y = Double.MAX_VALUE; // off the chart
    final double r = _atom.getElectronDistanceFromCenter();
    final double minEnergy = -1 / ( MIN_RADIUS * MIN_RADIUS );
    if ( r > 0 ) {
        final double energy = -1 / ( r * r );
        if ( energy >= minEnergy ) {
            double h = drawingArea.getHeight() - Y_MARGIN; // height of energy axis
            double d = h * energy / minEnergy; // how far down the energy axis is this energy value?
            y = drawingArea.getY() + Y_MARGIN + d;
        }
    }

    electronNode.setOffset( x, y );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:23,代码来源:SolarSystemEnergyDiagram.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: transformBoundsToStage

import edu.umd.cs.piccolo.util.PBounds; //导入依赖的package包/类
public Rectangle2D transformBoundsToStage( Rectangle2D localBounds ) {
        // TODO: verify this code!
        // get the translation of the control panel
        float offsetX = (float) position.get().getX();
        float offsetY = (float) position.get().getY();

        // convert these to stage-offset from the lower-left, since the control panel itself is translated
        double localLeft = localBounds.getMinX() + offsetX;
        double localRight = localBounds.getMaxX() + offsetX;
//        double localTop = getComponentHeight() - localBounds.getMinY() + offsetY; // remember, Y is flipped here
//        double localBottom = getComponentHeight() - localBounds.getMaxY() + offsetY; // remember, Y is flipped here
        double localTop = localBounds.getMaxY() + offsetY; // remember, Y is flipped here
        double localBottom = localBounds.getMinY() + offsetY; // remember, Y is flipped here

        return new PBounds( localLeft, localBottom, localRight - localLeft, localTop - localBottom );
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:OrthoSwingNode.java


示例4: addRandomNode

import edu.umd.cs.piccolo.util.PBounds; //导入依赖的package包/类
private void addRandomNode() {

        // choose a random motion delta
        int delta = (int) Math.max( 1, Math.random() * motionDelta );

        // choose a random image
        int index = (int) ( Math.random() * imagePool.size() );
        MovingImageNode imageNode = new MovingImageNode( imagePool.get( index ), delta );
        addChild( imageNode );

        // set a random location within the bounds
        PBounds bounds = getBoundsReference();
        Point2D location = getRandomPoint( bounds );
        double x = location.getX() - ( imageNode.getFullBoundsReference().getWidth() / 2 );
        double y = location.getY() - ( imageNode.getFullBoundsReference().getHeight() / 2 );
        imageNode.setOffset( x, y );
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:18,代码来源:RewardNode.java


示例5: LayoutBounds

import edu.umd.cs.piccolo.util.PBounds; //导入依赖的package包/类
/**
 * Construct the necessary layout. If wide is true, the collectionAreaModelWidth is ignored
 */
public LayoutBounds() {
    double availableWidth = MODEL_SIZE.getWidth() - 2 * ChemicalReactionsConstants.MODEL_PADDING; // minus padding
    double halfWidth = availableWidth / 2;

    double kitTop = MODEL_SIZE.getHeight() / 2 - MODEL_PADDING; // Y is up, so this is the top (max y) value for the rectangle
    double kitHeight = 550;
    double kitBottom = kitTop - kitHeight;

    availableKitBounds = new PBounds( -halfWidth, kitBottom, availableWidth, kitHeight );

    availablePlayAreaBounds = new PBounds(
            -MODEL_SIZE.getWidth() / 2 + MODEL_PADDING + LEFT_EXTRA_PADDING, // far left part of model
            -MODEL_SIZE.getHeight() / 2 + MODEL_PADDING + BOTTOM_PADDING, // top of kit
            availableKitBounds.width - LEFT_EXTRA_PADDING - RIGHT_EXTRA_PADDING, // add in padding, since there is padding in-between the kit and collection area
            kitBottom + MODEL_SIZE.getHeight() / 2 - MODEL_PADDING * 2 - BOTTOM_PADDING );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:LayoutBounds.java


示例6: ControlPanelNode

import edu.umd.cs.piccolo.util.PBounds; //导入依赖的package包/类
public ControlPanelNode( final PNode content, Color backgroundColor, BasicStroke borderStroke, Color borderColor, final int inset, final int arc, boolean transparifySwing ) {
    //Make sure the background resizes when the content resizes
    background = new PhetPPath( backgroundColor, borderStroke, borderColor ) {{
        final PropertyChangeListener updateSize = new PropertyChangeListener() {
            public void propertyChange( PropertyChangeEvent evt ) {
                final PBounds layoutSize = getControlPanelBounds( content );
                //Set the size of the border, subtracting out any local offset of the content node
                setPathTo( new RoundRectangle2D.Double( 0, 0, layoutSize.width + inset * 2, layoutSize.height + inset * 2, arc, arc ) );
            }
        };
        content.addPropertyChangeListener( PROPERTY_FULL_BOUNDS, updateSize );
        updateSize.propertyChange( null );
    }};
    // Create a node that puts the contents at the inset location
    // regardless of its initial offset.
    PNode insetContentNode = new ZeroOffsetNode( content ) {{
        setOffset( inset, inset );
    }};
    addChild( background );
    background.addChild( insetContentNode );
    if ( transparifySwing ) {
        transparifySwing( this );
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:25,代码来源:ControlPanelNode.java


示例7: 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


示例8: Shaker

import edu.umd.cs.piccolo.util.PBounds; //导入依赖的package包/类
public Shaker( Vector2D location, double orientation, PBounds dragBounds, Property<Solute> solute, double maxDispensingRate ) {
    super( location, dragBounds );
    assert ( dragBounds.contains( location.toPoint2D() ) );

    this.orientation = orientation;
    this.solute = solute;
    this.visible = new Property<Boolean>( true );
    this.empty = new Property<Boolean>( false );
    this.maxDispensingRate = maxDispensingRate;
    this.dispensingRate = new Property<Double>( 0d );
    this.previousLocation = location;

    // set the dispensing rate to zero when the shaker becomes empty or invisible
    RichSimpleObserver rateObserver = new RichSimpleObserver() {
        public void update() {
            if ( empty.get() || !visible.get() ) {
                dispensingRate.set( 0d );
            }
        }
    };
    rateObserver.observe( empty, visible );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:23,代码来源:Shaker.java


示例9: testCreateRectangleReturnsValidPPath

import edu.umd.cs.piccolo.util.PBounds; //导入依赖的package包/类
public void testCreateRectangleReturnsValidPPath() {
    final PPath path = PPath.createRectangle(0, 0, 100, 50);
    assertNotNull(path);

    // Seems like rounding is affecting the bounds greatly
    PiccoloAsserts.assertEquals(new PBounds(0, 0, 100, 50), path.getBounds(), 2.0d);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:PPathTest.java


示例10: repaint

import edu.umd.cs.piccolo.util.PBounds; //导入依赖的package包/类
/**
 * Flags the bounds provided as needing to be redrawn.
 * 
 * @param bounds the bounds that should be repainted
 */
public void repaint(final PBounds bounds) {
    bounds.expandNearestIntegerDimensions();
    bounds.inset(-1, -1);

    redraw((int) bounds.x, (int) bounds.y, (int) bounds.width, (int) bounds.height, true);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:12,代码来源:PSWTCanvas.java


示例11: testAnimateViewToPanToBoundsIsImmediateWhenDurationIsZero

import edu.umd.cs.piccolo.util.PBounds; //导入依赖的package包/类
public void testAnimateViewToPanToBoundsIsImmediateWhenDurationIsZero() {
    camera.setViewBounds(new PBounds(0, 0, 10, 10));
    final PActivity activity = camera.animateViewToPanToBounds(new PBounds(10, 10, 10, 10), 0);

    assertNull(activity);
    assertEquals(AffineTransform.getTranslateInstance(-15, -15), camera.getViewTransform());
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:PCameraTest.java


示例12: shouldRevalidateScrollPane

import edu.umd.cs.piccolo.util.PBounds; //导入依赖的package包/类
/**
 * Should the ScrollPane be revalidated. This occurs when either the scroll
 * bars are showing and should be remove or are not showing and should be
 * added.
 * 
 * @return Whether the scroll pane should be revalidated
 */
public boolean shouldRevalidateScrollPane() {
    if (camera != null) {
        if (scrollPane.getHorizontalScrollBarPolicy() != ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
                && scrollPane.getVerticalScrollBarPolicy() != ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED) {
            return false;
        }

        // 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());
        }

        // Put into camera coordinates
        camera.viewToLocal(layerBounds);

        // And union with the camera bounds
        final PBounds cameraBounds = camera.getBoundsReference();
        layerBounds.add(cameraBounds);

        // Truncate these to ints before comparing since
        // that's what the ScrollPane uses
        final int layerWidth = (int) (layerBounds.getWidth() + 0.5);
        final int layerHeight = (int) (layerBounds.getHeight() + 0.5);
        final int cameraWidth = (int) (cameraBounds.getWidth() + 0.5);
        final int cameraHeight = (int) (cameraBounds.getHeight() + 0.5);

        if (scrollPane.getHorizontalScrollBar().isShowing() && layerWidth <= cameraWidth
                || !scrollPane.getHorizontalScrollBar().isShowing() && layerWidth > cameraWidth
                || scrollPane.getVerticalScrollBar().isShowing() && layerHeight <= cameraHeight
                || !scrollPane.getVerticalScrollBar().isShowing() && layerHeight > cameraHeight) {
            return true;
        }
    }
    return false;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:46,代码来源:PDefaultScrollDirector.java


示例13: centerNode

import edu.umd.cs.piccolo.util.PBounds; //导入依赖的package包/类
protected void centerNode( PNode node ) {
    if ( node != null ) {
        Dimension2D worldSize = getWorldSize();
        PBounds b = node.getFullBoundsReference();
        double xOffset = ( worldSize.getWidth() - b.getWidth() - PNodeLayoutUtils.getOriginXOffset( node ) ) / 2;
        double yOffset = ( worldSize.getHeight() - b.getHeight() - PNodeLayoutUtils.getOriginYOffset( node ) ) / 2;
        node.setOffset( xOffset, yOffset );
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:BCECanvas.java


示例14: relocateHandle

import edu.umd.cs.piccolo.util.PBounds; //导入依赖的package包/类
/**
 * Force this handle to relocate itself using its locator.
 */
public void relocateHandle() {
    if (locator == null) {
        return;
    }

    final PBounds b = getBoundsReference();
    final Point2D aPoint = locator.locatePoint(null);

    if (locator instanceof PNodeLocator) {
        final PNode located = ((PNodeLocator) locator).getNode();
        final PNode parent = getParent();

        located.localToGlobal(aPoint);
        globalToLocal(aPoint);

        if (parent != located && parent instanceof PCamera) {
            ((PCamera) parent).viewToLocal(aPoint);
        }
    }

    final double newCenterX = aPoint.getX();
    final double newCenterY = aPoint.getY();

    if (newCenterX != b.getCenterX() || newCenterY != b.getCenterY()) {

        centerBoundsOnPoint(newCenterX, newCenterY);
    }

}
 
开发者ID:mleoking,项目名称:PhET,代码行数:33,代码来源:PHandle.java


示例15: getMarqueeBounds

import edu.umd.cs.piccolo.util.PBounds; //导入依赖的package包/类
/** {@inheritDoc} */
protected PBounds getMarqueeBounds() {
    if (marquee != null) {
        return marquee.getBounds();
    }
    return new PBounds();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:PSWTSelectionEventHandler.java


示例16: updateRtpLayout

import edu.umd.cs.piccolo.util.PBounds; //导入依赖的package包/类
private void updateRtpLayout()
{
    Rectangle2D probabilityDensityPlotBounds = _chartNode.localToGlobal( _chartNode.getProbabilityDensityPlotBounds() );
    PBounds pdZoomControlBounds = _probabilityDensityZoomControl.getFullBounds();
    
    Direction direction = _planeWave.getDirection();
    
    AbstractProbabilityNode leftNode = null;
    AbstractProbabilityNode rightNode = null;
    if ( direction == Direction.LEFT_TO_RIGHT ) {
        leftNode = _reflectionProbabilityNode;
        rightNode = _transmissionProbabilityNode;
    }
    else {
        leftNode = _transmissionProbabilityNode; 
        rightNode = _reflectionProbabilityNode;
    }
    
    double x, y;
    final double xmargin = 15;
    final double ymargin = 15;
    final double xFudge = 60;
    
    x = pdZoomControlBounds.getMaxX() + xmargin;
    y = probabilityDensityPlotBounds.getY() + ymargin;
    leftNode.setOffset( x, y );
    
    x = probabilityDensityPlotBounds.getX() + probabilityDensityPlotBounds.getWidth() - xFudge - xmargin;
    rightNode.setOffset( x, y );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:31,代码来源:QTModule.java


示例17: createTick

import edu.umd.cs.piccolo.util.PBounds; //导入依赖的package包/类
private static PNode createTick( double value, String units, boolean labelOnLeft ) {
    
    PComposite tickNode = new PComposite();
    
    // horizontal line
    GeneralPath path = new GeneralPath();
    path.moveTo( 0f, 0f );
    if ( labelOnLeft ) {
        path.lineTo( (float) -TICK_LENGTH, 0f ); 
    }
    else {
        path.lineTo( (float) TICK_LENGTH, 0f );
    }
    PPath lineNode = new PPath( path );
    lineNode.setPaint( null );
    lineNode.setStroke( TICK_STROKE );
    lineNode.setStrokePaint( TICK_COLOR );
    tickNode.addChild( lineNode );
    
    // label
    String s = TICK_LABEL_FORMAT.format( value ) + units;
    PText labelNode = new PText( s );
    labelNode.setFont( TICK_LABEL_FONT );
    labelNode.setTextPaint( TICK_LABEL_COLOR );
    tickNode.addChild( labelNode );
    
    // position label on left or right of tick, vertically align centers
    lineNode.setOffset( 0, 0 );
    PBounds bLine = lineNode.getFullBoundsReference();
    PBounds bLabel = labelNode.getFullBoundsReference();
    if ( labelOnLeft ) {
        labelNode.setOffset( bLine.getMinX() - bLabel.getWidth() - TICK_LABEL_SPACING, bLine.getCenterY() - bLabel.getHeight() / 2 );
    }
    else {
        labelNode.setOffset( bLine.getMaxX() + TICK_LABEL_SPACING, bLine.getCenterY() - bLabel.getHeight() / 2 );
    }
    
    return tickNode;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:40,代码来源:ElevationAxisNode.java


示例18: 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


示例19: centerMoleculesInBlackBox

import edu.umd.cs.piccolo.util.PBounds; //导入依赖的package包/类
private void centerMoleculesInBlackBox() {
    PBounds moleculeArea = getMoleculeAreaInBlackBox();

    // for now, we scale the molecules up and down depending on their size
    moleculeLayer.setScale( 1 );
    double xScale = ( moleculeArea.getWidth() - 25 ) / moleculeLayer.getFullBounds().getWidth();
    double yScale = ( moleculeArea.getHeight() - 25 ) / moleculeLayer.getFullBounds().getHeight();
    moleculeLayer.setScale( Math.min( xScale, yScale ) );

    moleculeLayer.centerFullBoundsOnPoint(
            moleculeArea.getCenterX() - moleculeArea.getX(),
            moleculeArea.getCenterY() - moleculeArea.getY() );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:14,代码来源:CollectionBoxNode.java


示例20: testCreatePolyLinePoint2DReturnsValidPPath

import edu.umd.cs.piccolo.util.PBounds; //导入依赖的package包/类
public void testCreatePolyLinePoint2DReturnsValidPPath() {
    final PPath path = PPath.createPolyline(new Point2D[] { new Point2D.Double(0, 0), new Point2D.Double(100, 50),
            new Point2D.Double(100, 0) });
    assertNotNull(path);

    // Seems like rounding is affecting the bounds greatly
    PiccoloAsserts.assertEquals(new PBounds(0, 0, 100, 50), path.getBounds(), 2.0d);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:PPathTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TCharShortMap类代码示例发布时间:2022-05-23
下一篇:
Java XSNotationDecl类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap