/src/org/mt4j/input/inputProcessors/componentProcessors/tapProcessor/TapEvent.java

http://mt4j.googlecode.com/ · Java · 152 lines · 50 code · 25 blank · 77 comment · 4 complexity · a4686f7c2a4a6fcc988a5393ed2ed0b5 MD5 · raw file

  1. /***********************************************************************
  2. * mt4j Copyright (c) 2008 - 2009, C.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.tapProcessor;
  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 ClickEvent.
  26. * @author Christopher Ruff
  27. */
  28. public class TapEvent extends MTGestureEvent {
  29. /** The cursor. */
  30. private InputCursor cursor;
  31. /** The click point. */
  32. private Vector3D clickPoint;
  33. /** The click id. */
  34. private int clickID;
  35. @Deprecated
  36. /** The Constant BUTTON_DOWN. */
  37. public static final int BUTTON_DOWN = 3;
  38. @Deprecated
  39. /** The Constant BUTTON_UP. */
  40. public static final int BUTTON_UP = 4;
  41. @Deprecated
  42. /** The Constant BUTTON_CLICKED. */
  43. public static final int BUTTON_CLICKED = 5;
  44. @Deprecated
  45. /** The Constant BUTTON_DOUBLE_CLICKED. */
  46. public static final int BUTTON_DOUBLE_CLICKED = 6;
  47. /** The Constant TAP_DOWN. */
  48. public static final int TAP_DOWN = 3;
  49. /** The Constant TAP_UP. */
  50. public static final int TAP_UP = 4;
  51. /** The Constant TAPPED. */
  52. public static final int TAPPED = 5;
  53. /** The Constant DOUBLE_TAPPED. */
  54. public static final int DOUBLE_TAPPED = 6;
  55. /**
  56. * Instantiates a new click event.
  57. *
  58. * @param source the source
  59. * @param id the id
  60. * @param targetComponent the target component
  61. * @param cursor the cursor
  62. * @param clickPoint the click point
  63. * @param clickID the click id
  64. */
  65. public TapEvent(IInputProcessor source, int id, IMTComponent3D targetComponent, InputCursor cursor, Vector3D clickPoint, int clickID) {
  66. super(source, id, targetComponent);
  67. this.cursor = cursor;
  68. this.clickPoint = clickPoint;
  69. this.clickID = clickID;
  70. }
  71. /**
  72. * Gets the click point.
  73. *
  74. * @return the click point
  75. */
  76. public Vector3D getLocationOnScreen() {
  77. return clickPoint;
  78. }
  79. /**
  80. * Gets the cursor.
  81. *
  82. * @return the cursor
  83. */
  84. public InputCursor getCursor() {
  85. return cursor;
  86. }
  87. /**
  88. * Gets the click id.
  89. *
  90. * @return the click id
  91. */
  92. public int getTapID() {
  93. return clickID;
  94. }
  95. /**
  96. * Checks if is tapped.
  97. *
  98. * @return true, if is tapped
  99. */
  100. public boolean isTapped(){
  101. return this.getTapID() == TAPPED;
  102. }
  103. /**
  104. * Checks if is tap down.
  105. *
  106. * @return true, if is tap down
  107. */
  108. public boolean isTapDown(){
  109. return this.getTapID() == TAP_DOWN;
  110. }
  111. /**
  112. * Checks if is tap canceled.
  113. *
  114. * @return true, if is tap canceled
  115. */
  116. public boolean isTapCanceled(){
  117. return this.getTapID() == TAP_UP;
  118. }
  119. /**
  120. * Checks if is double tap.
  121. *
  122. * @return true, if is double tap
  123. */
  124. public boolean isDoubleTap(){
  125. return this.getTapID() == DOUBLE_TAPPED;
  126. }
  127. }