您的位置:首页 > 产品设计 > UI/UE

j2ME中 lwuit实现按钮缩放功能代码解析

2010-11-30 10:32 676 查看
0j2ME中 lwuit实现按钮缩放功能代码解当用户按下按钮的时候 实现缩放功能final Button b = new Button(NameList[i], unselectedImages[i]) {public Image getPressedIcon() {
Image i = getIcon();
return i.scaled((int) (i.getWidth() * 0.8), (int) (i.getHeight() * 0.8));
}
};LWUIT Image 实现代码public Image scaled(int width, int height) {
if(width == getWidth() && height == getHeight()) {
return this;
}
Dimension d = new Dimension(width, height);
Image i = getCachedImage(d);
if(i != null) {
return i;
}
i = new Image(this.image);
i.scale(width, height);
i.transform = this.transform;
cacheImage(d, i);
return i;
}获得图片缓冲Image getCachedImage(Dimension size) {
if(scaleCache != null) {
WeakReference w = (WeakReference)scaleCache.get(size);
if(w != null) {
return (Image)w.get();
}
}
return null;本文出自 “技术人生” 博客,请务必保留此出处http://zhaohaiyang.blog.51cto.com/2056753/436147
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: