骑猪闯天下

J2ME随笔,记录成长的脚步

统计

留言簿(3)

阅读排行榜

评论排行榜

[J2ME-原创]锚点定位和值

J2ME画图,以锚点定位,各锚点位置示意图如下:



说明:
1. 通过测试验证:
 g.drawString("文字", x, y, 0); 
 =  
g.drawString("文字", x, y, Graphics.LEFT | Graphics.TOP);
0是个默认值,默认的意思就是默认手机空屏时,第一个点可以正常显示的位置,即:Graphics.LEFT | Graphics.TOP


2. 参数“vcenter”为图片专用——这个锚点示意图是以“Image”为例的,当要画的是“String”时,定位参数“vcenter”非法;
3. 定位坐标为 两个参数一组,每组为一个int值,具体的值如下所列;
        int a = Graphics.LEFT | Graphics.TOP;
        
int b = Graphics.LEFT |
 Graphics.BASELINE;
        
int c = Graphics.LEFT |
 Graphics.VCENTER;
        
int d = Graphics.LEFT |
 Graphics.BOTTOM;
        
        
int e = Graphics.RIGHT |
 Graphics.TOP;
        
int f = Graphics.RIGHT |
 Graphics.BASELINE;
        
int g = Graphics.RIGHT |
 Graphics.VCENTER;
        
int h = Graphics.RIGHT |
 Graphics.BOTTOM;
        
        
int i = Graphics.HCENTER |
 Graphics.TOP;
        
int j = Graphics.HCENTER |
 Graphics.BASELINE;
        
int k = Graphics.HCENTER |
 Graphics.VCENTER;
        
int l = Graphics.HCENTER |
 Graphics.BOTTOM;
        
        System.out.println(
"a is : "+
a);
        System.out.println(
"b is : "+
b);
        System.out.println(
"c is : "+
c);
        System.out.println(
"d is : "+
d);
        
        System.out.println(
"e is : "+
e);
        System.out.println(
"f is : "+
f);
        System.out.println(
"g is : "+
g);
        System.out.println(
"h is : "+
h);
        
        System.out.println(
"i is : "+
i);
        System.out.println(
"j is : "+
j);
        System.out.println(
"k is : "+
k);
        System.out.println(
"l is : "+l);

打印结果为:
a is : 20
b is : 68
c is : 6
d is : 36
e is : 24
f is : 72
g is : 10
h is : 40
i is : 17
j is : 65
k is : 3
l is : 33

--End--

posted on 2010-03-05 14:47 骑猪闯天下 阅读(853) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: