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


Java PNode.rotate方法代码示例

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


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

示例1: createCoilGraphics

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Creates the graphics for the coils
 *
 * @param bounds
 */
private void createCoilGraphics( Rectangle2D bounds ) {
    double baseDim = magnet.getOrientation() == GradientElectromagnet.HORIZONTAL ? bounds.getWidth() : bounds.getHeight();
    double coilWidth = baseDim / numSegments;
    for( int i = 0; i < coilsGraphics.length; i++ ) {
        PNode coilGraphic = null;
        double xLoc = i * coilWidth;
        if( magnet.getOrientation() == GradientElectromagnet.HORIZONTAL ) {
            coilGraphic = PImageFactory.create( MriResources.getImage( MriConfig.COIL_IMAGE ), new Dimension( (int)coilWidth, (int)bounds.getHeight() ) );
            coilGraphic.setOffset( xLoc, 0 );
        }
        else {
            coilGraphic = PImageFactory.create( MriResources.getImage( MriConfig.COIL_IMAGE ), new Dimension( (int)coilWidth, (int)bounds.getWidth() ) );
            coilGraphic.rotate( Math.PI / 2 );
            coilGraphic.translate( xLoc, -bounds.getWidth() );
        }
        addChild( coilGraphic );
        coilsGraphics[i] = coilGraphic;
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:25,代码来源:GradientMagnetGraphic.java

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

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

示例4: IonsAndChannelsLegendPanel

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public IonsAndChannelsLegendPanel() {
    
    // Add the border around the legend.
    BevelBorder baseBorder = (BevelBorder)BorderFactory.createRaisedBevelBorder();
    TitledBorder titledBorder = BorderFactory.createTitledBorder( baseBorder,
            NeuronStrings.LEGEND_TITLE,
            TitledBorder.LEFT,
            TitledBorder.TOP,
            NeuronConstants.CONTROL_PANEL_TITLE_FONT,
            Color.GRAY );
    
    setBorder( titledBorder );
    
    // Set the layout.
    setLayout( new GridBagLayout() );

    // Add the images and labels for the ions.
    int row = 0;
	PNode imageNode = new ParticleNode(new SodiumIon(), PARTICLE_MVT);
	addLegendItem( imageNode.toImage(), NeuronStrings.LEGEND_SODIUM_ION, row++ );
    		
	imageNode = new ParticleNode(new PotassiumIon(), PARTICLE_MVT);
	addLegendItem( imageNode.toImage(), NeuronStrings.LEGEND_POTASSIUM_ION, row++ );

	imageNode = new MembraneChannelNode(new SodiumDualGatedChannel(), CHANNEL_MVT);
	imageNode.rotate(-Math.PI / 2);
	addLegendItem( imageNode.toImage(), NeuronStrings.LEGEND_SODIUM_GATED_CHANNEL, row++ );

	imageNode = new MembraneChannelNode(new PotassiumGatedChannel(), CHANNEL_MVT);
	imageNode.rotate(-Math.PI / 2);
	addLegendItem( imageNode.toImage(), NeuronStrings.LEGEND_POTASSIUM_GATED_CHANNEL, row++ );

	imageNode = new MembraneChannelNode(new SodiumLeakageChannel(), CHANNEL_MVT);
	imageNode.rotate(-Math.PI / 2);
	addLegendItem( imageNode.toImage(), NeuronStrings.LEGEND_SODIUM_LEAK_CHANNEL, row++ );

	imageNode = new MembraneChannelNode(new PotassiumLeakageChannel(), CHANNEL_MVT);
	imageNode.rotate(-Math.PI / 2);
	addLegendItem( imageNode.toImage(), NeuronStrings.LEGEND_POTASSIUM_LEAK_CHANNEL, row++ );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:41,代码来源:IonsAndChannelsLegendPanel.java

示例5: ReactionArrowNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public ReactionArrowNode( Paint arrowColor ) {
    PNode topNode = new HalfArrowNode();
    PNode bottomNode = new HalfArrowNode();
    bottomNode.rotate( Math.PI );
    bottomNode.setOffset( ARROW_LENGTH, topNode.getFullBoundsReference().getMaxY() + 7 );
    addChild( topNode );
    addChild( bottomNode );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:ReactionArrowNode.java

示例6: SparkleNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public SparkleNode( Paint paint, double diameter, double angle ) {
    PNode bigCrosshairs = new CrosshairsNode( paint, diameter );
    PNode smallCrosshairs = new CrosshairsNode( paint, 0.7 * diameter );
    smallCrosshairs.rotate( Math.toRadians( 45 ) );
    addChild( smallCrosshairs );
    addChild( bigCrosshairs );
    rotate( angle );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:PhotonNode.java

示例7: TestDraggingInDifferentFrames

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public TestDraggingInDifferentFrames() {
    final PhetPCanvas contentPane = new PhetPCanvas();
    contentPane.setZoomEventHandler( new PZoomEventHandler() );
    frame.setContentPane( contentPane );
    frame.setSize( 1024, 768 );

    BoxNode boxNode = new BoxNode();
    contentPane.addScreenChild( boxNode );

    PNode rotateFrame = new PNode();
    rotateFrame.rotate( Math.PI / 2 );
    rotateFrame.translate( 0, -300 );
    rotateFrame.addChild( new BoxNode() );
    contentPane.addScreenChild( rotateFrame );

    PNode offsetFrame = new PNode();
    offsetFrame.setOffset( 200, 200 );
    offsetFrame.addChild( new BoxNode() );

    PNode offsetScaleNode = new PNode();
    offsetScaleNode.setOffset( 0, 200 );
    offsetScaleNode.scale( 2.0 );
    offsetScaleNode.addChild( new BoxNode() );
    contentPane.addScreenChild( offsetScaleNode );

    PNode parentNode = new PNode();
    parentNode.translate( 400, 400 );
    parentNode.scale( 1.2 );
    parentNode.rotate( Math.PI / 12 );
    parentNode.addChild( new BoxNode() );
    contentPane.addScreenChild( parentNode );

    PNode childNode = new PNode();
    childNode.scale( 1.2 );
    childNode.rotate( Math.PI / 6 );
    childNode.translate( 50, 50 );
    childNode.addChild( boxNode );

    parentNode.addChild( childNode );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:41,代码来源:TestDraggingInDifferentFrames.java

示例8: rotateNodes

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public void rotateNodes() {
    final Iterator i = getCanvas().getLayer().getChildrenReference().iterator();
    while (i.hasNext()) {
        final PNode each = (PNode) i.next();
        each.rotate(Math.toRadians(2));
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:DynamicExample.java

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

示例10: PointToolNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * This constructor creates a node that is independent of the model.
 * This was needed so that we could easily generate images of the point tool, for inclusion in the game reward.
 */
public PointToolNode( Vector2D point, Orientation orientation, Color background ) {

    // tool body
    bodyNode = new PImage( Images.POINT_TOOL_BODY );

    /*
     * Pointy tip, separate from the body and not pickable.
     * Because Piccolo's picking bounds are rectangular, making the tip pickable made it difficult
     * to pick a line manipulator when the tip and manipulator were on the same grid point.
     * Making the tip non-pickable was determined to be an acceptable and "natural feeling" solution.
     */
    PNode tipNode = new PImage( Images.POINT_TOOL_TIP );
    tipNode.setPickable( false );

    // background behind the displayed value, shows through a transparent hole in the display area portion of the body image
    final int backgroundMargin = 5;
    backgroundNode = new PPath( new Rectangle2D.Double( 0, 0,
                                                        bodyNode.getFullBoundsReference().getWidth() - ( 2 * backgroundMargin ),
                                                        bodyNode.getFullBoundsReference().getHeight() - ( 2 * backgroundMargin ) ) );
    backgroundNode.setStroke( null );
    backgroundNode.setOffset( bodyNode.getOffset() );
    backgroundNode.setPickable( false );

    // displayed value
    valueNode = new PText( "?" );
    valueNode.setFont( new PhetFont( Font.BOLD, 15 ) );
    valueNode.setPickable( false );

    // rendering order
    addChild( tipNode );
    addChild( backgroundNode );
    addChild( bodyNode );
    addChild( valueNode );

    // orientation
    if ( orientation == Orientation.DOWN ) {
        tipNode.setOffset( -tipNode.getFullBoundsReference().getWidth() / 2, -tipNode.getFullBoundsReference().getHeight() );
        bodyNode.setOffset( -bodyNode.getFullBoundsReference().getWidth() / 2, tipNode.getFullBoundsReference().getMinY() - bodyNode.getFullBoundsReference().getHeight() );
        backgroundNode.setOffset( bodyNode.getXOffset() + backgroundMargin, bodyNode.getYOffset() + backgroundMargin );
        valueNode.setOffset( 0, bodyNode.getFullBoundsReference().getMinY() + COORDINATES_Y_CENTER - ( valueNode.getFullBoundsReference().getHeight() / 2 ) );
    }
    else {
        tipNode.rotate( Math.PI );
        tipNode.setOffset( tipNode.getFullBoundsReference().getWidth() / 2, tipNode.getFullBoundsReference().getHeight() );
        bodyNode.setOffset( -bodyNode.getFullBoundsReference().getWidth() / 2, tipNode.getFullBoundsReference().getMaxY() );
        backgroundNode.setOffset( bodyNode.getFullBoundsReference().getMinX() + backgroundMargin, bodyNode.getFullBoundsReference().getMinY() + backgroundMargin );
        valueNode.setOffset( 0, bodyNode.getFullBoundsReference().getMaxY() - COORDINATES_Y_CENTER - ( valueNode.getFullBoundsReference().getHeight() / 2 ) );
    }

    // default state
    setCoordinates( point );
    setBackground( background );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:58,代码来源:PointToolNode.java

示例11: InjectorNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public InjectorNode( double rotationAngle, final SimpleObserver inject ) {
    this.inject = inject;

    // Create the root node to which the various constituent parts can be
    // added.
    injectorNode = new PNode();

    // Load the graphic images for this device.  These are offset in order
    // to make the center of rotation be the center of the bulb.
    BufferedImage injectorBodyImage = RESOURCES.getImage( "squeezer_background.png" );
    PNode injectorBodyImageNode = new PImage( injectorBodyImage );
    Rectangle2D originalBodyBounds = injectorBodyImageNode.getFullBounds();
    injectorBodyImageNode.setOffset( -originalBodyBounds.getWidth() / 2, -originalBodyBounds.getHeight() / 2 );
    injectorNode.addChild( injectorBodyImageNode );

    pressedButtonImage = RESOURCES.getImage( "button_pressed.png" );
    unpressedButtonImage = RESOURCES.getImage( "button_unpressed.png" );
    buttonImageNode = new PImage( unpressedButtonImage );
    buttonImageNode.setOffset( BUTTON_OFFSET );
    injectorNode.addChild( buttonImageNode );

    // Rotate and scale the image node as a whole.
    double scale = INJECTOR_HEIGHT / injectorBodyImageNode.getFullBoundsReference().height;
    injectorNode.rotate( -rotationAngle );
    injectorNode.scale( scale );

    // Add the injector image node.  Note that the position has to be
    // tweaked in order to account for the rotation of the node image,
    // since the rotation of the square image enlarges the bounds.
    injectorNode.setOffset( -Math.abs( Math.sin( rotationAngle * 2 ) ) * 30, 0 );
    addChild( injectorNode );

    // Set up the injection point offset. This makes some assumptions
    // about the nature of the image, and will need to be updated if the
    // image is changed.
    distanceCenterToTip = 0.7 * INJECTOR_HEIGHT;
    final double centerOffsetX = 0.4 * INJECTOR_HEIGHT;
    Dimension2D injectionPointOffset = new PDimension();
    injectionPointOffset.setSize( distanceCenterToTip * Math.cos( rotationAngle ) + centerOffsetX,
                                  distanceCenterToTip * Math.sin( -rotationAngle ) );

    // Set up the button handling.
    injectorBodyImageNode.setPickable( false );
    buttonImageNode.setPickable( true );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:46,代码来源:InjectorNode.java

示例12: nodeDemo

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

    // A node needs to be a descendent of the root to be displayed on the
    // screen.
    layer.addChild(aNode);

    // The default color for a node is blue, but you can change that with
    // the setPaint method.
    aNode.setPaint(Color.red);

    // A node can have children nodes added to it.
    aNode.addChild(PPath.createRectangle(0, 0, 100, 80));

    // The base bounds of a node is easy to change. Note that changing the
    // base
    // bounds of a node will not change it's children.
    aNode.setBounds(-10, -10, 200, 110);

    // Each node has a transform that can be used to transform the node, and
    // all its children on the screen.
    aNode.translate(100, 100);
    aNode.scale(1.5);
    aNode.rotate(45);

    // The transparency of any node can be set, this transparency will be
    // applied to any of the nodes children as well.
    aNode.setTransparency(0.75f);

    // Its easy to copy nodes.
    final PNode aCopy = (PNode) aNode.clone();

    // Make is so that the copies children are not pickable. For this
    // example
    // that means you will not be able to grab the child and remove it from
    // its parent.
    aNode.setChildrenPickable(false);

    // Change the look of the copy
    aNode.setPaint(Color.GREEN);
    aNode.setTransparency(1.0f);

    // Let's add the copy to the root, and translate it so that it does not
    // cover the original node.
    layer.addChild(aCopy);
    aCopy.setOffset(0, 0);
    aCopy.rotate(-45);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:50,代码来源:NodeExample.java

示例13: nodeDemo

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

    // A node needs to be a descendent of the root to be displayed on the
    // screen.
    layer.addChild(aNode);

    // The default color for a node is blue, but you can change that with
    // the setPaint method.
    aNode.setPaint(Color.red);

    // A node can have children nodes added to it.
    aNode.addChild(PPath.createRectangle(0, 0, 100, 80));

    // The base bounds of a node is easy to change. Note that changing the
    // base bounds of a node will not change it's children.
    aNode.setBounds(-10, -10, 200, 110);

    // Each node has a transform that can be used to transform the node, and
    // all its children on the screen.
    aNode.translate(100, 100);
    aNode.scale(1.5);
    aNode.rotate(45);

    // The transparency of any node can be set, this transparency will be
    // applied to any of the nodes children as well.
    aNode.setTransparency(0.75f);

    // Its easy to copy nodes.
    final PNode aCopy = (PNode) aNode.clone();

    // Make is so that the copies children are not pickable. For this
    // example that means you will not be able to grab the child and remove
    // it from its parent.
    aNode.setChildrenPickable(false);

    // Change the look of the copy
    aNode.setPaint(Color.GREEN);
    aNode.setTransparency(1.0f);

    // Let's add the copy to the root, and translate it so that it does not
    // cover the original node.
    layer.addChild(aCopy);
    aCopy.setOffset(0, 0);
    aCopy.rotate(-45);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:48,代码来源:BirdsEyeViewExample.java


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