📄 scheduleimage.java
字号:
/********************************************************************
* 项目名称 :<b>j2me学习 J2me Wap Explorer</b> <br/>
*
* Copyright 2005-2006 Wuhua. All rights reserved </br>
*
* 本程序只用于学习目的,不能用于商业目的。如有需要请联系作者
********************************************************************/
package org.wuhua.wap.ui;
import java.util.TimerTask;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import org.wuhua.wap.Resources;
import org.wuhua.wap.log.Logger;
import org.wuhua.wap.ui.core.Platform;
import org.wuhua.wap.ui.form.Panel;
import org.wuhua.wap.ui.timer.TimerTaskManager;
/**
* <b>类名:ScheduleImage.java</b> </br> 编写日期: 2006-12-25 <br/> 程序功能描述: 下载进度对象,实现像firefox的效果<br/>
* Demo: <br/> Bug: <br/>
*
* 程序变更日期 :<br/> 变更作者 :<br/> 变更说明 :<br/>
*
* @author wuhua </br> <a href="mailto:rrq12345@163.com">rrq12345@163.com</a>
*/
public class ScheduleImage extends Part implements Runnable{
Logger logger = Logger.getLogger("ScheduleImage");
/** 用于执行消失窗口 */
protected TimerTask task;
private Display display;
private Displayable displayable;
private int index;
private Image[] si = Resources.LOAD_STATE;
private int toalTime;
private int timeOut;
public ScheduleImage(Display display) {
super(Platform.WIDTH - 20, 0, 60, 20);
this.display = display;
timeOut = 300;
}
public void paint(Graphics g) {
g.drawImage(si[index], view[X] + 1, view[Y] + 1, Graphics.TOP
| Graphics.LEFT);
}
public void onClick(int keyCode) {
}
public void active(){
logger.info("Start...");
this.toalTime = 0;
if (timeOut != 0)
task = TimerTaskManager.getInstace().add(this, timeOut);
}
/**
* 刷新时间的方法,每隔1秒钟刷新一次
*/
public void run() {
if(toalTime >= timeOut * 220){
cancel();
}
toalTime = toalTime + timeOut;
//超过多少就取消掉
if(toalTime == timeOut * 225)
this.cancel();
// 更新时间
updateSchedule();
repaintSchedule();
}
private void updateSchedule() {
if(index == 3)
index = 0;
index++;
}
/**
* 这里本不应该与程序又任何关联的。但考虑到。。 所以就先这样先
*
*/
private void repaintSchedule() {
if (display == null)
return;
displayable = display.getCurrent();
if (displayable instanceof Panel) {
Panel panel = (Panel) displayable;
panel.repaintSchedule();
}
}
public void cancel() {
this.task.cancel();
}
public int getHeight() {
// TODO 自动生成方法存根
return 0;
}
public int getWidth() {
return font.stringWidth(text);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -