android的Paint.java中几个枚举的定义和使用
2011-08-07 22:03
513 查看
android的Paint.java中几个枚举的定义和使用
frameworks\base\graphics\java\android\graphics\Paint.java定义:
/** * The Style specifies if the primitive being drawn is filled, * stroked, or both (in the same color). The default is FILL. */ public enum Style { /** * Geometry and text drawn with this style will be filled, ignoring all * stroke-related settings in the paint. */ FILL (0), /** * Geometry and text drawn with this style will be stroked, respecting * the stroke-related fields on the paint. */ STROKE (1), /** * Geometry and text drawn with this style will be both filled and * stroked at the same time, respecting the stroke-related fields on * the paint. */ FILL_AND_STROKE (2); Style(int nativeInt) { this.nativeInt = nativeInt; } final int nativeInt; } /** * The Cap specifies the treatment for the beginning and ending of * stroked lines and paths. The default is BUTT. */ public enum Cap { /** * The stroke ends with the path, and does not project beyond it. */ BUTT (0), /** * The stroke projects out as a semicircle, with the center at the * end of the path. */ ROUND (1), /** * The stroke projects out as a square, with the center at the end * of the path. */ SQUARE (2); private Cap(int nativeInt) { this.nativeInt = nativeInt; } final int nativeInt; } /** * The Join specifies the treatment where lines and curve segments * join on a stroked path. The default is MITER. */ public enum Join { /** * The outer edges of a join meet at a sharp angle */ MITER (0), /** * The outer edges of a join meet in a circular arc. */ ROUND (1), /** * The outer edges of a join meet with a straight line */ BEVEL (2); private Join(int nativeInt) { this.nativeInt = nativeInt; } final int nativeInt; } /** * Align specifies how drawText aligns its text relative to the * [x,y] coordinates. The default is LEFT. */ public enum Align { /** * The text is drawn to the right of the x,y origin */ LEFT (0), /** * The text is drawn centered horizontally on the x,y origin */ CENTER (1), /** * The text is drawn to the left of the x,y origin */ RIGHT (2); private Align(int nativeInt) { this.nativeInt = nativeInt; } final int nativeInt; }
使用:
private static final Style[] sStyleArray = { Style.FILL, Style.STROKE, Style.FILL_AND_STROKE }; private static final Cap[] sCapArray = { Cap.BUTT, Cap.ROUND, Cap.SQUARE }; private static final Join[] sJoinArray = { Join.MITER, Join.ROUND, Join.BEVEL }; private static final Align[] sAlignArray = { Align.LEFT, Align.CENTER, Align.RIGHT };
相关文章推荐
- 提高你的Java代码质量吧:推荐使用枚举定义常量
- Android中Webview使用javascript调用事先定义好的Java函数
- java 枚举——java(android)中枚举的运用和使用场景
- java 定义枚举+枚举使用
- java的枚举定义以及使用方法介绍
- Android基础入门教程——8.3.14 Paint几个枚举-常量值以及ShadowLayer阴影效果
- java 定义枚举+枚举使用
- [改善Java代码]推荐使用枚举定义常量
- 提高Java代码质量:使用枚举定义常量(转)
- Android初学习 - color在XML文件和java代码中的定义和使用
- Android基础—Paint几个枚举/常量值以及ShadowLayer阴影效果
- 拔高你的Java代码质量吧:推荐使用枚举定义常量(转)
- java 枚举——java(android)中枚举的运用和使用场景
- [编写高质量代码:改善java程序的151个建议]建议83 推荐使用枚举定义常量
- 提高你的Java代码质量吧:推荐使用枚举定义常量
- java 枚举——java(android)中枚举的运用和使用场景
- Java从零开始学二十五(枚举定义和简单使用)
- Java基础知识JNI 在Android中使用System.loadLibrary()
- Android res文件夹下资源定义及使用