📄 part.java
字号:
/********************************************************************
* 项目名称 :<b>j2me学习 J2me Wap Explorer</b> <br/>
*
* Copyright 2005-2006 Wuhua. All rights reserved </br>
*
* 本程序只用于学习目的,不能用于商业目的。如有需要请联系作者
********************************************************************/
package org.wuhua.wap.ui;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import org.wuhua.wap.ui.event.PartChangeListener;
/**
* <b>类名:Part.java</b> </br> 编写日期: 2006-9-14 <br/> 程序功能描述: 所有窗口的部件<br/> Demo:
* <br/> Bug: <br/>
*
* 程序变更日期 :<br/> 变更作者 :<br/> 变更说明 :<br/>
*
* @author wuhua </br> <a href="mailto:rrq12345@163.com">rrq12345@163.com</a>
*/
public abstract class Part {
protected final int X = 0;
protected final int Y = 1;
protected final int WIDTH = 2;
protected final int HEIGHT = 3;
/**
* 位置的显示
*/
protected int view[] = new int[4];
/**
* 背景色
*/
protected int bgColor = 0x000000;
/**
* 字体颜色
*/
protected int fontColor = 0xFFFFFF;
protected int selectedIndex;
protected Canvas container;
protected String label;
protected String text;
/** 每个Item都有自己的聚焦 **/
protected boolean hasFocus;
/**
* 行
*/
protected int row;
protected int rowNum;
/**
* 列
*/
protected int column;
protected int columnNum;
/**
* 每个Part的位置
*/
public final static String ALIGN_LEFT = "0";
public final static String ALIGN_CENTER = "1";
public final static String ALIGN_RIGHT = "2";
protected String align = ALIGN_LEFT;
protected PartChangeListener partChangeListener;
/**
* URL
*/
protected String url;
/**
* Display对象,用于显示高级UI,
* 不知道怎么样对这个对象进行解耦.
*/
protected static Display display;
/**
* 是否是下一行, 默认是下一行
*/
private boolean isNextRow = true;
public final String getUrl() {
return url;
}
public static final void setDisplay(Display display) {
Part.display = display;
}
public Part(int x, int y, int widht, int height) {
view[X] = x;
view[Y] = y;
view[WIDTH] = widht;
view[HEIGHT] = height;
}
public void setStyle(int bgColor, int fontColor) {
this.bgColor = bgColor;
this.fontColor = fontColor;
}
/**
* 默认字体
*/
protected Font font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN,
Font.SIZE_SMALL);
/**
* 资料实现绘制方法
*
* @param g
*/
public abstract void paint(Graphics g);
/**
* 事件
*
* @param keyCode
*/
public abstract void onClick(int keyCode);
public int getSelectIndex() {
return selectedIndex;
}
public void setSelectIndex(int selectIndex) {
this.selectedIndex = selectIndex;
}
/**
* 改变部件的位置
*/
public void changePosition(int x, int y, int width, int height){
view[X] = x;
view[Y] = y;
view[WIDTH] = width;
view[HEIGHT] = height;
}
public void setContainer(Canvas container) {
this.container = container;
}
/**
* 聚焦
* @param hasFocus
*/
public void setHasFocus(boolean hasFocus){
this.hasFocus = hasFocus;
}
public void setPartChangeListener(PartChangeListener partChangeListener) {
this.partChangeListener = partChangeListener;
}
public int[] getView() {
return view;
}
public final Canvas getContainer() {
return container;
}
public final String getText() {
return text;
}
public final void setText(String text) {
this.text = text;
}
/**
* 动态的获取UI的高度。
* @return
*/
public abstract int getHeight();
/**
* 动态的获取UI的宽度。
* @return
*/
public abstract int getWidth();
public final int getColumn() {
return column;
}
public final void setColumn(int column) {
this.column = column;
}
public final int getColumnNum() {
return columnNum;
}
public final void setColumnNum(int columnNum) {
this.columnNum = columnNum;
}
public final int getRow() {
return row;
}
public final void setRow(int row) {
this.row = row;
}
public final int getRowNum() {
return rowNum;
}
public final void setRowNum(int rowNum) {
this.rowNum = rowNum;
}
public final boolean isNextRow() {
return isNextRow;
}
public final void setNextRow(boolean isNextRow) {
this.isNextRow = isNextRow;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -