/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. ***********************************************************************/
  18. package org.mt4j.input.inputProcessors.componentProcessors.tapAndHoldProcessor;
  19. import org.mt4j.components.interfaces.IMTComponent3D;
  20. import org.mt4j.input.inputData.InputCursor;
  21. import org.mt4j.input.inputProcessors.IInputProcessor;
  22. import org.mt4j.input.inputProcessors.MTGestureEvent;
  23. import org.mt4j.util.math.Vector3D;
  24. /**
  25. * The Class TapAndHoldEvent.
  26. *
  27. * @author Christopher Ruff
  28. */
  29. public class TapAndHoldEvent extends MTGestureEvent {
  30. /** The cursor. */
  31. private InputCursor cursor;
  32. /** The click point. */
  33. private Vector3D clickPoint;
  34. private int holdTime;
  35. private float elapsedTime;
  36. private float elapsedTimeNormalized;
  37. private boolean holdComplete;
  38. /**
  39. * Instantiates a new tap and hold event.
  40. *
  41. * @param source the source
  42. * @param id the id
  43. * @param targetComponent the target component
  44. * @param m the m
  45. * @param clickPoint the click point
  46. */
  47. public TapAndHoldEvent(IInputProcessor source, int id, IMTComponent3D targetComponent, InputCursor m, boolean holdComplete, Vector3D clickPoint, int holdTime, float elapsedTime, float elapsedTimeNormalized) {
  48. super(source, id, targetComponent);
  49. this.cursor = m;
  50. this.holdComplete = holdComplete;
  51. this.clickPoint = clickPoint;
  52. this.holdTime = holdTime;
  53. this.elapsedTime = elapsedTime;
  54. this.elapsedTimeNormalized = elapsedTimeNormalized;
  55. }
  56. /**
  57. * Gets the total time required to hold for a successfully completed gesture.
  58. *
  59. * @return the hold time
  60. */
  61. public int getHoldTime() {
  62. return holdTime;
  63. }
  64. /**
  65. * Checks if the tap and hold gesture was completed successfully or if it was aborted/not finished yet.
  66. *
  67. * @return true, if is hold complete
  68. */
  69. public boolean isHoldComplete() {
  70. return holdComplete;
  71. }
  72. /**
  73. * Gets the elapsed holding time in milliseconds.
  74. *
  75. * @return the elapsed time
  76. */
  77. public float getElapsedTime() {
  78. return elapsedTime;
  79. }
  80. /**
  81. * Gets the elapsed time normalized from 0..1.
  82. * Clamps the value to 1.0 if it would be slightly higher.
  83. *
  84. * @return the elapsed time normalized
  85. */
  86. public float getElapsedTimeNormalized() {
  87. return elapsedTimeNormalized;
  88. }
  89. /**
  90. * Gets the click point.
  91. *
  92. * @return the click point
  93. */
  94. public Vector3D getLocationOnScreen() {
  95. return clickPoint;
  96. }
  97. /**
  98. * Gets the cursor.
  99. *
  100. * @return the cursor
  101. */
  102. public InputCursor getCursor() {
  103. return cursor;
  104. }
  105. }