Example usage for com.google.gwt.animation.client AnimationScheduler get

List of usage examples for com.google.gwt.animation.client AnimationScheduler get

Introduction

In this page you can find the example usage for com.google.gwt.animation.client AnimationScheduler get.

Prototype

public static AnimationScheduler get() 

Source Link

Document

Returns the default implementation of the AnimationScheduler API.

Usage

From source file:com.ait.lienzo.client.core.animation.AbstractAnimation.java

License:Open Source License

private final AnimationCallback getAnimationCallback() {
    if (null == m_animate) {
        m_animate = new AnimationCallback() {
            @Override/* ww  w  .j a va  2s. c om*/
            public void execute(double time) {
                doFrame();

                if (isRunning()) {
                    AnimationScheduler.get().requestAnimationFrame(m_animate);
                } else {
                    doClose();
                }
            }
        };
    }
    return m_animate;
}

From source file:com.ait.lienzo.client.core.animation.AbstractAnimation.java

License:Open Source License

@Override
public IAnimationHandle run() {
    if (isRunning()) {
        return this;
    }/*from   w  w w  .j a va2s.c om*/
    m_running = true;

    m_begtime = System.currentTimeMillis();

    doStart();

    AnimationScheduler.get().requestAnimationFrame(getAnimationCallback());

    return this;
}

From source file:com.ait.lienzo.client.core.animation.LayerRedrawManager.java

License:Open Source License

private void kick() {
    if (m_layers.size() > 0) {
        AnimationScheduler.get().requestAnimationFrame(m_redraw);
    }
}

From source file:com.ait.lienzo.client.core.event.AnimationFrameAttributesChangedBatcher.java

License:Open Source License

@Override
protected final void tick() {
    if (m_refire) {
        m_refire = false;

        AnimationScheduler.get().requestAnimationFrame(m_action);
    }
}

From source file:com.ait.lienzo.ks.client.views.components.MandelbrotComponent.java

License:Open Source License

public MandelbrotComponent() {
    doColors();/*from w ww  . j a v a2 s .  co  m*/

    final Layer layer = new Layer();

    m_push.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            m_zoom = 400.0;

            m_xpos = -m_wide / 2;

            m_ypos = -m_high / 2;

            m_xpan = 50.0;

            m_ypan = 50.0;

            draw(layer);
        }
    });
    m_push.setWidth(100);

    getToolBarContainer().add(m_push);

    getLienzoPanel().add(layer);

    layer.addNodeMouseClickHandler(new NodeMouseClickHandler() {
        @Override
        public void onNodeMouseClick(NodeMouseClickEvent event) {
            zoom(event.getX(), event.getY(), event.isShiftKeyDown() ? 1 : 2, false == event.isAltKeyDown());

            draw(layer);
        }
    });
    getWorkingContainer().add(getLienzoPanel());

    AnimationScheduler.get().requestAnimationFrame(getAnimationCallback(layer));
}

From source file:com.ait.lienzo.ks.client.views.components.MandelbrotComponent.java

License:Open Source License

private final AnimationCallback getAnimationCallback(final Layer layer) {
    if (null == m_animate) {
        m_animate = new AnimationCallback() {
            @Override// w w w . j  a  va  2 s.  c  o m
            public void execute(double time) {
                if (init(layer)) {
                    draw(layer);
                } else {
                    AnimationScheduler.get().requestAnimationFrame(m_animate);
                }
            }
        };
    }
    return m_animate;
}

From source file:com.badlogic.gdx.backends.gwt.GwtApplication.java

License:Apache License

void setupLoop() {
    // setup modules
    try {/*from   w ww  . j  a va  2  s  .  co m*/
        graphics = new GwtGraphics(root, config);
    } catch (Throwable e) {
        root.clear();
        root.add(new Label("Sorry, your browser doesn't seem to support WebGL"));
        return;
    }
    lastWidth = graphics.getWidth();
    lastHeight = graphics.getHeight();
    Gdx.app = this;
    Gdx.audio = new GwtAudio();
    Gdx.graphics = graphics;
    Gdx.gl20 = graphics.getGL20();
    Gdx.gl = Gdx.gl20;
    Gdx.files = new GwtFiles(preloader);
    this.input = new GwtInput(graphics.canvas);
    Gdx.input = this.input;
    this.net = new GwtNet();
    Gdx.net = this.net;
    this.clipboard = new GwtClipboard();

    // tell listener about app creation
    try {
        listener.create();
        listener.resize(graphics.getWidth(), graphics.getHeight());
    } catch (Throwable t) {
        error("GwtApplication", "exception: " + t.getMessage(), t);
        t.printStackTrace();
        throw new RuntimeException(t);
    }

    AnimationScheduler.get().requestAnimationFrame(new AnimationCallback() {
        @Override
        public void execute(double timestamp) {
            try {
                mainLoop();
            } catch (Throwable t) {
                error("GwtApplication", "exception: " + t.getMessage(), t);
                throw new RuntimeException(t);
            }
            AnimationScheduler.get().requestAnimationFrame(this, graphics.canvas);
        }
    }, graphics.canvas);
}

From source file:com.emitrom.lienzo.client.core.animation.LayerRedrawManager.java

License:Open Source License

private void kick() {
    if (m_layers.length() > 0) {
        AnimationScheduler.get().requestAnimationFrame(m_redraw);
    }
}

From source file:com.emitrom.lienzo.client.core.shape.Movie.java

License:Open Source License

/**
 * Draws the frames of the video.  If looping has been set, frames are drawn
 * continuously in a loop.//  w w  w. j av  a2  s  .  c o m
 * 
 * @param context
 */
@Override
public boolean prepare(final Context2D context, Attributes attr, double alpha) {
    if (false == m_inits) {
        init();
    }
    if (null != m_error) {
        context.save();

        context.setTextAlign(TextAlign.LEFT);

        context.setTextBaseline(TextBaseLine.ALPHABETIC);

        context.setTextFont("italic 40pt Calibri");

        context.setStrokeColor(ColorName.BLACK);

        context.setStrokeWidth(2);

        context.strokeText(m_error, 0, 0);

        context.restore();
    } else {
        final int wide = getWidth();

        final int high = getHeight();

        m_video.setWidth(wide + "px");

        m_video.setHeight(high + "px");

        m_video.setLoop(isLoop());

        if (false == m_added) {
            m_added = true;

            RootPanel.get().add(m_video);
        }
        m_video.addCanPlayThroughHandler(new CanPlayThroughHandler() {
            @Override
            public void onCanPlayThrough(CanPlayThroughEvent event) {
                play();

                AnimationScheduler.get().requestAnimationFrame(new AnimationCallback() {
                    @Override
                    public void execute(double timestamp) {
                        if (false == m_pause) {
                            context.drawImage(m_video.getElement(), getX(), getY(), getWidth(), getHeight());

                            AnimationScheduler.get().requestAnimationFrame(this);
                        }
                    }
                });
            }
        });
    }
    return false;
}

From source file:com.google.collide.client.util.ResizeController.java

License:Open Source License

private void resizeDragged(int delta) {
    unappliedDelta += delta;/*from www  .  j a v  a  2 s .  co m*/

    /*
     * Give the browser a chance to redraw before applying the next delta.
     * Otherwise, we'll end up locking the browser if the user moves the mouse
     * too quickly.
     */
    if (animationCallback == null) {
        animationCallback = new AnimationCallback() {
            @Override
            public void execute(double arg0) {
                if (this != animationCallback) {
                    // The resize event was already ended.
                    return;
                }
                animationCallback = null;
                applyUnappliedDelta();
            }
        };
        AnimationScheduler.get().requestAnimationFrame(animationCallback);
    }
}