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


Java PActivity类代码示例

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


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

示例1: delete

import edu.umd.cs.piccolo.activities.PActivity; //导入依赖的package包/类
/**
 * Deletes a specified tool.
 * <p>
 * Shows an animation of a tool shrinking towards a point.
 * Then deletes the tool.
 * 
 * @param toolNode the tool to delete
 * @param p a position transformed through the view transform of the bottom camera
 */
public void delete( final AbstractToolNode toolNode, Point2D p ) {
    
    assert ( isInTrash( p ) );
    
    // shrink the tool to the specified point
    final double scale = 0.1;
    final long duration = 300; // ms
    PActivity a1 = toolNode.animateToPositionScaleRotation( p.getX(), p.getY(), scale, toolNode.getRotation(), duration );
    
    // then delete the tool
    PActivity a2 = new PActivity( -1 ) {
        protected void activityStep( long elapsedTime ) {
            _toolProducer.removeTool( toolNode.getTool() );
            terminate(); // ends this activity
        }
    };
    _trashCanNode.addActivity( a2 );
    a2.startAfter( a1 );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:29,代码来源:TrashCanDelegate.java

示例2: ParticleApplication

import edu.umd.cs.piccolo.activities.PActivity; //导入依赖的package包/类
public ParticleApplication() {
    particleModel = new ParticleModel( maxX, maxY );
    particlePanel = new ParticlePanel( particleModel, this );
    frame = new JFrame( "Self-Driven Particles" );
    frame.setContentPane( particlePanel );
    frame.setSize( 900, 600 );
    frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

    particlePanel.getRoot().addActivity( new PActivity( -1 ) {
        protected void activityStep( long elapsedTime ) {
            super.activityStep( elapsedTime );
            particleModel.step( 1.0 );
        }
    } );

    for ( int i = 0; i < 100; i++ ) {
        addParticle();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:ParticleApplication.java

示例3: OrderParameter90

import edu.umd.cs.piccolo.activities.PActivity; //导入依赖的package包/类
public OrderParameter90( BasicTutorialCanvas basicPage ) {
    super( basicPage );

    setText( "Some Dynamical Systems can be characterized by their degree of orderliness.  " +
             "This quantity is termed the 'order parameter'.  " +
             "In this model, the order parameter reflects the similarity of particles' headings.  " +
             "Try to get the order parameter above 0.9" );
    orderParamText = new PText();
    orderParamText.setTextPaint( Color.blue );
    orderParamText.setFont( new PhetFont( 16, true ) );
    decimalFormat = new DecimalFormat( "0.00" );
    activity = new PActivity( -1 ) {
        protected void activityStep( long elapsedTime ) {
            super.activityStep( elapsedTime );
            updateText();
            if ( isOrderParamaterAwesome() ) {
                advance();
            }
        }
    };
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:OrderParameter90.java

示例4: animateCameraViewTransformTo

import edu.umd.cs.piccolo.activities.PActivity; //导入依赖的package包/类
/**
 * Animates the camera's view transform into the provided one over the
 * duration provided.
 * 
 * @param camera camera being animated
 * @param targetTransform the transform to which the camera's transform will
 *            be animated
 * @param duration the number of milliseconds the animation should last
 * 
 * @return an activity object that represents the animation
 */
protected PActivity animateCameraViewTransformTo(final PCamera camera, final AffineTransform targetTransform,
        final int duration) {
    boolean wasOldAnimation = false;

    // first stop any old animations.
    if (navigationActivity != null) {
        navigationActivity.terminate();
        wasOldAnimation = true;
    }

    if (duration == 0) {
        camera.setViewTransform(targetTransform);
        return null;
    }

    final AffineTransform source = camera.getViewTransformReference();

    if (source.equals(targetTransform)) {
        return null;
    }

    navigationActivity = camera.animateViewToTransform(targetTransform, duration);
    navigationActivity.setSlowInSlowOut(!wasOldAnimation);
    return navigationActivity;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:37,代码来源:PNavigationEventHandler.java

示例5: moveCameraOnPath

import edu.umd.cs.piccolo.activities.PActivity; //导入依赖的package包/类
/**
 * Moves along a path
 * @param p the point
 * @param jump true if jumping
 */
public void moveCameraOnPath(Point2D p, boolean jump) {
	Rectangle2D area = hull.getAreaToZoom(p);
	int minZoomHeight = (int)viewedCanvas.getCamera().getHeight();
	if (area.getHeight() < minZoomHeight)
		area.setFrame(area.getX(), area.getCenterY() - minZoomHeight/2, area.getWidth(), minZoomHeight);
 	if (jump || smoothPanning) {
 		// The following allows a camera animation to start while another animation
 		// is already running.
 		if (currentCameraAnimation != null && currentCameraAnimation.isStepping()) {
 			currentCameraAnimation.terminate(PActivity.TERMINATE_WITHOUT_FINISHING);
 		}
 		if (jump) {
 			currentCameraAnimation = viewedCanvas.getCamera().animateViewToCenterBounds(area, true, 300);
 			currentCameraAnimation.setSlowInSlowOut(true);
 		} else {
 			currentCameraAnimation = viewedCanvas.getCamera().animateViewToCenterBounds(area, true, 150);
 			currentCameraAnimation.setSlowInSlowOut(false);
 		}
		// Play one step right now, otherwise nothing will happen while dragging the mouse since animations
 		// won't have time to play.
		currentCameraAnimation.setStartTime(System.currentTimeMillis() - currentCameraAnimation.getStepRate());
		currentCameraAnimation.processStep(System.currentTimeMillis());            		
 	} else
		viewedCanvas.getCamera().setViewBounds(area);
}
 
开发者ID:jdfekete,项目名称:geneaquilt,代码行数:31,代码来源:BirdsEyeView.java

示例6: setViewBounds

import edu.umd.cs.piccolo.activities.PActivity; //导入依赖的package包/类
/**
    * Changes the view bounds of a camera with a smooth animation.
    */
protected void setViewBounds(PCamera camera, PBounds b) {
	if (!smoothPanning) {
		camera.setViewBounds(b);
	} else {
 		// The following allows a camera animation to start while another animation
 		// is already running.
 		if (isAnimatingPan()) {
 			currentCameraAnimation.terminate(PActivity.TERMINATE_WITHOUT_FINISHING);
 		}
			currentCameraAnimation = camera.animateViewToCenterBounds(b, true, 150);
			currentCameraAnimation.setSlowInSlowOut(false);
		// Play one step right now, otherwise nothing will happen while dragging the mouse since animations
 		// won't have time to play.
		currentCameraAnimation.setStartTime(System.currentTimeMillis() - currentCameraAnimation.getStepRate());
		currentCameraAnimation.processStep(System.currentTimeMillis());            		
	}
	}
 
开发者ID:jdfekete,项目名称:geneaquilt,代码行数:21,代码来源:SlidingController.java

示例7: getNumberOfActiveActivities

import edu.umd.cs.piccolo.activities.PActivity; //导入依赖的package包/类
private int getNumberOfActiveActivities() {
    int numberActiveActivities = 0;
    for ( PActivity activity : activities ) {
        if ( activity.isStepping() ) { numberActiveActivities++; }
    }
    return numberActiveActivities;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:PieceNode.java

示例8: terminateActivities

import edu.umd.cs.piccolo.activities.PActivity; //导入依赖的package包/类
public void terminateActivities() {
    for ( PActivity activity : new ArrayList<PActivity>( activities ) ) {
        activities.remove( activity );
        activity.terminate( PActivity.TERMINATE_WITHOUT_FINISHING );
    }
    activities.clear();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:PieceNode.java

示例9: animateToToolboxStack

import edu.umd.cs.piccolo.activities.PActivity; //导入依赖的package包/类
public void animateToToolboxStack( Point2D point, double scale ) {
    animateToPositionScaleRotation( point.getX(), point.getY(), scale, 0, BuildAFractionModule.ANIMATION_TIME ).setDelegate( new CompositeDelegate( new DisablePickingWhileAnimating( this, true ), new PActivityDelegateAdapter() {
        @Override public void activityFinished( final PActivity activity ) {
            super.activityFinished( activity );
            updateExpansionButtonsEnabled();
            context.containerNodeAnimationToToolboxFinished( ContainerNode.this );
        }
    } ) );
    animateToShowSpinners();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:11,代码来源:ContainerNode.java

示例10: animateToPosition

import edu.umd.cs.piccolo.activities.PActivity; //导入依赖的package包/类
private void animateToPosition( final ContainerNode containerNode, final Vector2D position, PActivityDelegate delegate ) {
    containerNode.animateToPositionScaleRotation( position.x, position.y,
                                                  getContainerScale(), 0, BuildAFractionModule.ANIMATION_TIME ).
            setDelegate( new CompositeDelegate( new DisablePickingWhileAnimating( containerNode, true ), delegate, new PActivityDelegateAdapter() {
                @Override public void activityFinished( final PActivity activity ) {
                    containerNode.updateExpansionButtonsEnabled();
                }
            } ) );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:ShapeSceneNode.java

示例11: animateToStackLocation

import edu.umd.cs.piccolo.activities.PActivity; //导入依赖的package包/类
public void animateToStackLocation( Vector2D v, final boolean deleteOnArrival ) {
    animateToPositionScaleRotation( v.x, v.y, 1, 0, BuildAFractionModule.ANIMATION_TIME ).setDelegate( new CompositeDelegate(
            new DisablePickingWhileAnimating( this, true ),
            new UpdateAnimatingFlag( animating ),
            new PActivityDelegateAdapter() {
                @Override public void activityFinished( final PActivity activity ) {
                    if ( deleteOnArrival ) {
                        delete();
                    }
                }
            } ) );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:NumberCardNode.java

示例12: animateTo

import edu.umd.cs.piccolo.activities.PActivity; //导入依赖的package包/类
/**
 * Animates to a point using a specified duration.
 * Animation begins immediately.
 * The animation path is a straight line.
 *
 * @param x
 * @param y
 * @param duration duration in milliseconds
 * @return the PActivity that was scheduled, or null if none was scheduled
 * @throws IllegalStateException if this node is not yet in the Piccolo tree
 */
public PActivity animateTo( final double x, final double y, final long duration ) {
    if ( !started ) {
        if ( getRoot() == null ) {
            throw new IllegalStateException( "node has no root" );
        }
        PActivity activity = animateToPositionScaleRotation( x, y, 1 /*scale*/, 0 /*theta*/, duration );
        return activity;
    }
    else {
        return null;
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:24,代码来源:MotionHelpBalloon.java

示例13: scrollTo

import edu.umd.cs.piccolo.activities.PActivity; //导入依赖的package包/类
private void scrollTo( int index ) {
    if ( index >= 0 && index < kitLayer.getChildrenCount() ) {
        if ( activity != null ) {

            //Terminate without finishing the previous activity so the motion doesn't stutter
            activity.terminate( PActivity.TERMINATE_WITHOUT_FINISHING );
        }
        selectedKit.set( index );
        double x = background.getFullBounds().getWidth() * index;
        activity = kitLayer.animateToPositionScaleRotation( -x, 0, 1, 0, 500 );
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:KitSelectionNode.java

示例14: initialize

import edu.umd.cs.piccolo.activities.PActivity; //导入依赖的package包/类
public void initialize() {
    final PLayer layer = getCanvas().getLayer();
    final PRoot root = getCanvas().getRoot();
    final Random r = new Random();
    for (int i = 0; i < 1000; i++) {
        final PNode n = PPath.createRectangle(0, 0, 100, 80);
        n.translate(10000 * r.nextFloat(), 10000 * r.nextFloat());
        n.setPaint(new Color(r.nextFloat(), r.nextFloat(), r.nextFloat()));
        layer.addChild(n);
    }
    getCanvas().getCamera().animateViewToCenterBounds(layer.getGlobalFullBounds(), true, 0);
    final PActivity a = new PActivity(-1, 20) {
        public void activityStep(final long currentTime) {
            super.activityStep(currentTime);
            rotateNodes();
        }
    };
    root.addActivity(a);

    final PPath p = new PPath();
    p.moveTo(0, 0);
    p.lineTo(0, 1000);
    final PFixedWidthStroke stroke = new PFixedWidthStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10,
            new float[] { 5, 2 }, 0);
    p.setStroke(stroke);
    layer.addChild(p);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:28,代码来源:DynamicExample.java

示例15: OffscreenCanvasExample

import edu.umd.cs.piccolo.activities.PActivity; //导入依赖的package包/类
/**
 * Create a new offscreen canvas example with the specified graphics device.
 * 
 * @param device graphics device
 */
public OffscreenCanvasExample(final GraphicsDevice device) {
    final GraphicsConfiguration configuration = device.getDefaultConfiguration();
    frame = new Frame(configuration);
    frame.setUndecorated(true);
    frame.setIgnoreRepaint(true);
    frame.setBounds(100, 100, 400, 400);
    frame.setVisible(true);
    frame.createBufferStrategy(2);

    canvas = new POffscreenCanvas(400, 400);

    final PText text = new PText("Offscreen Canvas Example");
    text.setFont(text.getFont().deriveFont(32.0f));
    text.setTextPaint(new Color(200, 200, 200));
    text.offset(200.0f - text.getWidth() / 2.0f, 200.0f - text.getHeight() / 2.0f);

    final PPath rect = PPath.createRectangle(0.0f, 0.0f, 360.0f, 360.0f);
    rect.setPaint(new Color(20, 20, 20, 80));
    rect.setStroke(new BasicStroke(2.0f));
    rect.setStrokePaint(new Color(20, 20, 20));
    rect.offset(20.0f, 20.0f);

    canvas.getCamera().getLayer(0).addChild(text);
    canvas.getCamera().getLayer(0).addChild(rect);

    final Rectangle2D right = new Rectangle2D.Double(200.0f, 200.0f, 800.0f, 800.0f);
    final Rectangle2D left = new Rectangle2D.Double(-200.0f, 200.0f, 225.0f, 225.0f);
    final Rectangle2D start = new Rectangle2D.Double(0.0f, 0.0f, 400.0f, 400.0f);
    final PActivity toRight = canvas.getCamera().animateViewToCenterBounds(right, true, 5000);
    final PActivity toLeft = canvas.getCamera().animateViewToCenterBounds(left, true, 5000);
    final PActivity toStart = canvas.getCamera().animateViewToCenterBounds(start, true, 5000);
    toLeft.startAfter(toRight);
    toStart.startAfter(toLeft);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:40,代码来源:OffscreenCanvasExample.java


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