Android Open Source - DroidBallet Horizontal Motion Event






From Project

Back to project page DroidBallet.

License

The source code is released under:

Apache License

If you think the Android project DroidBallet listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.lonepulse.droidballet.listener;
//ww  w.j ava 2 s.  c  o m
/*
 * #%L
 * DroidBallet
 * %%
 * Copyright (C) 2013 Lonepulse
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */


import com.lonepulse.droidballet.filter.SmoothingFilter;

import android.hardware.SensorEvent;
import android.view.ViewGroup;

/**
 * <p>Holds information about a single <i>vertical</i> scroll event which 
 * has been fired on a Widget or {@link ViewGroup}.</i></p>
 * 
 * @version 1.1.0
 * 
 * @author <a href="mailto:lahiru@lonepulse.com">Lahiru Sahan Jayasinghe</a>
 */
public class HorizontalMotionEvent extends AbstractMotionEvent {

  /**
   * <p>Specifies the direction of a {@link HorizontalMotionEvent} with respect to 
   * the <b>sensor coordinates</b>.</p>
   * 
   * <p>More information on the sensor coordinates can be found 
   * <a href="http://developer.android.com/guide/topics/sensors/sensors_overview.html#sensors-coords">here</a>.</p>
   * 
   * @version 1.1.0
   * 
   * @author <a href="mailto:lahiru@lonepulse.com">Lahiru Sahan Jayasinghe</a>
   */
  public static enum HORIZONTAL_DIRECTION {
    
    /**
     * <p>The device orientation is such that there is no deduced 
     * direction of scrolling; i.e. scrolling has stopped and the 
     * widget or {@link ViewGroup} remains stagnant.</p>
     * 
     * <p>This state is assumed when the device is tilted to an angle 
     * which lies within <i>resting range</i>. This range is created 
     * by adding a predetermined magnitude to either side of the medial 
     * position of the <i>sensor range</i>.</p>
     * 
     * <p>For example, if the medial position is {@code 4.5} with a 
     * resting magnitude of {@code 1}, then the <i>resting range</i> 
     * would extend from {@code 3.5} to {@code 5.5}. <i>All values 
     * are in terms of sensor output</i>.</p>
     * 
     * <p>{@link MotionEvent}s of this direction are mapped to 
     * {@link VerticalMotionListener#onMotionRest(VerticalMotionEvent)}</p>.
     * 
     * @since 1.1.0
     */
    NONE,
    
    /**
     * <p>The device orientation is such that the deduced direction 
     * of scrolling is towards the <b>left</b> with respect to the 
     * sensor coordinates.</p>
     * 
     * </p>This direction is assumed when the device is tilted to an 
     * angle which lies between the <i>sensor range <b>upper-bound</b></i> 
     * and the <i>resting range <b>upper-bound</b></i>.
     * 
    * <p>{@link MotionEvent}s of this direction are mapped to 
    * {@link HorizontalMotionListener#onMotionLeft(HorizontalMotionEvent)}</p>.
     * 
     * @since 1.1.0
     */
    LEFT,
    
    /**
     * <p>The device orientation is such that the deduced direction 
     * of scrolling is towards the <b>right</b> with respect to the 
     * sensor coordinates.</p>
     * 
     * </p>This direction is assumed when the device is tilted to an 
     * angle which lies between the <i>resting range <b>lower-bound</b></i> 
     * and the <i>sensor range <b>lower-bound</b></i>.
     * 
    * <p>{@link MotionEvent}s of this direction are mapped to 
    * {@link HorizontalMotionListener#onMotionRight(HorizontalMotionEvent)}</p>.
     * 
     * @since 1.1.0
     */
    RIGHT;
  }

  
  /**
   * <p>Specifies the direction of the scroll movement along the X-Axis of 
   * the sensor coordinate system.
   */
  private HORIZONTAL_DIRECTION direction;

  
  /**
   * <p>Default constructor which initializes the {@link AbstractMotionEvent}.
   * 
   * @param sensorEvent
   *       See {@link AbstractMotionEvent#getSensorEvent()}
   * 
   * @param direction
   *       the {@link #direction} of the vertical motion
   * 
   * @param filteredOutput
   *       the sensor output values which have been filtered 
   *       through a {@link SmoothingFilter}
   * 
   * @since 1.1.0
   */
  public HorizontalMotionEvent(SensorEvent sensorEvent, 
                 HORIZONTAL_DIRECTION direction, 
                 float[] filteredOutput) {
    
    super(sensorEvent, filteredOutput);
    
    this.direction = direction;
  }
  
  /**
   * <p>Accessor for {@link #direction}.
   * 
   * @return {@link #direction}
   * 
   * @since 1.1.0
   */
  public HORIZONTAL_DIRECTION getDirection() {
    
    return direction;
  }
}




Java Source Code List

com.lonepulse.droidballet.DroidBalletException.java
com.lonepulse.droidballet.DroidBalletRuntimeException.java
com.lonepulse.droidballet.app.MotionApplication.java
com.lonepulse.droidballet.core.HiggsFieldConfiguration.java
com.lonepulse.droidballet.core.HiggsFieldException.java
com.lonepulse.droidballet.core.HiggsFieldUninitializedException.java
com.lonepulse.droidballet.core.HiggsField.java
com.lonepulse.droidballet.core.HiggsMechanism.java
com.lonepulse.droidballet.core.SensorType.java
com.lonepulse.droidballet.detector.HorizontalMotionDetector.java
com.lonepulse.droidballet.detector.MotionDetectorException.java
com.lonepulse.droidballet.detector.MotionDetector.java
com.lonepulse.droidballet.detector.VerticalMotionDetector.java
com.lonepulse.droidballet.filter.AbstractSmoothingFilter.java
com.lonepulse.droidballet.filter.LowPassFilter.java
com.lonepulse.droidballet.filter.SmoothingFilterException.java
com.lonepulse.droidballet.filter.SmoothingFilter.java
com.lonepulse.droidballet.listener.AbstractMotionEvent.java
com.lonepulse.droidballet.listener.HorizontalMotionEvent.java
com.lonepulse.droidballet.listener.HorizontalMotionListener.java
com.lonepulse.droidballet.listener.MotionEvent.java
com.lonepulse.droidballet.listener.MotionListener.java
com.lonepulse.droidballet.listener.VerticalMotionEvent.java
com.lonepulse.droidballet.listener.VerticalMotionListener.java
com.lonepulse.droidballet.queue.EventQueue.java
com.lonepulse.droidballet.queue.MotionEventResolutionJob.java
com.lonepulse.droidballet.queue.QueueController.java
com.lonepulse.droidballet.registry.MotionEventResolverRegistry.java
com.lonepulse.droidballet.registry.MotionListenerRegistry.java
com.lonepulse.droidballet.registry.MotionViewRegistry.java
com.lonepulse.droidballet.resolver.AbstractMotionEventResolver.java
com.lonepulse.droidballet.resolver.HorizontalMotionEventResolver.java
com.lonepulse.droidballet.resolver.MotionEventResolver.java
com.lonepulse.droidballet.resolver.VerticalMotionEventResolver.java
com.lonepulse.droidballet.widget.LinearMotionListView.java
com.lonepulse.droidballet.widget.MotionView.java