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


Java PBounds.getMaxX方法代码示例

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


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

示例1: setPositions

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
private void setPositions() {
    PBounds parentBounds = parent.getBounds();

    double buttonNodeX = parentBounds.getMaxX() - showHideButtonNode.getWidth() - DEFAULT_PADDING;
    double buttonNodeY = parentBounds.getMinY() + DEFAULT_PADDING;

    showHideButtonNode.setOffset(
            buttonNodeX,
            buttonNodeY
    );

    if ( showHideButtonNode.getParent() != null && showHideButtonNode.getParent().getChildrenReference().contains( showHideButtonNode ) ) {
        showHideButtonNode.moveToFront();
    }

    restoreLabelNode.setOffset(
            buttonNodeX - restoreLabelNode.getWidth() - DEFAULT_PADDING,
            buttonNodeY
    );

    if ( restoreLabelNode.getParent() != null && restoreLabelNode.getParent().getChildrenReference().contains( restoreLabelNode ) ) {
        restoreLabelNode.moveToFront();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:25,代码来源:PNodeShowHideControl.java

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

示例3: separateMoleculeDestinations

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
 * Update atom destinations so that separate molecules will be separated visually
 * <p/>
 * Returns all of the molecules that were pushed in this action
 */
private Set<Molecule> separateMoleculeDestinations() {
    int maxIterations = 500;
    double pushAmount = 10; // how much to push two molecules away

    Set<Molecule> pushedMolecules = new HashSet<Molecule>();

    boolean foundOverlap = true;
    while ( foundOverlap && maxIterations-- >= 0 ) {
        foundOverlap = false;
        for ( Molecule a : molecules ) {
            PBounds aBounds = padMoleculeBounds( a.getDestinationBounds() );

            // push it away from the outsides
            if ( aBounds.getMinX() < getAvailablePlayAreaBounds().getMinX() ) {
                a.shiftDestination( new Vector2D( getAvailablePlayAreaBounds().getMinX() - aBounds.getMinX(), 0 ) );
                aBounds = padMoleculeBounds( a.getDestinationBounds() );
            }
            if ( aBounds.getMaxX() > getAvailablePlayAreaBounds().getMaxX() ) {
                a.shiftDestination( new Vector2D( getAvailablePlayAreaBounds().getMaxX() - aBounds.getMaxX(), 0 ) );
                aBounds = padMoleculeBounds( a.getDestinationBounds() );
            }
            if ( aBounds.getMinY() < getAvailablePlayAreaBounds().getMinY() ) {
                a.shiftDestination( new Vector2D( 0, getAvailablePlayAreaBounds().getMinY() - aBounds.getMinY() ) );
                aBounds = padMoleculeBounds( a.getDestinationBounds() );
            }
            if ( aBounds.getMaxY() > getAvailablePlayAreaBounds().getMaxY() ) {
                a.shiftDestination( new Vector2D( 0, getAvailablePlayAreaBounds().getMaxY() - aBounds.getMaxY() ) );
            }

            // then separate it from other molecules
            for ( Molecule b : molecules ) {
                if ( a.getMoleculeId() >= b.getMoleculeId() ) {
                    // this removes the case where a == b, and will make sure we don't run the following code twice for (a,b) and (b,a)
                    continue;
                }
                PBounds bBounds = padMoleculeBounds( b.getDestinationBounds() );
                if ( aBounds.intersects( bBounds ) ) {
                    foundOverlap = true;

                    // try adding both. set should remove duplicates
                    pushedMolecules.add( a );
                    pushedMolecules.add( b );

                    // get perturbed centers. this is so that if two molecules have the exact same centers, we will push them away
                    Vector2D aCenter = new Vector2D( aBounds.getCenter2D() ).plus( Math.random() - 0.5, Math.random() - 0.5 );
                    Vector2D bCenter = new Vector2D( bBounds.getCenter2D() ).plus( Math.random() - 0.5, Math.random() - 0.5 );

                    // delta from center of A to center of B, scaled to half of our push amount.
                    Vector2D delta = bCenter.minus( aCenter ).normalized().times( pushAmount );

                    // how hard B should be pushed (A will be pushed (1-pushRatio)). Heuristic, power is to make the ratio not too skewed
                    // this is done so that heavier molecules will be pushed less, while lighter ones will be pushed more
                    double pushPower = 1;
                    double pushRatio = Math.pow( a.getApproximateMolecularWeight(), pushPower ) / ( Math.pow( a.getApproximateMolecularWeight(), pushPower ) + Math.pow( b.getApproximateMolecularWeight(), pushPower ) );

                    // push B by the pushRatio
                    b.shiftDestination( delta.times( pushRatio ) );

                    // push A the opposite way, by (1 - pushRatio)
                    Vector2D delta1 = delta.times( -1 * ( 1 - pushRatio ) );
                    a.shiftDestination( delta1 );

                    aBounds = padMoleculeBounds( a.getDestinationBounds() );
                }
            }
        }
    }

    return pushedMolecules;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:76,代码来源:Kit.java

示例4: isPointOutsideRadiusBounds

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
private static boolean isPointOutsideRadiusBounds( Vector2D point, double radius, PBounds bounds ) {
    return point.x - radius < bounds.getMinX()
           || point.x + radius > bounds.getMaxX()
           || point.y - radius < bounds.getMinY()
           || point.y + radius > bounds.getMaxY();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:7,代码来源:Reaction.java

示例5: BeakerNode

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
public BeakerNode( PDimension vesselSize, AqueousSolution solution ) {
    
    VesselNode vesselNode = new VesselNode( vesselSize, MAX_VOLUME );
    
    double probeHeight = vesselSize.getHeight() + 55;
    probeNode = new PHProbeNode( probeHeight, solution );
    
    SolutionNode solutionNode = new SolutionNode( vesselSize );
    
    moleculeCountsNode = new MoleculeCountsNode( solution );
    
    PDimension labelSize = new PDimension( 0.9 * vesselSize.getWidth(), 0.1 * vesselSize.getHeight() );
    beakerLabelNode = new BeakerLabelNode( labelSize, solution );
    
    // clipping path for "dot" views
    PBounds containerBounds = new PBounds( 0, 0, vesselSize.getWidth(), vesselSize.getHeight() );
    PClip dotsClippingPath = new PClip();
    dotsClippingPath.setPathTo( new Rectangle2D.Double( containerBounds.getX(), containerBounds.getY(), containerBounds.getWidth(), containerBounds.getHeight() ) );
    dotsClippingPath.setStroke( null );
    
    dotsNode = new RatioDotsNode( solution, containerBounds );
    dotsClippingPath.addChild( dotsNode ); // clip to solution bounds
    
    // rendering order
    addChild( solutionNode );
    addChild( probeNode );
    addChild( dotsClippingPath );
    addChild( vesselNode );
    addChild( moleculeCountsNode );
    addChild( beakerLabelNode );
    
    // layout
    vesselNode.setOffset( 0, 0 );
    solutionNode.setOffset( vesselNode.getOffset() );
    // molecule counts inside the vessel
    double xOffset = vesselNode.getXOffset() - PNodeLayoutUtils.getOriginXOffset( moleculeCountsNode ) + 25;
    double yOffset = vesselNode.getYOffset() - PNodeLayoutUtils.getOriginYOffset( moleculeCountsNode ) + 20;
    moleculeCountsNode.setOffset( xOffset, yOffset );
    // label at bottom of vessel
    PBounds vfb = vesselNode.getFullBoundsReference();
    xOffset = vfb.getMinX() + ( vfb.getWidth() - beakerLabelNode.getFullBoundsReference().getWidth() ) / 2;
    yOffset = vfb.getMaxY() - beakerLabelNode.getFullBoundsReference().getHeight() - 20;
    beakerLabelNode.setOffset( xOffset, yOffset );
    // probe at right side of vessel, tip of probe at bottom of vessel
    xOffset = vfb.getMaxX() - probeNode.getFullBoundsReference().getWidth() - 100;
    yOffset = vfb.getMaxY() - probeNode.getFullBoundsReference().getHeight();
    probeNode.setOffset( xOffset, yOffset );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:49,代码来源:BeakerNode.java

示例6: GameScoreboardNode

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
 * Constructor
 *
 * @param maxLevel     the maximum level, used to adjust the layout to accommodate the maximum width
 * @param maxScore     the maximum score, used to adjust the layout to accommodate the maximum width
 * @param pointsFormat points are displayed in this format
 */
public GameScoreboardNode( int maxLevel, double maxScore, NumberFormat pointsFormat ) {

    this.pointsFormat = pointsFormat;
    this.confirmNewGame = false; // #3434, default is no confirmation
    this.listeners = new EventListenerList();

    // Level
    levelNode = new PText();
    levelNode.setFont( FONT );
    setLevel( maxLevel ); // start with this, so we have a reasonable size for layout

    // Score
    scoreNode = new PText();
    scoreNode.setFont( FONT );
    setScore( maxScore ); // start with this, so we have a reasonable size for layout

    // timer
    timerIcon = new PImage( STOPWATCH_ICON );
    timerValue = new PText();
    timerValue.setFont( FONT );
    setTime( 0 ); // start with this, so we have a reasonable size for layout

    // New Game button
    newGameButton = new HTMLImageButtonNode( BUTTON_NEW_GAME, BUTTON_FONT, BUTTON_COLOR ) {{
        setUserComponent( GameSimSharing.UserComponents.newGameButton );
    }};
    newGameButton.addActionListener( new ActionListener() {
        public void actionPerformed( ActionEvent e ) {
            handleNewGame();
        }
    } );

    // rendering order
    addChild( levelNode );
    addChild( scoreNode );
    addChild( timerIcon );
    addChild( timerValue );
    addChild( newGameButton );

    // layout, everything in a row, vertically centered, offsets were set by eyeballing them
    final double maxChildHeight = getMaxChildHeight();
    // level
    double x = X_MARGIN;
    double y = Y_MARGIN + ( ( maxChildHeight - levelNode.getFullBoundsReference().getHeight() ) / 2 );
    levelNode.setOffset( x, y );
    // score
    x = levelNode.getFullBoundsReference().getMaxX() + 80;
    y = Y_MARGIN + ( ( maxChildHeight - scoreNode.getFullBoundsReference().getHeight() ) / 2 );
    scoreNode.setOffset( x, y );
    // timer
    x = scoreNode.getFullBoundsReference().getMaxX() + 60;
    y = Y_MARGIN + ( ( maxChildHeight - timerIcon.getFullBoundsReference().getHeight() ) / 2 );
    timerIcon.setOffset( x, y );
    x = timerIcon.getFullBoundsReference().getMaxX() + 5;
    y = Y_MARGIN + ( ( maxChildHeight - timerValue.getFullBoundsReference().getHeight() ) / 2 );
    timerValue.setOffset( x, y );
    // New Game button
    x = timerValue.getFullBoundsReference().getMaxX() + 20;
    y = Y_MARGIN + ( ( maxChildHeight - newGameButton.getFullBoundsReference().getHeight() ) / 2 );
    newGameButton.setOffset( x, y );

    // background, added last since it's sized to fit the child nodes above
    PBounds b = getFullBoundsReference();
    backgroundShape = new Rectangle2D.Double( 0, 0, b.getMaxX() + X_MARGIN, b.getMaxY() + Y_MARGIN );
    backgroundNode = new PPath( backgroundShape );
    backgroundNode.setPaint( BACKGROUND_FILL_COLOR );
    backgroundNode.setStroke( BACKGROUND_STROKE );
    backgroundNode.setStrokePaint( BACKGROUND_STROKE_COLOR );
    addChild( backgroundNode );
    backgroundNode.moveToBack();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:79,代码来源:GameScoreboardNode.java

示例7: createContentNode

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
private static PNode createContentNode( String text, Font font, Color foreground, Color disabledForeground, boolean enabled, BufferedImage image, BufferedImage disabledImage, TextPosition textPosition, double imageTextGap ) {
    PNode textNode = createTextNode( text, font, foreground, disabledForeground, enabled );
    PNode imageNode = createImageNode( image, disabledImage, enabled );
    PComposite content = new PComposite();
    content.addChild( textNode );
    content.addChild( imageNode );

    // layout text and image
    double textX, imageX = 0;
    double textY, imageY = 0;
    PBounds tb = textNode.getFullBoundsReference();
    PBounds ib = imageNode.getFullBoundsReference();
    if ( textPosition == TextPosition.ABOVE ) {
        textX = 0;
        imageX = tb.getCenterX() - ( ib.getWidth() / 2 );
        textY = 0;
        imageY = tb.getMaxY() + imageTextGap;
    }
    else if ( textPosition == TextPosition.BELOW ) {
        imageX = 0;
        textX = ib.getCenterX() - ( tb.getWidth() / 2 );
        imageY = 0;
        textY = ib.getMaxY() + imageTextGap;
    }
    else if ( textPosition == TextPosition.LEFT ) {
        textX = 0;
        imageX = tb.getMaxX() + imageTextGap;
        textY = 0;
        imageY = tb.getCenterY() - ( ib.getHeight() / 2 );
    }
    else if ( textPosition == TextPosition.RIGHT ) {
        imageX = 0;
        textX = ib.getMaxX() + imageTextGap;
        imageY = 0;
        textY = ib.getCenterY() - ( tb.getHeight() / 2 );
    }
    else {
        throw new UnsupportedOperationException( "unsupported text position: " + textPosition );
    }
    textNode.setOffset( textX, textY );
    imageNode.setOffset( imageX, imageY );
    return content;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:44,代码来源:HTMLImageButtonNode.java


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