www.pudn.com > Bluegammon蓝牙的应用编程.rar > Animation.java
// Copyright (c) 2005 Sony Ericsson Mobile Communications AB // // This software is provided "AS IS," without a warranty of any kind. // ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, // INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A // PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. // // THIS SOFTWARE IS COMPLEMENTARY OF JAYWAY AB (www.jayway.se) package bluegammon.gui.animation; import javax.microedition.lcdui.Graphics; /** * This abstract class represents an animation and is * handled by theAnimationEngine* @author Peter Andersson */ public abstract class Animation { /** Time of last invokation ofnexton this animation. */ protected long m_lastInvoke = System.currentTimeMillis(); /** * Override this to invoke functionality at the * start of this animation */ public void onStart() {} /** * Draws the animation using the specified graphics context. * @param g The graphics context. */ public abstract void paint(Graphics g); /** * Called each time the animation should be updated. */ public abstract void next(); /** * Probes to check if the animation can be removed * @return true if finished, false if still active */ public abstract boolean isFinished(); /** * Returns interval time in milliseconds when the animation should be updated, * i.e. thenextmethod is invoked. * @return update interval in milliseconds. */ public abstract long getInterval(); /** * Called from animation engine * @param t Current time */ public void callNext(long t) { m_lastInvoke = t; next(); } /** * Returns last update in milliseconds * @return The time of last update */ public long getLastInvoke() { return m_lastInvoke; } /** * Override this to invoke functionality at the * end of this animation */ public void onExit() {} }