PageRenderTime 35ms CodeModel.GetById 24ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

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