imageview.java.svn-base

来自「开发框架。 一.说明: 此框架的意图是解决手机软件开发中常遇到」· SVN-BASE 代码 · 共 74 行

SVN-BASE
74
字号
package org.gggeye.easymf.ui;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Image;

/**
 * 对PNG,JPEG,GIF的支持 
 
 * @author wuhua
 * 
 */
public class ImageView extends View {
	
	Image image;
	public ImageView(String _src, String _alt, Image _image, String _action,
			HyperLink _hyperLink) {
		this.image = _image;

		this.action = _action;
		this.name = _src;
		this.value = _alt;
		this.addHyperLink(_hyperLink); 
	}
	
	
	final void resetImage(byte[] _imageBytes, Canvas _canvas) throws java.lang.Throwable {
		if (_imageBytes == null)
			return;
		this.resetImage(Image.createImage(_imageBytes, 0,
					_imageBytes.length));
	}

	final void resetImage(Image _image) {
		if(_image == null)
			return;
		image = _image;
		// if (_image == null) {
		// this.width = 20;
		// this.height = DocumentBuilder.defaultHeight;
		// this.right = this.left + width;
		// this.buttom = this.top + height;
		//
		// } else {
		this.width = _image.getWidth() + ViewBuilder.LEFT_SPACE;
		this.height = _image.getHeight() + ViewBuilder.TOP_SPACE;
		this.right = this.left + width;
		this.buttom = this.top + height;
		// }
	}

	public void doPaint(Pen point, HtmlDocument _htmlDocument) {
		if (_htmlDocument.focusIndex == this.index) {
			point.drawRects(left, top, width, height);
		}	 
		doDrawImage(point);
	}



	protected void doDrawImage(Pen point) {
		if (image == null ) {
			point.drawRect(left, top, width, height);
			
			point.drawString("图", left, top, 20);
		} else
			point.drawImage(image, left + (ViewBuilder.LEFT_SPACE), top
					+ (ViewBuilder.TOP_SPACE), 20);
	}
	
	
}

 

⌨️ 快捷键说明

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