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

📄 effecthelper.java

📁 j2me开发框架
💻 JAVA
字号:
package com.podome.tool;

import java.util.Vector;

import com.podome.ui.UIBase;

public class EffectHelper extends Thread {
	/***********************************************/
	private static EffectHelper instance;
	private static Vector repaintQueue;
	private static boolean runing = true;
	
	private EffectHelper(){
		
	}	
	
	/**
	 * 暂停一个正在运行的跑马灯
	 */
	public static void pause(){
		runing = false;
	}
	
	/**
	 *  停止一个正在运行的跑马灯
	 */
	public static void play(){
		runing = true;			
	}
	
	
	public static void addToRepaint(UIBase o){
		if(repaintQueue == null){
			repaintQueue = new Vector(5);
		}
		repaintQueue.addElement(o);
		if(instance == null){
			instance = new EffectHelper();
			instance.start();
		}		
	}
	
	public static void removeRepaint(UIBase o){
	    if( repaintQueue == null) return;
	    if( runing ){
	    	//for(int i=repaintQueue.size()-1;i > 0;i--)
	    	repaintQueue.removeElement(o);
	    }
	    else{
	    	//for(int i=repaintQueue.size()-1;i > 0;i--)
	    	repaintQueue.removeElement(o);
	    }	    
	}
	
	public void run(){
		UIBase o;
		while( true){
		    while( runing && repaintQueue.size() > 0 ){	
			    boolean hasDrawAlert = false;
			    for(int i=0; i< repaintQueue.size(); i++){
			    	o = (UIBase)repaintQueue.elementAt(i);
			    	if( o.getTypeName().equals("Alert") ){
			    	    if( !hasDrawAlert){
			    		    o.move();	    	        
			    	        hasDrawAlert = true;
			    	    }
			    	}
			    	else{
			    		 o.move();				    	 
			    	}			    	
			    }
			    try {
					sleep( Config.SCHEMA_INTERVAL);
				} 
			    catch (InterruptedException e) {
					
				}
	        }
		    try {
				sleep( 50 );
			} 
		    catch (InterruptedException e) {				
			}
		}
//		else{
//			timer.cancel();
//			instance = null;
//			timer = null;			
//		}
		
//		while( repaintQueue.size() > 0 ){
//			boolean hasDrawAlert = false;
//		    for(int i=0; i< repaintQueue.size(); i++){				
//		    	o = (UIBase)repaintQueue.elementAt(i);
//		    	if( o.getTypeName().equals("Alert") ){
//		    	    if( !hasDrawAlert){
//		    		    o.move();
//		    	        Stage.getInstance().notifyRepaint(o);
//		    	        hasDrawAlert = true;
//		    	    }
//		    	}
//		    	else{
//		    		 o.move();
//			    	 Stage.getInstance().notifyRepaint(o);
//		    	}			    	
//		    }
//		    try {
//		    	yield();
//				wait(Config.SCHEMA_INTERVAL);
//			} catch (Exception e) {				
//				e.printStackTrace();
//			}
//		}
//		instance = null;	
		
	}
}

⌨️ 快捷键说明

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