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

📄 imagefont.java

📁 Move2008 J2ME SDK是Move2008开发团队在平时的开发中研究出的一个非常精简的类库
💻 JAVA
字号:
/**
*进度条
*@CopyRight:Move2008
*@Author:bedlang
*@Version 1.0 2003/6/8
*/

package Move2008.UI;

import javax.microedition.lcdui.*;

public class ImageFont
{
	Image img=null;
	int fontWidth;
	
	/**
	*构造函数,ImageFont中图象资源的标准位置为:
	*8为Font的宽度
	* !"#$%&'()*+,-./			16 * 8 = 128 	->128
	*0123456789					10 * 8 = 80		->208
	*:;<=>?@					7  * 8 = 56		->264
	*ABCDEFGHIJKLMNOPQRSTUVWXYZ	26 * 8 = 208	->472
	*[\]^_`						6  * 8 = 48		->520
	*abcdefghijklmnopqrstuvwxyz	26 * 8 = 208	->728
	*{|}~						4  * 8 = 32		->760
	*
	*总长:95 * 8 = 760
	*@param Img:ImageFont 的图象资源
	*@param FontWidth:字体的宽度
	*/
	public ImageFont(Image Img, int FontWidth)
	{
		img = Img;
		fontWidth = FontWidth;
	}
	
	/*
	*画Image字符串
	*/
	public void drawString(Graphics G, String Str, int Left, int Top)
	{
		String s = null;
		int asc=0;
		int offset=0;
		int x,y;
		x = y = 0;
		
		for(int i=0; i<Str.length(); i++)
		{
			s = Str.substring(i,i+1);
			asc = s.hashCode();
			x = i*fontWidth + Left;
			y = Top;
			
			offset = asc-32;		
				
			G.setClip(x, y, fontWidth, img.getHeight());
			G.drawImage(img, x-offset*fontWidth, y, G.TOP|G.LEFT);			
		}
	}	
}

⌨️ 快捷键说明

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