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


Java PActivity.startAfter方法代码示例

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


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

示例3: initialize

import edu.umd.cs.piccolo.activities.PActivity; //导入方法依赖的package包/类
public void initialize() {
    final PLayer layer = getCanvas().getLayer();

    final PNode a = PPath.createRectangle(0, 0, 100, 80);
    final PNode b = PPath.createRectangle(0, 0, 100, 80);

    layer.addChild(a);
    layer.addChild(b);

    final PActivity a1 = a.animateToPositionScaleRotation(200, 200, 1, 0, 5000);
    final PActivity a2 = b.animateToPositionScaleRotation(200, 200, 1, 0, 5000);

    a2.startAfter(a1);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:15,代码来源:WaitForActivitiesExample.java

示例4: initialize

import edu.umd.cs.piccolo.activities.PActivity; //导入方法依赖的package包/类
public void initialize() {
    final long currentTime = System.currentTimeMillis();

    // Create a new node that we will apply different activities to, and
    // place that node at location 200, 200.
    final PNode aNode = PPath.createRectangle(0, 0, 100, 80);
    final PLayer layer = getCanvas().getLayer();
    layer.addChild(aNode);
    aNode.setOffset(200, 200);

    // Create a new custom "flash" activity. This activity will start
    // running in five seconds, and while it runs it will flash aNode's
    // paint between red and green every half second.
    final PActivity flash = new PActivity(-1, 500, currentTime + 5000) {
        boolean fRed = true;

        protected void activityStep(final long elapsedTime) {
            super.activityStep(elapsedTime);

            if (fRed) {
                aNode.setPaint(Color.red);
            }
            else {
                aNode.setPaint(Color.green);
            }

            fRed = !fRed;
        }
    };

    // An activity will not run unless it is scheduled with the root. Once
    // it has been scheduled it will be given a chance to run during the
    // next PRoot.processInputs() call.
    getCanvas().getRoot().addActivity(flash);

    // Use the PNode animate methods to create three activities that animate
    // the node's position. Since our node already descends from the root
    // node the animate methods will automatically schedule these activities
    // for us.
    final PActivity a1 = aNode.animateToPositionScaleRotation(0, 0, 0.5, 0, 5000);
    final PActivity a2 = aNode.animateToPositionScaleRotation(100, 0, 1.5, Math.toRadians(110), 5000);
    final PActivity a3 = aNode.animateToPositionScaleRotation(200, 100, 1, 0, 5000);
    final PActivity a4 = aNode.animateToTransparency(0.25f, 3000);

    // the animate activities will start immediately (in the next call to
    // PRoot.processInputs) by default. Here we set their start times (in
    // PRoot global time) so that they start when the previous one has
    // finished.
    a1.setStartTime(currentTime);

    a2.startAfter(a1);
    a3.startAfter(a2);
    a4.startAfter(a3);

    // or the previous three lines could be replaced with these lines for
    // the same effect.
    // a2.setStartTime(currentTime + 5000);
    // a3.setStartTime(currentTime + 10000);
    // a4.setStartTime(currentTime + 15000);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:61,代码来源:ActivityExample.java


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