Definition and use of several enumeration in paint. Java of Android
Frameworks \ base \ graphics \ Java \ Android \ graphics \ paint. Java
Definition:
/** * 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; }
Usage:
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 };