Android Open Source - DroidBallet Motion Event Resolution Job






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.queue;
/*from   w w  w  . j a v a  2s  .c  om*/
/*
 * #%L
 * DroidBallet Library
 * %%
 * 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 java.util.Set;

import android.hardware.SensorEvent;
import android.view.MotionEvent;

import com.lonepulse.droidballet.listener.MotionListener;
import com.lonepulse.droidballet.resolver.MotionEventResolver;

/**
 * <p>Represents a motion event which is to be translated to a motion 
 * event and despatched to targeted motion listeners. 
 * 
 * @version 1.1.0
 * <br><br>
 * @author <a href="mailto:lahiru@lonepulse.com">Lahiru Sahan Jayasinghe</a>
 */
public class MotionEventResolutionJob {

  
  /**
   * <p>This <i>builder</i> is to be used for creating a custom 
   * {@link MotionEventResolutionJob}.
   * 
   * @version 1.1.0
   * <br><br>
   * @author <a href="mailto:lahiru@lonepulse.com">Lahiru Sahan Jayasinghe</a>
   */
  public static final class Builder {
    
    
    /**
     * <p>See {@link MotionEventResolutionJob#sensorEvent}.
     */
    private SensorEvent sensorEvent;
    
    /**
     * <p>See {@link MotionEventResolutionJob#motionListeners}.
     */
    private Set<MotionListener> motionListeners;
    
    /**
     * <p>See {@link MotionEventResolutionJob#motionEventResolver}.
     */
    private MotionEventResolver motionEventResolver;
    
    
    /**
     * <p>Creates an instance of {@link MotionEventResolutionJob} to reflect the 
     * properties set in this instance of {@link MotionEventResolutionJob.Builder}.
     * 
     * @param sensorEvent
     *       see {@link MotionEventResolutionJob#sensorEvent}
     * 
     * @param motionListeners
     *       see {@link MotionEventResolutionJob#motionListeners}
     * 
     * @param motionEventResolver
     *       see {@link MotionEventResolutionJob#motionEventResolver}
     * 
     * @since 1.1.0
     */
    public Builder(SensorEvent sensorEvent, 
             Set<MotionListener> motionListeners, 
             MotionEventResolver motionEventResolver) {
      
      this.sensorEvent = sensorEvent;
      this.motionListeners = motionListeners;
      this.motionEventResolver = motionEventResolver;
    }

    /**
     * <p>Mutator for {@link #sensorEvent}.
     *
     * @param sensorEvent 
     *      sets {@link #sensorEvent}
     */
    public void setSensorEvent(SensorEvent sensorEvent) {
      
      this.sensorEvent = sensorEvent;
    }

    /**
     * <p>Mutator for {@link #motionListeners}.
     *
     * @param motionListeners 
     *      sets {@link #motionListeners}
     */
    public void setMotionListeners(Set<MotionListener> motionListeners) {
      
      this.motionListeners = motionListeners;
    }

    /**
     * <p>Mutator for {@link #motionEventResolver}.
     *
     * @param motionEventResolver 
     *      sets {@link #motionEventResolver}
     */
    public void setMotionEventResolver(MotionEventResolver motionEventResolver) {
      
      this.motionEventResolver = motionEventResolver;
    }
    
    /**
     * <p>Creates an instance of {@link MotionEventResolutionJob} to reflect the 
     * properties set in this instance of {@link MotionEventResolutionJob.Builder}.
     * 
     * @return the configured instance of {@link MotionEventResolutionJob}
     * 
     * @since 1.1.0
     */
    public MotionEventResolutionJob build() {
      
      return new MotionEventResolutionJob(this);
    }
  }

  
  /**
   * <p>The motion {@link SensorEvent} which is to be processed 
   * and translated to an action on a {@link MotionListener}.
   */
  private final SensorEvent sensorEvent;
  
  /**
   * <p>The set of {@link MotionListener}s on which the motion 
   * event is despatched.  
   */
  private final Set<MotionListener> motionListeners;
  
  /**
   * <p>The {@link MotionEventResolver} which is to be used for 
   * translating the {@link #sensorEvent} to a {@link MotionEvent} 
   * on the set of {@link #motionListeners}
   */
  private final MotionEventResolver motionEventResolver;

  
  /**
   * <p>Accessor for {@link #sensorEvent}.
   *
   * @return the {@link #sensorEvent}
   * 
   * @since 1.1.0
   */
  public SensorEvent getSensorEvent() {
    
    return sensorEvent;
  }

  /**
   * <p>Accessor for {@link #motionListeners}.
   *
   * @return the {@link #motionListeners}
   * 
   * @since 1.1.0
   */
  public Set<MotionListener> getMotionListeners() {
    
    return motionListeners;
  }

  /**
   * <p>Accessor for {@link #motionEventResolver}.
   *
   * @return the {@link #motionEventResolver}
   * 
   * @since 1.1.0
   */
  public MotionEventResolver getMotionEventResolver() {
    
    return motionEventResolver;
  }
  
  /**
   * <p>Creates an instance of {@link MotionEventResolutionJob} using the 
   * supplied {@link MotionEventResolutionJob.Builder}.
   * 
   * @param builder
   *       a {@link MotionEventResolutionJob.Builder} which can be used 
   *       to create a {@link MotionEventResolutionJob}
   * 
   * @since 1.1.0
   */
  public MotionEventResolutionJob(MotionEventResolutionJob.Builder builder) {
  
    this.sensorEvent = builder.sensorEvent;
    this.motionListeners = builder.motionListeners;
    this.motionEventResolver = builder.motionEventResolver;
  }
}




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