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


Java PNode.scale方法代码示例

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


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

示例1: initialize

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public void initialize() {
    final PNode n1 = PPath.createRectangle(0, 0, 100, 80);
    final PNode n2 = PPath.createRectangle(0, 0, 100, 80);

    getCanvas().getLayer().addChild(n1);
    getCanvas().getLayer().addChild(n2);

    n2.scale(2.0);
    n2.rotate(Math.toRadians(90));
    // n2.setScale(2.0);
    // n2.setScale(1.0);
    n2.scale(0.5);
    n2.setPaint(Color.red);

    n1.offset(100, 0);
    n2.offset(100, 0);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:18,代码来源:PositionExample.java

示例2: SettingsNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public SettingsNode( final LineGameModel model, Dimension2D stageSize ) {

        // the standard game settings panel
        PNode panelNode = new PSwing( new GameSettingsPanel( model.settings,
                                                             new VoidFunction0() {
                                                                 public void apply() {
                                                                     model.phase.set( GamePhase.PLAY );
                                                                 }
                                                             },
                                                             LineGameConstants.BUTTON_COLOR ) );
        panelNode.scale( 1.5 );
        addChild( panelNode );

        // centered on stage
        setOffset( ( stageSize.getWidth() - getFullBoundsReference().getWidth() ) / 2,
                   ( stageSize.getHeight() - getFullBoundsReference().getHeight() ) / 2 );
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:18,代码来源:SettingsNode.java

示例3: createIcon

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public static Icon createIcon( double width ) {

        PNode parentNode = new PadBoundsNode();

        LineFormsModel model = new SlopeInterceptModel();
        model.interactiveLine.set( Line.createSlopeIntercept( 1, 2, 0 ) ); // bigger values will make slope tool look smaller in icon

        // slope tool
        SlopeToolNode slopeToolNode = new SlopeToolNode( model.interactiveLine, model.mvt );
        parentNode.addChild( slopeToolNode );

        // dashed line where the line would be, tweaked visually
        PPath lineNode = new PPath( new Line2D.Double( slopeToolNode.getFullBoundsReference().getMinX() + ( 0.4 * slopeToolNode.getFullBoundsReference().getWidth() ), slopeToolNode.getFullBoundsReference().getMaxY(),
                                                       slopeToolNode.getFullBoundsReference().getMaxX(), slopeToolNode.getFullBoundsReference().getMinY() + ( 0.5 * slopeToolNode.getFullBoundsReference().getHeight() ) ) );
        lineNode.setStroke( new BasicStroke( 1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 6, 6 }, 0 ) );
        parentNode.addChild( lineNode );

        // scale and convert to image
        parentNode.scale( width / parentNode.getFullBoundsReference().getWidth() );
        return new ImageIcon( parentNode.toImage() );
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:SlopeToolNode.java

示例4: initialize

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public void initialize() {
    final PComposite composite = new PComposite();

    final PNode circle = PPath.createEllipse(0, 0, 100, 100);
    final PNode rectangle = PPath.createRectangle(50, 50, 100, 100);
    final PNode text = new PText("Hello world!");

    composite.addChild(circle);
    composite.addChild(rectangle);
    composite.addChild(text);

    rectangle.rotate(Math.toRadians(45));
    rectangle.setPaint(Color.RED);

    text.scale(2.0);
    text.setPaint(Color.GREEN);

    getCanvas().getLayer().addChild(composite);
    getCanvas().removeInputEventListener(getCanvas().getPanEventHandler());
    getCanvas().addInputEventListener(new PDragEventHandler());
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:CompositeExample.java

示例5: addAlpha

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void addAlpha( PNode nucleus, double radius, double pixelsPerFm ) {

        PNode alphaParticle = new AlphaParticleNode();
        alphaParticle.scale( pixelsPerFm );
        PImage alphaParticleImage = new PImage( alphaParticle.toImage() );
        setParticlePosition( radius, alphaParticleImage, pixelsPerFm );
        nucleus.addChild( alphaParticleImage );

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

示例6: addNeutron

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void addNeutron( PNode nucleus, double radius, double pixelsPerFm ) {

        PNode neutron = new StandaloneNeutronNode();
        neutron.scale( pixelsPerFm );
        PImage neutronImage = new PImage( neutron.toImage() );
        setParticlePosition( radius, neutronImage, pixelsPerFm );
        nucleus.addChild( neutronImage );

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

示例7: addProton

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void addProton( PNode nucleus, double radius, double pixelsPerFm ) {

        PNode proton = new StandaloneProtonNode();
        proton.scale( pixelsPerFm );
        PImage protonImage = new PImage( proton.toImage() );
        setParticlePosition( radius, protonImage, pixelsPerFm );
        nucleus.addChild( protonImage );
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:NucleusImageFactory.java

示例8: BetaDecayLegendPanel

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public BetaDecayLegendPanel(){
	
    // Add the border around the legend.
    BevelBorder baseBorder = (BevelBorder)BorderFactory.createRaisedBevelBorder();
    TitledBorder titledBorder = BorderFactory.createTitledBorder( baseBorder,
            NuclearPhysicsStrings.LEGEND_BORDER_LABEL,
            TitledBorder.LEFT,
            TitledBorder.TOP,
            new PhetFont( Font.BOLD, 14 ),
            Color.GRAY );
    
    setBorder( titledBorder );
    
    // Set the layout.
    setLayout( new GridBagLayout() );

    // Add the images and labels that comprise the legend.
    
    PNode neutron = new StandaloneNeutronNode();
    neutron.scale( PARTICLE_SCALE_FACTOR );
    addLegendItem( neutron.toImage(), NuclearPhysicsStrings.NEUTRON_LEGEND_LABEL ); 
    PNode proton = new StandaloneProtonNode();
    proton.scale( PARTICLE_SCALE_FACTOR );
    addLegendItem( proton.toImage(), NuclearPhysicsStrings.PROTON_LEGEND_LABEL ); 
    PNode electron = new ElectronNode();
    electron.scale( PARTICLE_SCALE_FACTOR );
    addLegendItem( electron.toImage(), NuclearPhysicsStrings.ELECTRON_LEGEND_LABEL );
    PNode antineutrino = new AntineutrinoNode();
    antineutrino.scale( PARTICLE_SCALE_FACTOR );
    addLegendItem( antineutrino.toImage(), NuclearPhysicsStrings.ANTINEUTRINO_LEGEND_LABEL );
    
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:33,代码来源:BetaDecayLegendPanel.java

示例9: NuclearReactorLegendPanel

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public NuclearReactorLegendPanel() {
    
    // Add the border around the legend.
    BevelBorder baseBorder = (BevelBorder)BorderFactory.createRaisedBevelBorder();
    TitledBorder titledBorder = BorderFactory.createTitledBorder( baseBorder,
            NuclearPhysicsStrings.LEGEND_BORDER_LABEL,
            TitledBorder.LEFT,
            TitledBorder.TOP,
            new PhetFont( Font.BOLD, 14 ),
            Color.GRAY );
    
    setBorder( titledBorder );
    
    // Set the layout.
    setLayout( new GridLayout(0, 2) );

    // Add the images and labels for the simple portion of the legend.
    
    PNode neutron = new StandaloneNeutronNode();
    neutron.scale( PARTICLE_SCALE_FACTOR );
    addLegendItem( neutron.toImage(), NuclearPhysicsStrings.NEUTRON_LEGEND_LABEL ); 
    
    // Add the Uranium 235 nucleus to the legend.
    // Add the Uranium 235 nucleus to the legend.
    PNode labeledU235Nucleus = new LabeledNucleusImageNode("uranium-nucleus-small.png",
            NuclearPhysicsStrings.URANIUM_235_ISOTOPE_NUMBER, 
            NuclearPhysicsStrings.URANIUM_235_CHEMICAL_SYMBOL, 
            NuclearPhysicsConstants.URANIUM_235_LABEL_COLOR );
    
    Image u235Image = labeledU235Nucleus.toImage();
    ImageIcon icon = new ImageIcon(u235Image);
    add(new JLabel(icon));
    add(new JLabel( NuclearPhysicsStrings.URANIUM_235_LEGEND_LABEL ) );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:35,代码来源:NuclearReactorLegendPanel.java

示例10: createHierarchy

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public PNode createHierarchy(final int level) {
    final PPath result = PPath.createRectangle(0, 0, 100, 100);

    if (level > 0) {
        final PNode child = createHierarchy(level - 1);
        child.scale(0.5);
        result.addChild(child);
        child.offset(25, 25);
    }

    return result;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:HierarchyZoomExample.java

示例11: main

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public static void main( String[] args ) {
    {
        PNode node = new PNode();
        System.out.println( node.getTransform() );

        node.scale( 2 );
        System.out.println( node.getTransform() );

        node.translate( 1, 3 );
        System.out.println( node.getTransform() );

        node.rotate( Math.PI / 2 );
        System.out.println( node.getTransform() );

        node.translate( -31, 21 );
        System.out.println( node.getTransform() );
        System.out.println( node.getOffset().getX() );
        System.out.println( node.getOffset().getY() );
        System.out.println( node.getRotation() );

        node.setOffset( -5, 7 );
        System.out.println( node.getTransform() );

        node.setRotation( 1.2 );
        System.out.println( node.getTransform() );

        node.setRotation( -0.7 );
        System.out.println( node.getTransform() );
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:31,代码来源:PiccoloTesting.java

示例12: composeOtherNodes

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public void composeOtherNodes() {
    final PNode myCompositeFace = PPath.createRectangle(0, 0, 100, 80);

    // create parts for the face.
    final PNode eye1 = PPath.createEllipse(0, 0, 20, 20);
    eye1.setPaint(Color.YELLOW);
    final PNode eye2 = (PNode) eye1.clone();
    final PNode mouth = PPath.createRectangle(0, 0, 40, 20);
    mouth.setPaint(Color.BLACK);

    // add the face parts
    myCompositeFace.addChild(eye1);
    myCompositeFace.addChild(eye2);
    myCompositeFace.addChild(mouth);

    // don't want anyone grabbing out our eye's.
    myCompositeFace.setChildrenPickable(false);

    // position the face parts.
    eye2.translate(25, 0);
    mouth.translate(0, 30);

    // set the face bounds so that it neatly contains the face parts.
    final PBounds b = myCompositeFace.getUnionOfChildrenBounds(null);
    myCompositeFace.setBounds(b.inset(-5, -5));

    // opps it to small, so scale it up.
    myCompositeFace.scale(1.5);

    getCanvas().getLayer().addChild(myCompositeFace);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:32,代码来源:BirdsEyeViewExample.java

示例13: addLabelToContainer

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public void addLabelToContainer( PNode label ) {
    if ( label.getFullBoundsReference().getWidth() > scaledContainerShape.getBounds().getWidth() * 0.8 ) {
        // The caption must be scaled in order to fit on the container.
        label.scale( scaledContainerShape.getBounds().getWidth() * 0.8 / label.getFullBoundsReference().getWidth() );
    }
    label.setOffset(
            scaledContainerShape.getBounds2D().getCenterX() - label.getFullBoundsReference().getWidth() / 2,
            scaledContainerShape.getBounds2D().getCenterY() - label.getFullBoundsReference().getHeight() / 2 );
    containerLayer.addChild( label );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:11,代码来源:BucketView.java

示例14: ChainReactionLegendPanel

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

        // Add the border around the legend.
        BevelBorder baseBorder = (BevelBorder)BorderFactory.createRaisedBevelBorder();
        TitledBorder titledBorder = BorderFactory.createTitledBorder( baseBorder,
                NuclearPhysicsStrings.LEGEND_BORDER_LABEL,
                TitledBorder.LEFT,
                TitledBorder.TOP,
                new PhetFont( Font.BOLD, 14 ),
                Color.GRAY );

        setBorder( titledBorder );

        // Set the layout.
        setLayout( new GridLayout(0, 2) );

        // Add the images and labels for the simple portion of the legend.
        PNode neutron = new StandaloneNeutronNode();
        neutron.scale( PARTICLE_SCALE_FACTOR );
        addLegendItem( neutron.toImage(), NuclearPhysicsStrings.NEUTRON_LEGEND_LABEL );
        PNode proton = new StandaloneProtonNode();
        proton.scale( PARTICLE_SCALE_FACTOR );
        addLegendItem( proton.toImage(), NuclearPhysicsStrings.PROTON_LEGEND_LABEL );

        // Add the Uranium 235 nucleus to the legend.
        PNode labeledU235Nucleus = new LabeledNucleusImageNode("uranium-nucleus-small.png",
                NuclearPhysicsStrings.URANIUM_235_ISOTOPE_NUMBER,
                NuclearPhysicsStrings.URANIUM_235_CHEMICAL_SYMBOL,
                NuclearPhysicsConstants.URANIUM_235_LABEL_COLOR );

        Image u235Image = labeledU235Nucleus.toImage();
        ImageIcon icon = new ImageIcon(u235Image);
        add(new JLabel(icon));
        add(new JLabel( NuclearPhysicsStrings.URANIUM_235_LEGEND_LABEL ) );

        // Add the Uranium 238 nucleus to the legend.
        PNode labeledU238Nucleus = new LabeledNucleusImageNode("uranium-nucleus-small.png",
                NuclearPhysicsStrings.URANIUM_238_ISOTOPE_NUMBER,
                NuclearPhysicsStrings.URANIUM_238_CHEMICAL_SYMBOL,
                NuclearPhysicsConstants.URANIUM_238_LABEL_COLOR );

        Image u238Image = labeledU238Nucleus.toImage();
        icon = new ImageIcon(u238Image);
        add(new JLabel(icon));
        add(new JLabel( NuclearPhysicsStrings.URANIUM_238_LEGEND_LABEL ) );

        // Add the Uranium 238 nucleus to the legend.
        PNode labeledU239Nucleus = new LabeledNucleusImageNode("uranium-nucleus-small.png",
                NuclearPhysicsStrings.URANIUM_239_ISOTOPE_NUMBER,
                NuclearPhysicsStrings.URANIUM_239_CHEMICAL_SYMBOL,
                NuclearPhysicsConstants.URANIUM_239_LABEL_COLOR );

        Image u239Image = labeledU239Nucleus.toImage();
        icon = new ImageIcon(u239Image);
        add(new JLabel(icon));
        add(new JLabel( NuclearPhysicsStrings.URANIUM_239_LEGEND_LABEL ) );

        // Add the daughter nuclei to the legend.
        addLegendItem( "daughter-nuclei-small.png", NuclearPhysicsStrings.DAUGHTER_NUCLEI_LABEL, 75 );
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:61,代码来源:ChainReactionLegendPanel.java

示例15: FissionOneNucleusLegendPanel

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

        // Add the border around the legend.
        BevelBorder baseBorder = (BevelBorder)BorderFactory.createRaisedBevelBorder();
        TitledBorder titledBorder = BorderFactory.createTitledBorder( baseBorder,
                NuclearPhysicsStrings.LEGEND_BORDER_LABEL,
                TitledBorder.LEFT,
                TitledBorder.TOP,
                new PhetFont( Font.BOLD, 14 ),
                Color.GRAY );

        setBorder( titledBorder );

        // Set the layout.
        setLayout( new GridLayout(0, 2) );

        // Add the images and labels for the simple portion of the legend.

        PNode neutron = new StandaloneNeutronNode();
        neutron.scale( PARTICLE_SCALE_FACTOR );
        addLegendItem( neutron.toImage(), NuclearPhysicsStrings.NEUTRON_LEGEND_LABEL );
        PNode proton = new StandaloneProtonNode();
        proton.scale( PARTICLE_SCALE_FACTOR );
        addLegendItem( proton.toImage(), NuclearPhysicsStrings.PROTON_LEGEND_LABEL );

        // Add the Uranium nucleus to the legend.

        PNode labeledUraniumNucleus = new LabeledNucleusImageNode("uranium-nucleus-small.png",
                NuclearPhysicsStrings.URANIUM_235_ISOTOPE_NUMBER,
                NuclearPhysicsStrings.URANIUM_235_CHEMICAL_SYMBOL,
                NuclearPhysicsConstants.URANIUM_235_LABEL_COLOR );

        Image uraniumImage = labeledUraniumNucleus.toImage();
        ImageIcon icon = new ImageIcon(uraniumImage);
        add(new JLabel(icon));
        add(new JLabel( NuclearPhysicsStrings.URANIUM_235_LEGEND_LABEL ) );

        // Add the daughter nuclei to the legend.  These are not specifically
        // labeled with chemical symbols because the products from a fission
        // of U-235 can vary.

        addLegendItem( "daughter-nuclei-small.png", NuclearPhysicsStrings.DAUGHTER_NUCLEI_LABEL, 75 );
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:44,代码来源:FissionOneNucleusLegendPanel.java


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