splashcanvas.java

来自「最强手机阅读器Anyview3.0版的界面代码」· Java 代码 · 共 69 行

JAVA
69
字号
package com.ismyway.anyview.win;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

import com.ismyway.anyview.others.Configure;
import com.ismyway.fairyui.Handset;
import com.ismyway.fairyui.MainCanvas;
import com.ismyway.fairyui.Panel;

public class SplashCanvas extends Canvas implements Runnable {
	private boolean getSize = false;
	private Image logo = null;

	public SplashCanvas() {
		setFullScreenMode(true);
		try {
			logo = Image.createImage("/res/logo.png");
		} catch (Exception e) {

		}
		new Thread(this).start();
	}

	protected void paint(Graphics g) {
		//System.out.println(">>" + MainCanvas.screenWidth + ", " + MainCanvas.screenHeight);

		if (null != logo) {
			for (int height = 0; height < getHeight(); height += 16) {
				for (int width = 0; width < getWidth(); width += 100) {
					g.setClip(width, height, 100, 16);
					g.drawImage(logo, width, height, 20);
				}
			}
			int x = (getWidth() - logo.getWidth()) >> 1;
			int y = (getHeight() - logo.getHeight()) >> 1;
			g.setClip(0, 0, getWidth(), getHeight());
			g.drawImage(logo, x, y, 20);
		} else {
			g.setColor(0);
			g.fillRect(0, getWidth(), 0, getHeight());
		}
		
		MainCanvas.screenWidth = getWidth();
		MainCanvas.screenHeight = getHeight();
		getSize = true;
	}

	public void run() {
		repaint();
		while (!getSize) {
			try {
				Thread.sleep(100L);
			} catch (Exception e) {

			}
		}

		logo = null;
		Configure.gc();

		MainCanvas screen = MainCanvas.getInstance();
		Handset.getDisplay().setCurrent(screen);
		Panel p = new Welcome();
		screen.setCurrent(p);
	}
}

⌨️ 快捷键说明

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