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


Java PNode.setScale方法代码示例

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


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

示例1: updateNucleusNodesScale

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Update the scale settings for the nucleus nodes.  This is generally
 * done if and when the chart is resized.
 */
private void updateNucleusNodesScale() {

    if ( _nucleusNodeRadius > 0 ) {

        if ( _undecayedNucleusNode != null ) {
            _undecayedNucleusNode.setScale( 1 );
            _undecayedNucleusNode.setScale( ( _nucleusNodeRadius * 2 ) / _undecayedNucleusNode.getFullBoundsReference().height );
        }

        Iterator it = _decayedNucleusNodes.iterator();
        while ( it.hasNext() ) {
            PNode nucleusNode = (PNode) it.next();
            nucleusNode.setScale( 1 );
            nucleusNode.setScale( ( _nucleusNodeRadius * 2 ) / nucleusNode.getFullBoundsReference().height );
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:SingleNucleusDecayTimeChart.java

示例2: DebugPSwingExtremeScaling

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public DebugPSwingExtremeScaling() {
    setSize( new Dimension( 1024, 768 ) );

    // canvas
    final PCanvas canvas = new PSwingCanvas();
    canvas.setBorder( new LineBorder( Color.BLACK ) );
    canvas.removeInputEventListener( canvas.getZoomEventHandler() );
    canvas.removeInputEventListener( canvas.getPanEventHandler() );
    setContentPane( canvas );

    // root node, uses the inverse of our extreme scale (PSWING_SCALE)
    PNode rootNode = new PNode();
    rootNode.setScale( 1.0 / PSWING_SCALE );
    canvas.getLayer().addChild( rootNode );

    // PSwing panel with some radio buttons
    PSwing panelNode = new PSwing( new UnitsPanel() );
    rootNode.addChild( panelNode );
    panelNode.setScale( PSWING_SCALE );
    panelNode.setOffset( 1, 1 );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:DebugPSwingExtremeScaling.java

示例3: updateCount

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void updateCount( ManualGeneExpressionModel model ) {
    int numProteinTypesCollected = 0;
    if ( model.proteinACollected.get() > 0 ) {
        numProteinTypesCollected++;
    }
    if ( model.proteinBCollected.get() > 0 ) {
        numProteinTypesCollected++;
    }
    if ( model.proteinCCollected.get() > 0 ) {
        numProteinTypesCollected++;
    }
    removeAllChildren();
    PNode collectedQuantityIndicator = new VBox(
            5,
            new HBox( 4, new ReadoutPText( PROTEIN_COUNT_CAPTION_PART_1 ), new IntegerBox( numProteinTypesCollected ) ),
            new ReadoutPText( PROTEIN_COUNT_CAPTION_PART_2 ) {{
                setFont( READOUT_FONT );
            }}

    );
    if ( collectedQuantityIndicator.getFullBoundsReference().width > MAX_CONTENT_WIDTH ) {
        // Scale to fit.
        collectedQuantityIndicator.setScale( MAX_CONTENT_WIDTH / getFullBoundsReference().width );
    }

    // Offset the collection complete indicator so that it will be
    // centered when it is shown.
    collectionCompleteNode.centerFullBoundsOnPoint( collectedQuantityIndicator.getFullBoundsReference().getCenterX(),
                                                    collectedQuantityIndicator.getFullBoundsReference().getCenterY() );

    // Add both nodes, so that the overall size of the node is
    // consistent, but only show one of them based upon whether the
    // collection is complete.
    addChild( collectedQuantityIndicator );
    addChild( collectionCompleteNode );

    // Set the visibility.
    collectedQuantityIndicator.setVisible( numProteinTypesCollected != NUM_PROTEIN_TYPES );
    collectionCompleteNode.setVisible( numProteinTypesCollected == NUM_PROTEIN_TYPES );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:41,代码来源:ProteinCollectionNode.java

示例4: LabeledNucleusImageNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Constructor that takes the name of an image resource and loads it.
 * 
 * @param imageName - Name of the image resource that will provide the background.
 * @param isotopeNumber - Numerical isotope number, which will be displayed as a pre-script.
 * @param chemicalSymbol - Chemical symbol for the nucleus.
 * @param labelColor - Color that will be used to display the label.
 */
public LabeledNucleusImageNode( String imageName, String isotopeNumber, String chemicalSymbol, Color labelColor ){
	
	super( isotopeNumber, chemicalSymbol, labelColor );
    
    // Get the image for the nucleus.
    BufferedImage im = NuclearPhysicsResources.getImage( imageName );
    
    // Create and add the image node.
    PImage nucleusImage = new PImage(im);
    nucleusImage.setScale( (double)IMAGE_WIDTH_IN_PIXELS / nucleusImage.getWidth() );
    getRepresentationLayer().addChild(nucleusImage);

    // Scale and position the label.
    double imageWidth = nucleusImage.getFullBoundsReference().getWidth();
    double imageHeight = nucleusImage.getFullBoundsReference().getHeight();
    PNode label = getLabel();
    double scale = Math.min( ( imageWidth / label.getFullBoundsReference().getWidth() ) * 0.9,
    	( imageHeight / label.getFullBoundsReference().getHeight() ) );
    
    label.setScale( scale );

    // Center the label over the nucleus image.
    label.setOffset( ( imageWidth - label.getFullBoundsReference().getWidth() ) / 2, 
  	  	  ( imageHeight - label.getFullBoundsReference().getHeight() ) / 2);

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

示例5: LabeledNucleusSphereNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public LabeledNucleusSphereNode( NucleusDisplayInfo displayInfo ){
  	
  	super( displayInfo );
      
  	// Create the gradient paint for the sphere in order to give it a 3D look.
Paint spherePaint = new RoundGradientPaint( SPHERE_DIAMETER / 8, -SPHERE_DIAMETER / 8, 
		getHighlightColor( displayInfo.getDisplayColor() ), 
		new Point2D.Double( SPHERE_DIAMETER / 4, SPHERE_DIAMETER / 4 ),
		displayInfo.getDisplayColor() );

  	// Create and add the sphere node.
  	SphericalNode sphere = new SphericalNode(SPHERE_DIAMETER, spherePaint, false);
  	sphere.setOffset(SPHERE_DIAMETER / 2, SPHERE_DIAMETER / 2);
      getRepresentationLayer().addChild( sphere );
      
      // Scale and position the label.
      double sphereWidth = sphere.getFullBoundsReference().getWidth();
      PNode label = getLabel();
      double scale = Math.min( ( sphereWidth / label.getFullBoundsReference().getWidth() ) * 0.9,
          	( sphereWidth / label.getFullBoundsReference().getHeight() ) );

      label.setScale( scale );
      
      // Center the label over the nucleus image.
      label.setOffset( ( sphereWidth - label.getFullBoundsReference().getWidth() ) / 2, 
    	  	  ( sphere.getFullBoundsReference().getHeight() - label.getFullBoundsReference().getHeight() ) / 2);
  }
 
开发者ID:mleoking,项目名称:PhET,代码行数:28,代码来源:LabeledNucleusSphereNode.java

示例6: updateTransform

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void updateTransform( PNode node, double d, double theta ) {
    node.setTransform( new AffineTransform() );
    node.translate( pivotPt.getX() - ( node.getFullBounds().getWidth() / 2 * scale ), pivotPt.getY() );
    node.rotateAboutPoint( theta, node.getFullBounds().getWidth() / 2 * scale, 0 );
    node.setScale( scale );
    node.translate( 0, d );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:LauncherGraphic.java

示例7: updateLaserControlPSwingScale

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void updateLaserControlPSwingScale( PSwingCanvas lightSimulationPanel, PNode laserControlPSwing, double scale ) {
    if ( lightSimulationPanel.getWidth() < 900 ) {
        laserControlPSwing.setScale( scale );
    }
    else {
        laserControlPSwing.setScale( 1.0 );
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:ResizeHandler.java

示例8: TiltPredictionSelectionPanel

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private TiltPredictionSelectionPanel( final IUserComponent userComponent, Image image, final TiltPrediction correspondingPrediction, final Property<TiltPrediction> tiltPredictionProperty,
                                      final Property<BalanceGameModel.GameState> gameStateProperty ) {

    // Create and add the panel that represents this tilt prediction choice.
    PNode panel = new PImage( image );
    panel.setScale( PANEL_WIDTH / panel.getFullBoundsReference().width );
    addChild( panel );

    // Set up mouse listener that watches to see if the user has
    // selected this option.
    panel.addInputEventListener( new PBasicInputEventHandler() {
        @Override public void mouseReleased( PInputEvent event ) {
            tiltPredictionProperty.set( correspondingPrediction );
            // Send up a sim-sharing message indicating that this panel
            // was selected.  Portray it as a radio button, since that
            // is essentially how it functions.
            SimSharingManager.sendUserMessage( userComponent, radioButton, pressed );
        }
    } );

    // Set up the listener that will highlight or un-highlight the panel.
    outline = new PhetPPath( panel.getFullBoundsReference().getBounds2D(), NON_HIGHLIGHT_STROKE, NON_HIGHLIGHT_COLOR );
    addChild( outline );

    // Add listener for changes to the tilt prediction.
    tiltPredictionProperty.addObserver( new VoidFunction1<TiltPrediction>() {
        public void apply( TiltPrediction predictionValue ) {
            // Turn the highlight on or off.
            updateHighlightState( predictionValue == correspondingPrediction, gameStateProperty.get() == BalanceGameModel.GameState.DISPLAYING_CORRECT_ANSWER );
        }
    } );

    // Add listener for changes to the game state.
    gameStateProperty.addObserver( new VoidFunction1<BalanceGameModel.GameState>() {
        public void apply( BalanceGameModel.GameState gameState ) {
            updateHighlightState( tiltPredictionProperty.get() == correspondingPrediction, gameState == BalanceGameModel.GameState.DISPLAYING_CORRECT_ANSWER );
        }
    } );

    // Set the cursor to look different when the user mouses over it.
    panel.addInputEventListener( new CursorHandler( CursorHandler.HAND ) );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:43,代码来源:TiltPredictionSelectorNode.java

示例9: loadMultipleContainerImages

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void loadMultipleContainerImages() {

        // Load the images that will make up the container.
        PImage containerLeftSideImageNode = StatesOfMatterResources.getImageNode( CONTAINER_FRONT_LEFT_IMAGE_NAME );
        PImage containerRightSideImageNode = StatesOfMatterResources.getImageNode( CONTAINER_FRONT_RIGHT_IMAGE_NAME );
        PImage containerBottomImageNode = StatesOfMatterResources.getImageNode( CONTAINER_FRONT_BOTTOM_IMAGE_NAME );
        PImage containerTopImageNode = StatesOfMatterResources.getImageNode( CONTAINER_FRONT_TOP_IMAGE_NAME );

        // Create a single PNode to contain these images, and add the images to it.
        PNode containerNode = new PNode();
        containerNode.addChild( containerLeftSideImageNode );
        containerNode.addChild( containerTopImageNode );
        containerTopImageNode.setOffset( containerLeftSideImageNode.getFullBoundsReference().width,
                                         FRONT_TOP_IMAGE_OFFSET_TWEAK );
        containerNode.addChild( containerBottomImageNode );
        containerBottomImageNode.setOffset( containerLeftSideImageNode.getFullBoundsReference().width,
                                            containerLeftSideImageNode.getFullBoundsReference().height -
                                            containerBottomImageNode.getFullBoundsReference().height + FRONT_BOTTOM_IMAGE_OFFSET_TWEAK );
        containerNode.addChild( containerRightSideImageNode );
        containerRightSideImageNode.setOffset( containerBottomImageNode.getFullBoundsReference().getMaxX(), 0 );

        // Scale the container node based on the size of the container.
        containerNode.setScale( m_containmentAreaWidth / containerNode.getFullBoundsReference().width );

        // Add the image to the top layer node.
        m_topContainerLayer.addChild( containerNode );
        containerNode.setOffset( 0, 0 );

        // Add the lid of the container.
        m_containerLid = StatesOfMatterResources.getImageNode( LID_IMAGE_NAME );
        m_containerLid.setScale( m_containmentAreaWidth / m_containerLid.getFullBoundsReference().width );
        m_containerLid.setPickable( false );
        m_middleContainerLayer.addChild( m_containerLid );
        m_containerLid.setOffset( 0, ( -m_containerLid.getFullBoundsReference().height / 2 ) + LID_POSITION_TWEAK_FACTOR );

        if ( LOAD_CONTAINER_BACKGROUND_IMAGE ) {
            // Load the image that will be used for the back of the container.
            PImage containerBackImageNode = StatesOfMatterResources.getImageNode( CONTAINER_BACK_IMAGE_NAME );

            // Scale the container image based on the size of the container.
            containerBackImageNode.setScale( m_containmentAreaWidth / containerBackImageNode.getFullBoundsReference().width );

            // Add the image to the bottom layer node.
            m_bottomContainerLayer.addChild( containerBackImageNode );
            containerBackImageNode.setOffset( 0, -( m_model.getParticleContainerHeight() * ELLIPSE_HEIGHT_PROPORTION / 2 ) );
        }
        else {
            // Just load an image for the back of the top.
            PImage containerTopBackImageNode = StatesOfMatterResources.getImageNode( CONTAINER_BACK_TOP_IMAGE_NAME );

            // Scale the container image based on the size of the container.
            containerTopBackImageNode.setScale( m_containmentAreaWidth / containerTopBackImageNode.getFullBoundsReference().width );

            // Add the image to the bottom layer node.
            m_bottomContainerLayer.addChild( containerTopBackImageNode );
            containerTopBackImageNode.setOffset( 0, -( m_model.getParticleContainerHeight() * ELLIPSE_HEIGHT_PROPORTION / 2 ) );
        }
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:59,代码来源:ParticleContainerNode.java


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