⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 animationqueue.java

📁 wap浏览器 日程安排 Rss 棋牌游戏
💻 JAVA
字号:
/* * Fire (Flexible Interface Rendering Engine) is a set of graphics widgets for creating GUIs for j2me applications.  * Copyright (C) 2006-2008 Bluevibe (www.bluevibe.net) * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. *  * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Lesser General Public License for more details. *  * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA *  *//** *  */package gr.fire.util;import gr.fire.core.Animation;import java.util.Vector;/** * @author padeler * */public final class AnimationQueue{	private final Vector animations = new Vector();	private final Object lock = new Object();		private int pointer;		public AnimationQueue()	{		pointer=0;	}		public Animation getNextAnimation() throws InterruptedException	{		synchronized (lock)		{			while(animations.size()==0)			{				lock.wait(); 			}			++pointer;			if(pointer>=animations.size()) pointer=0;					Animation anim = (Animation)animations.elementAt(pointer);							return anim; 		}	}		public void addAnimation(Animation anim)	{		if(anim==null) throw new IllegalArgumentException("Animation cannot be null");				synchronized (lock)		{			animations.addElement(anim);			// set pointer to a position that the next animation served will be this one.			pointer = animations.size()-2;			lock.notify(); // notify animation thread for the new animation.		}			}		public boolean removeAnimation(Animation anim)	{		if(anim==null) throw new IllegalArgumentException("Animation cannot be null");				synchronized (lock)		{			// set pointer to a safe position.			pointer = 0;			return animations.removeElement(anim);		}	}		public void removeAllAnimations()	{		synchronized (lock)		{			// set pointer to a safe position.			pointer = 0;			animations.removeAllElements();		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -