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

📄 imagefont.java

📁 MMAE1.0开发者版源代码 用于扩展java me移动开发引擎,这是1.0版的源码.
💻 JAVA
字号:
/**
*进度条
*@CopyRight:Move2008
*@Author:bedlang
*@Version 1.0 2003/6/8
*/

package mmae.ui;

import javax.microedition.lcdui.*;

public class ImageFont
{
	private Image img=null;
	private int fontWidth;
	private int fontOffSet=0;
	
	/**
	*构造函数,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;

        int i1 = G.getClipX();
        int j1 = G.getClipY();
        int k1 = G.getClipWidth();
        int l1 = G.getClipHeight();

		for(int i=0; i<Str.length(); i++)
		{
			s = Str.substring(i,i+1);
			asc = s.hashCode();
			x = i*(fontWidth+fontOffSet) + Left;
			y = Top;
			
			offset = asc-32;		
			
			G.setClip(x, y, fontWidth, img.getHeight());
			G.drawImage(img, x-offset*fontWidth, y, G.TOP|G.LEFT);	
		}
		G.setClip(i1,j1,k1,l1);				
	}
	
	/**
	*得到ImageFont字体高度
	*/
	public int getHeight()
	{
		return img.getHeight();
	}
	
	/**
	*设置文字之间的间隙
	*/
	public void setOffset(int i)
	{
		fontOffSet = i;
	}	
	
}

⌨️ 快捷键说明

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