/src/org/mt4j/util/animation/AnimationEvent.java

http://mt4j.googlecode.com/ · Java · 148 lines · 43 code · 25 blank · 80 comment · 0 complexity · c097ec600873d9815e5eefb1556b2c4d 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.util.animation;
  19. import org.mt4j.input.MTEvent;
  20. /**
  21. * The Class AnimationEvent.
  22. * @author Christopher Ruff
  23. */
  24. public class AnimationEvent extends MTEvent {
  25. /** The id. */
  26. private int id;
  27. /** The animation. */
  28. private IAnimation animation;
  29. /** The target object. */
  30. private Object targetObject;
  31. /** The Constant ANIMATION_STARTED. */
  32. public static final int ANIMATION_STARTED = 0;
  33. /** The Constant ANIMATION_UPDATED. */
  34. public static final int ANIMATION_UPDATED = 1;
  35. /** The Constant ANIMATION_ENDED. */
  36. public static final int ANIMATION_ENDED = 2;
  37. /**
  38. * Instantiates a new animation event.
  39. *
  40. * @param source the source
  41. * @param id the id
  42. * @param animation the animation
  43. */
  44. public AnimationEvent(Object source, int id, IAnimation animation) {
  45. this(source, id, animation, null);
  46. }
  47. /**
  48. * Instantiates a new animation event.
  49. *
  50. * @param source the source
  51. * @param id the id
  52. * @param animation the animation
  53. * @param targetObject the target object
  54. */
  55. public AnimationEvent(Object source, int id, IAnimation animation, Object targetObject) {
  56. super(source);
  57. this.id = id;
  58. this.animation = animation;
  59. this.targetObject = targetObject;
  60. }
  61. /**
  62. * Gets the id.
  63. *
  64. * @return the id
  65. */
  66. public int getId() {
  67. return id;
  68. }
  69. /**
  70. * Gets the animation.
  71. *
  72. * @return the animation
  73. */
  74. public IAnimation getAnimation() {
  75. return animation;
  76. }
  77. /**
  78. * Gets the current step delta - the difference between the last value and the current value.
  79. *
  80. * @return the current step delta
  81. * @deprecated use getDelta() instead
  82. * @see #getDelta()
  83. */
  84. public float getCurrentStepDelta(){
  85. return this.getAnimation().getDelta();
  86. }
  87. /**
  88. * Gets the current absolute value of the interpolated value.
  89. *
  90. * @return the current value
  91. * @deprecated use getValue() instead
  92. * @see #getValue()
  93. */
  94. public float getCurrentValue(){
  95. return this.getAnimation().getValue();
  96. }
  97. public float getValue(){
  98. return this.getAnimation().getValue();
  99. }
  100. public float getDelta(){
  101. return this.getAnimation().getDelta();
  102. }
  103. /**
  104. * returns the target for the animation
  105. * <br>Note: can be null!.
  106. *
  107. * @return the target object of this animation - if it is set
  108. * @deprecated use getTaget() instead
  109. * @see #getTarget()
  110. */
  111. public Object getTargetObject() {
  112. return targetObject;
  113. }
  114. /**
  115. * returns the target for the animation
  116. * <br>Note: can be null!.
  117. *
  118. * @return the target object of this animation - if it is set
  119. */
  120. public Object getTarget(){
  121. return this.targetObject;
  122. }
  123. }