📄 directgraphics.java
字号:
/*
* 模拟Nokia的DirectGraphics对象
* Created on 2005-1-16 by Tianlei
* version 1.0.0.3
* since MIDP1.0
*
* 具体不明白的参见Nokia的API reference
* getPixel和setPixel实现了int参数和short参数的,但是short参数的颜色有丢失
* 所以推荐在使用模拟器版本时,将数组改成int型,导真机的时候再改回short
* TODO 很多都只提供了接口,里面的东西还没有实现,
* 估计以后可能会用到的都可以实现起来,还有已经实现的可能没有进行错误判断,以后可以完善起来
*/
package com.nokia.mid.ui;
/**
* @author Tianlei
* @version 1.0.0.3
*
* @since MIDP1.0
*
* 具体不明白的参见Nokia的API reference
* TODO 很多都只提供了接口,里面的东西还没有实现,
* 估计以后可能会用到的都可以实现起来,还有已经实现的可能没有进行错误判断,以后可以完善起来
*/
public interface DirectGraphics {
/**
* 水平翻转的常量
* @since MIDP1.0
*/
public static final int FLIP_HORIZONTAL = 0X2000;
/**
* 垂直翻转的常量
* @since MIDP1.0
*/
public static final int FLIP_VERTICAL = 0X4000;
/**
* 逆时针旋转90度的常量
* @since MIDP1.0
*/
public static final int ROTATE_90 = 90;
/**
* 逆时针旋转180度的常量
* @since MIDP1.0
*/
public static final int ROTATE_180 = 180;
/**
* 逆时针旋转270度的常量
* @since MIDP1.0
*/
public static final int ROTATE_270 = 270;
/**
* 一位格式,只有两种选择,开或者关,8位的一个btye,尽可能的用接近的颜色
* @since MIDP1.0
*/
public static final int TYPE_BYTE_1_GRAY = 1;
/**
* 一位格式,只有两种选择,开或者关,8位的一个btye,尽可能的用接近的颜色
* @since MIDP1.0
*/
public static final int TYPE_BYTE_1_GRAY_VERTICAL = -1;
/**
* 两位格式,4种不同灰度值
* @since MIDP1.0
*/
public static final int TYPE_BYTE_2_GRAY = 2;
/**
* 4位格式,16种不同灰度值
* @since MIDP1.0
*/
public static final int TYPE_BYTE_4_GRAY = 4;
/**
* 8位格式,256种灰度值
* @since MIDP1.0
*/
public static final int TYPE_BYTE_8_GRAY = 8;
/**
* 3位红色,3位绿色,2位蓝色,共一个byte
* @since MIDP1.0
*/
public static final int TYPE_BYTE_332_RGB = 332;
/**
* 4位透明色,各4位的红,绿,蓝,作为一个short保存
* @since MIDP1.0
*/
public static final int TYPE_USHORT_4444_ARGB = 4444;
/**
* 各4位的红,绿,蓝,作为一个short保存
* @since MIDP1.0
*/
public static final int TYPE_USHORT_444_RGB = 444;
/**
* 各5位的红,绿,蓝,作为一个short保存
* @since MIDP1.0
*/
public static final int TYPE_USHORT_555_RGB = 555;
/**
* 1位透明色,各4位的红,绿,蓝,作为一个short保存
* @since MIDP1.0
*/
public static final int TYPE_USHORT_1555_ARGB = 1555;
/**
* 5位红色,6位绿色,5位蓝色来表示一个象素的颜色
* @since MIDP1.0
*/
public static final int TYPE_USHORT_565_RGB = 565;
/**
* 各8位的红,绿,蓝
* @since MIDP1.0
*/
public static final int TYPE_INT_888_RGB = 888;
/**
* 8位透明色,各8位的红,绿,蓝,作为一个int保存
* @since MIDP1.0
*/
public static final int TYPE_INT_8888_ARGB = 8888;
/**
* 设置颜色
* @param argbColor 32位的ARGB颜色
* @since MIDP1.0
*/
public void setARGBColor(int argbColor);
/**
* 画图,目前没有进行错误处理,需要完善起来
* @param img 需要画的图像
* @param x x坐标
* @param y y坐标
* @param anchor 对齐方式
* @param manipulation 旋转方式
*
* @since MIDP1.0
*/
public void drawImage(javax.microedition.lcdui.Image img, int x, int y,
int anchor, int manipulation);
/**
* 画三角形
* @param x1 第一个点的x坐标
* @param y1 第一个点的y坐标
* @param x2 第二个点的x坐标
* @param y2 第二个点的y坐标
* @param x3 第三个点的x坐标
* @param y3 第三个点的y坐标
* @param argbColor 三角形的颜色
*
* @since MIDP1.0
*/
public void drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3,
int argbColor);
/**
* 填充一个三角形
* @param x1 第一个点的x坐标
* @param y1 第一个点的y坐标
* @param x2 第二个点的x坐标
* @param y2 第二个点的y坐标
* @param x3 第三个点的x坐标
* @param y3 第三个点的y坐标
* @param argbColor 三角形的填充颜色
*
* @since MIDP1.0
*/
public void fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3,
int argbColor);
/**
* 画多边形
* @param xPoints x坐标数组
* @param xOffset 相对应xPoints中第一个点的x偏移
* @param yPoints y坐标数组
* @param yOffset 相对应yPoints中第一个点的y偏移
* @param nPoints 点的个数
* @param argbColor 多边形的颜色
* @since MIDP1.0
*/
public void drawPolygon(int[] xPoints, int xOffset, int[] yPoints,
int yOffset, int nPoints, int argbColor);
/**
* 填充一个多边形
* @param xPoints x坐标数组
* @param xOffset 相对应xPoints中第一个点的x偏移
* @param yPoints y坐标数组
* @param yOffset 相对应yPoints中第一个点的y偏移
* @param nPoints 点的个数
* @param argbColor 多边形的颜色
* @since MIDP1.0
*/
public void fillPolygon(int[] xPoints, int xOffset, int[] yPoints,
int yOffset, int nPoints, int argbColor);
/**
* 画象素
* @param pixels 象素数组
* @param transparency 是否需要透明色
* @param offset 第一个象素在数组中的偏移
* @param scanlength 扫描行的长度,通常都等于width
* @param x 左上角的x坐标
* @param y 左上角的y坐标
* @param width 区域宽度
* @param height 区域高度
* @param manipulation 旋转
* @param format 象素值的格式
* @since MIDP1.0
*/
public void drawPixels(int[] pixels, boolean transparency, int offset,
int scanlength, int x, int y, int width, int height,
int manipulation, int format);
/**
* 画象素值
* @param pixels 象素值
* @param transparencyMask 透明色的遮罩数组
* @param offset 第一个象素在数组中的偏移
* @param scanlength 扫描行的长度,通常都等于width
* @param x 左上角的x坐标
* @param y 左上角的y坐标
* @param width 区域宽度
* @param height 区域高度
* @param manipulation 旋转
* @param format 象素值的格式
* @since MIDP1.0
*/
public void drawPixels(byte[] pixels, byte[] transparencyMask, int offset,
int scanlength, int x, int y, int width, int height,
int manipulation, int format);
/**
* 画象素
* @param pixels 象素数组
* @param transparency 是否需要透明色
* @param offset 第一个象素在数组中的偏移
* @param scanlength 扫描行的长度,通常都等于width
* @param x 左上角的x坐标
* @param y 左上角的y坐标
* @param width 区域宽度
* @param height 区域高度
* @param manipulation 旋转
* @param format 象素值的格式
* @since MIDP1.0
*/
public void drawPixels(short[] pixels, boolean transparency, int offset,
int scanlength, int x, int y, int width, int height,
int manipulation, int format);
/**
* 得到象素值
* @param pixels 保存象素的数组
* @param offset 第一个象素保存在数组中的位置
* @param scanlength 扫描行的长度
* @param x 需要得到象素值的区域左上角的x坐标
* @param y 需要得到象素值的区域左上角的y坐标
* @param width 需要得到象素值的区域宽度
* @param height 需要得到象素值的区域高度
* @param format 象素值的格式
* @since MIDP1.0
*/
public void getPixels(int[] pixels, int offset, int scanlength, int x,
int y, int width, int height, int format);
/**
* 保存象素值
* @param pixels 保存象素的数组
* @param transparencyMask 透明遮罩的数组
* @param offset 第一个象素保存在数组中的位置
* @param scanlength 扫描行的长度
* @param x 需要得到象素值的区域左上角的x坐标
* @param y 需要得到象素值的区域左上角的y坐标
* @param width 需要得到象素值的区域宽度
* @param height 需要得到象素值的区域高度
* @param format 象素值的格式
* @since MIDP1.0
*/
public void getPixels(byte[] pixels, byte[] transparencyMask, int offset,
int scanlength, int x, int y, int width, int height, int format);
/**
* 保存象素值
* @param pixels 保存象素的数组
* @param offset 第一个象素保存在数组中的位置
* @param scanlength 扫描行的长度
* @param x 需要得到象素值的区域左上角的x坐标
* @param y 需要得到象素值的区域左上角的y坐标
* @param width 需要得到象素值的区域宽度
* @param height 需要得到象素值的区域高度
* @param format 象素值的格式
* @since MIDP1.0
*/
public void getPixels(short[] pixels, int offset, int scanlength, int x,
int y, int width, int height, int format);
/**
* 实际的象素格式
* @return 实际实现中的象素格式
* @since MIDP1.0
*/
public int getNativePixelFormat();
/**
* 得到当前使用的颜色的alpha值
* @return 当前使用的颜色的alpha值
* @since MIDP1.0
*/
public int getAlphaComponent();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -