?? imagefont.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 + -