PageRenderTime 48ms CodeModel.GetById 38ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/src/org/mt4j/input/inputProcessors/componentProcessors/tapAndHoldProcessor/TapAndHoldEvent.java

http://mt4j.googlecode.com/
Java | 129 lines | 41 code | 24 blank | 64 comment | 0 complexity | 1ce21ab1349cc1d8bb5ea9e7c84fece7 MD5 | raw file
  1/***********************************************************************
  2 * mt4j Copyright (c) 2008 - 2009 Christopher Ruff, Fraunhofer-Gesellschaft All rights reserved.
  3 *  
  4 *   This program is free software: you can redistribute it and/or modify
  5 *   it under the terms of the GNU General Public License as published by
  6 *   the Free Software Foundation, either version 3 of the License, or
  7 *   (at your option) any later version.
  8 *
  9 *   This program is distributed in the hope that it will be useful,
 10 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12 *   GNU General Public License for more details.
 13 *
 14 *   You should have received a copy of the GNU General Public License
 15 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 16 *
 17 ***********************************************************************/
 18package org.mt4j.input.inputProcessors.componentProcessors.tapAndHoldProcessor;
 19
 20import org.mt4j.components.interfaces.IMTComponent3D;
 21import org.mt4j.input.inputData.InputCursor;
 22import org.mt4j.input.inputProcessors.IInputProcessor;
 23import org.mt4j.input.inputProcessors.MTGestureEvent;
 24import org.mt4j.util.math.Vector3D;
 25
 26/**
 27 * The Class TapAndHoldEvent.
 28 * 
 29 * @author Christopher Ruff
 30 */
 31public class TapAndHoldEvent extends MTGestureEvent {
 32	
 33	/** The cursor. */
 34	private InputCursor cursor;
 35	
 36	/** The click point. */
 37	private Vector3D clickPoint;
 38	
 39	private int holdTime;
 40	
 41	private float elapsedTime;
 42	
 43	private float elapsedTimeNormalized;
 44	
 45	private boolean holdComplete;
 46
 47	/**
 48	 * Instantiates a new tap and hold event.
 49	 * 
 50	 * @param source the source
 51	 * @param id the id
 52	 * @param targetComponent the target component
 53	 * @param m the m
 54	 * @param clickPoint the click point
 55	 */
 56	public TapAndHoldEvent(IInputProcessor source, int id, IMTComponent3D targetComponent, InputCursor m, boolean holdComplete, Vector3D clickPoint, int holdTime, float elapsedTime, float elapsedTimeNormalized) {
 57		super(source, id, targetComponent);
 58		this.cursor = m;
 59		this.holdComplete = holdComplete;
 60		this.clickPoint = clickPoint;
 61		this.holdTime = holdTime;
 62		this.elapsedTime = elapsedTime;
 63		this.elapsedTimeNormalized = elapsedTimeNormalized;
 64	}
 65	
 66	
 67	
 68	/**
 69	 * Gets the total time required to hold for a successfully completed gesture.
 70	 * 
 71	 * @return the hold time
 72	 */
 73	public int getHoldTime() {
 74		return holdTime;
 75	}
 76
 77
 78
 79	/**
 80	 * Checks if the tap and hold gesture was completed successfully or if it was aborted/not finished yet.
 81	 * 
 82	 * @return true, if is hold complete
 83	 */
 84	public boolean isHoldComplete() {
 85		return holdComplete;
 86	}
 87
 88
 89	/**
 90	 * Gets the elapsed holding time in milliseconds.
 91	 * 
 92	 * @return the elapsed time
 93	 */
 94	public float getElapsedTime() {
 95		return elapsedTime;
 96	}
 97
 98
 99
100	/**
101	 * Gets the elapsed time normalized from 0..1.
102	 * Clamps the value to 1.0 if it would be slightly higher.
103	 * 
104	 * @return the elapsed time normalized
105	 */
106	public float getElapsedTimeNormalized() {
107		return elapsedTimeNormalized;
108	}
109
110
111	/**
112	 * Gets the click point.
113	 * 
114	 * @return the click point
115	 */
116	public Vector3D getLocationOnScreen() {
117		return clickPoint;
118	}
119
120	/**
121	 * Gets the cursor.
122	 * 
123	 * @return the cursor
124	 */
125	public InputCursor getCursor() {
126		return cursor;
127	}
128
129}