1 /* 2 * Copyright 2012 Daniel Kurka 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16 package com.googlecode.mgwt.dom.client.recognizer.tap; 17 18 import com.google.gwt.event.shared.GwtEvent; 19 import com.googlecode.mgwt.collection.shared.LightArray; 20 import com.googlecode.mgwt.dom.client.event.touch.Touch; 21 22 /** 23 * A {@link MultiTapEvent} occurs if the taps multiple times on the screen 24 * 25 * @author Daniel Kurka 26 * 27 */ 28 public class MultiTapEvent extends GwtEvent<MultiTapHandler> { 29 30 private static final GwtEvent.Type<MultiTapHandler> TYPE = new Type<MultiTapHandler>(); 31 32 public static GwtEvent.Type<MultiTapHandler> getType() { 33 return TYPE; 34 } 35 36 private final int numberOfFingers; 37 private final LightArray<LightArray<Touch>> touchStarts; 38 private final int numberOfTaps; 39 40 /** 41 * Construct a Multitap event 42 * 43 * @param numberOfFingers the number of fingers that tapped on the screen 44 * @param numberOfTaps the number of times the screen was tapped 45 * @param touchStarts the position of the fingers that started the taps 46 */ 47 public MultiTapEvent(int numberOfFingers, int numberOfTaps, LightArray<LightArray<Touch>> touchStarts) { 48 this.numberOfFingers = numberOfFingers; 49 this.numberOfTaps = numberOfTaps; 50 this.touchStarts = touchStarts; 51 } 52 53 /** 54 * get the number of fingers that tapped on the screen 55 * 56 * @return the number of fingers that tapped on the screen 57 */ 58 public int getNumberOfFinders() { 59 return numberOfFingers; 60 } 61 62 /** 63 * get the position of the fingers that started the taps 64 * 65 * @return the position of the fingers that started the taps 66 */ 67 public LightArray<LightArray<Touch>> getTouchStarts() { 68 return touchStarts; 69 } 70 71 /** 72 * get the number of times the screen was tapped 73 * 74 * @return the number of times the screen was tapped 75 */ 76 public int getNumberOfTabs() { 77 return numberOfTaps; 78 } 79 80 /* 81 * (non-Javadoc) 82 * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() 83 */ 84 @Override 85 public com.google.gwt.event.shared.GwtEvent.Type<MultiTapHandler> getAssociatedType() { 86 return TYPE; 87 } 88 89 /* 90 * (non-Javadoc) 91 * @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler) 92 */ 93 @Override 94 protected void dispatch(MultiTapHandler handler) { 95 handler.onMultiTap(this); 96 97 } 98 99 }