Package com.google.gwt.touch.client.Momentum

Examples of com.google.gwt.touch.client.Momentum.State


   * Test updating the state before the acceleration falls below the minimum
   * acceleration.
   */
  public void testUpdateStateFast() {
    DefaultMomentum momentum = new DefaultMomentum();
    State state = momentum.createState(new Point(0.0, 0.0), new Point(1.0, 2.0));
    state.setPosition(new Point(0.1, 0.2));
    state.setCumulativeElapsedMillis(10);
    state.setElapsedMillis(5);

    assertTrue(momentum.updateState(state));

    // Check the new velocity.
    Point velocity = state.getVelocity();
    assertEquals(0.99302, velocity.getX(), 0.000009); // 1.0 * .9993 ^ 10
    assertEquals(1.98604, velocity.getY(), 0.000009); // 2.0 * .9993 ^ 10

    // Check the new position.
    Point position = state.getPosition();
    assertEquals(5.0651, position.getX(), 0.0001); // .1 + v * 5ms
    assertEquals(10.1302, position.getY(), 0.0001); // .2 + v * 5ms5
  }
View Full Code Here


   * Test updating the state after the X acceleration falls below the minimum
   * acceleration.
   */
  public void testUpdateStateSlowX() {
    DefaultMomentum momentum = new DefaultMomentum();
    State state = momentum.createState(new Point(0.0, 0.0), new Point(0.005, 1.0));
    state.setPosition(new Point(0.2, 0.1));
    state.setCumulativeElapsedMillis(10);
    state.setElapsedMillis(5);

    assertTrue(momentum.updateState(state));

    // Check the new velocity.
    Point velocity = state.getVelocity();
    assertEquals(0.0025, velocity.getX(), 0.0001); // 0.005 - 0.0005 * 5
    assertEquals(0.99302, velocity.getY(), 0.000009); // 1.0 * .9993 ^ 10

    // Check the new position.
    Point position = state.getPosition();
    assertEquals(0.2125, position.getX(), 0.0001); // .2 + v * 5ms
    assertEquals(5.0651, position.getY(), 0.0001); // .1 + v * 5ms
  }
View Full Code Here

   * Test updating the state after the Y acceleration falls below the minimum
   * acceleration.
   */
  public void testUpdateStateSlowY() {
    DefaultMomentum momentum = new DefaultMomentum();
    State state = momentum.createState(new Point(0.0, 0.0), new Point(1.0, 0.005));
    state.setPosition(new Point(0.1, 0.2));
    state.setCumulativeElapsedMillis(10);
    state.setElapsedMillis(5);

    assertTrue(momentum.updateState(state));

    // Check the new velocity.
    Point velocity = state.getVelocity();
    assertEquals(0.99302, velocity.getX(), 0.000009); // 1.0 * .9993 ^ 10
    assertEquals(0.0025, velocity.getY(), 0.0001); // 0.005 - 0.0005 * 5

    // Check the new position.
    Point position = state.getPosition();
    assertEquals(5.0651, position.getX(), 0.0001); // .1 + v * 5ms
    assertEquals(0.2125, position.getY(), 0.0001); // .2 + v * 5ms
  }
View Full Code Here

  /**
   * Test updating the state returns null when we reach the minimum velocity.
   */
  public void testUpdateStateMinimumVelociy() {
    DefaultMomentum momentum = new DefaultMomentum();
    State state = momentum.createState(new Point(0.0, 0.0), new Point(0.02, 0.02));
    state.setPosition(new Point(0.1, 0.2));
    state.setCumulativeElapsedMillis(10);
    state.setElapsedMillis(5);

    assertFalse(momentum.updateState(state));
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.touch.client.Momentum.State

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.