|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.graphics.Paint
public class Paint
The Paint class holds the style and color information about how to draw geometries, text and bitmaps.
| Nested Class Summary | |
|---|---|
static class |
Paint.Align
Align specifies how drawText aligns its text relative to the [x,y] coordinates. |
static class |
Paint.Cap
The Cap specifies the treatment for the beginning and ending of stroked lines and paths. |
static class |
Paint.FontMetrics
Class that describes the various metrics for a font at a given text size. |
static class |
Paint.FontMetricsInt
Convenience method for callers that want to have FontMetrics values as integers. |
static class |
Paint.Join
The Join specifies the treatment where lines and curve segments join on a stroked path. |
static class |
Paint.Style
The Style specifies if the primitive being drawn is filled, stroked, or both (in the same color). |
| Field Summary | |
|---|---|
static int |
ANTI_ALIAS_FLAG
bit mask for the flag enabling antialiasing |
static int |
DEV_KERN_TEXT_FLAG
bit mask for the flag enabling device kerning for text |
static int |
DITHER_FLAG
bit mask for the flag enabling dithering |
static int |
FAKE_BOLD_TEXT_FLAG
bit mask for the flag enabling fake-bold text |
static int |
FILTER_BITMAP_FLAG
bit mask for the flag enabling bitmap filtering |
static int |
LINEAR_TEXT_FLAG
bit mask for the flag enabling linear-text (no caching) |
(package private) int |
mNativePaint
|
static int |
STRIKE_THRU_TEXT_FLAG
bit mask for the flag enabling strike-thru text |
static int |
SUBPIXEL_TEXT_FLAG
bit mask for the flag enabling subpixel-text |
static int |
UNDERLINE_TEXT_FLAG
bit mask for the flag enabling underline text |
| Constructor Summary | |
|---|---|
Paint()
Create a new paint with default settings. |
|
Paint(int flags)
Create a new paint with the specified flags. |
|
Paint(Paint paint)
Create a new paint, initialized with the attributes in the specified paint parameter. |
|
| Method Summary | |
|---|---|
float |
ascent()
Return the distance above (negative) the baseline (ascent) based on the current typeface and text size. |
int |
breakText(char[] text,
int index,
int count,
float maxWidth,
float[] measuredWidth)
Measure the text, stopping early if the measured width exceeds maxWidth. |
int |
breakText(CharSequence text,
int start,
int end,
boolean measureForwards,
float maxWidth,
float[] measuredWidth)
Measure the text, stopping early if the measured width exceeds maxWidth. |
int |
breakText(String text,
boolean measureForwards,
float maxWidth,
float[] measuredWidth)
Measure the text, stopping early if the measured width exceeds maxWidth. |
void |
clearShadowLayer()
Temporary API to clear the shadow layer. |
float |
descent()
Return the distance below (positive) the baseline (descent) based on the current typeface and text size. |
protected void |
finalize()
Called by the virtual machine when there are no longer any (non-weak) references to the receiver. |
int |
getAlpha()
Helper to getColor() that just returns the color's alpha value. |
int |
getColor()
Return the paint's color. |
ColorFilter |
getColorFilter()
Get the paint's colorfilter (maybe be null). |
boolean |
getFillPath(Path src,
Path dst)
Applies any/all effects (patheffect, stroking) to src, returning the result in dst. |
int |
getFlags()
Return the paint's flags. |
Paint.FontMetrics |
getFontMetrics()
Allocates a new FontMetrics object, and then calls getFontMetrics(fm) with it, returning the object. |
float |
getFontMetrics(Paint.FontMetrics metrics)
Return the font's recommended interline spacing, given the Paint's settings for typeface, textSize, etc. |
Paint.FontMetricsInt |
getFontMetricsInt()
|
int |
getFontMetricsInt(Paint.FontMetricsInt fmi)
Return the font's interline spacing, given the Paint's settings for typeface, textSize, etc. |
float |
getFontSpacing()
Return the recommend line spacing based on the current typeface and text size. |
MaskFilter |
getMaskFilter()
Get the paint's maskfilter object. |
PathEffect |
getPathEffect()
Get the paint's patheffect object. |
Rasterizer |
getRasterizer()
Get the paint's rasterizer (or null). |
Shader |
getShader()
Get the paint's shader object. |
Paint.Cap |
getStrokeCap()
Return the paint's Cap, controlling how the start and end of stroked lines and paths are treated. |
Paint.Join |
getStrokeJoin()
Return the paint's stroke join type. |
float |
getStrokeMiter()
Return the paint's stroke miter value. |
float |
getStrokeWidth()
Return the width for stroking. |
Paint.Style |
getStyle()
Return the paint's style, used for controlling how primitives' geometries are interpreted (except for drawBitmap, which always assumes FILL_STYLE). |
Paint.Align |
getTextAlign()
Return the paint's Align value for drawing text. |
void |
getTextBounds(char[] text,
int index,
int count,
Rect bounds)
Return in bounds (allocated by the caller) the smallest rectangle that encloses all of the characters, with an implied origin at (0,0). |
void |
getTextBounds(String text,
int start,
int end,
Rect bounds)
Return in bounds (allocated by the caller) the smallest rectangle that encloses all of the characters, with an implied origin at (0,0). |
void |
getTextPath(char[] text,
int index,
int count,
float x,
float y,
Path path)
Return the path (outline) for the specified text. |
void |
getTextPath(String text,
int start,
int end,
float x,
float y,
Path path)
Return the path (outline) for the specified text. |
float |
getTextScaleX()
Return the paint's horizontal scale factor for text. |
float |
getTextSize()
Return the paint's text size. |
float |
getTextSkewX()
Return the paint's horizontal skew factor for text. |
int |
getTextWidths(char[] text,
int index,
int count,
float[] widths)
Return the advance widths for the characters in the string. |
int |
getTextWidths(CharSequence text,
int start,
int end,
float[] widths)
Return the advance widths for the characters in the string. |
int |
getTextWidths(String text,
float[] widths)
Return the advance widths for the characters in the string. |
int |
getTextWidths(String text,
int start,
int end,
float[] widths)
Return the advance widths for the characters in the string. |
Typeface |
getTypeface()
Get the paint's typeface object. |
Xfermode |
getXfermode()
Get the paint's xfermode object. |
boolean |
isAntiAlias()
Helper for getFlags(), returning true if ANTI_ALIAS_FLAG bit is set AntiAliasing smooths out the edges of what is being drawn, but is has no impact on the interior of the shape. |
boolean |
isDither()
Helper for getFlags(), returning true if DITHER_FLAG bit is set Dithering affects how colors that are higher precision than the device are down-sampled. |
boolean |
isFakeBoldText()
Helper for getFlags(), returning true if FAKE_BOLD_TEXT_FLAG bit is set |
boolean |
isFilterBitmap()
Whether or not the bitmap filter is activated. |
boolean |
isLinearText()
Helper for getFlags(), returning true if LINEAR_TEXT_FLAG bit is set |
boolean |
isStrikeThruText()
Helper for getFlags(), returning true if STRIKE_THRU_TEXT_FLAG bit is set |
boolean |
isSubpixelText()
Helper for getFlags(), returning true if SUBPIXEL_TEXT_FLAG bit is set |
boolean |
isUnderlineText()
Helper for getFlags(), returning true if UNDERLINE_TEXT_FLAG bit is set |
float |
measureText(char[] text,
int index,
int count)
Return the width of the text. |
float |
measureText(CharSequence text,
int start,
int end)
Return the width of the text. |
float |
measureText(String text)
Return the width of the text. |
float |
measureText(String text,
int start,
int end)
Return the width of the text. |
void |
reset()
Restores the paint to its default settings. |
void |
set(Paint src)
Copy the fields from src into this paint. |
void |
setAlpha(int a)
Helper to setColor(), that only assigns the color's alpha value, leaving its r,g,b values unchanged. |
void |
setAntiAlias(boolean aa)
Helper for setFlags(), setting or clearing the ANTI_ALIAS_FLAG bit AntiAliasing smooths out the edges of what is being drawn, but is has no impact on the interior of the shape. |
void |
setARGB(int a,
int r,
int g,
int b)
Helper to setColor(), that takes a,r,g,b and constructs the color int |
void |
setColor(int color)
Set the paint's color. |
ColorFilter |
setColorFilter(ColorFilter filter)
Set or clear the paint's colorfilter, returning the parameter. |
void |
setDither(boolean dither)
Helper for setFlags(), setting or clearing the DITHER_FLAG bit Dithering affects how colors that are higher precision than the device are down-sampled. |
void |
setFakeBoldText(boolean fakeBoldText)
Helper for setFlags(), setting or clearing the STRIKE_THRU_TEXT_FLAG bit |
void |
setFilterBitmap(boolean filter)
Helper for setFlags(), setting or clearing the FILTER_BITMAP_FLAG bit. |
void |
setFlags(int flags)
Set the paint's flags. |
void |
setLinearText(boolean linearText)
Helper for setFlags(), setting or clearing the LINEAR_TEXT_FLAG bit |
MaskFilter |
setMaskFilter(MaskFilter maskfilter)
Set or clear the maskfilter object. |
PathEffect |
setPathEffect(PathEffect effect)
Set or clear the patheffect object. |
Rasterizer |
setRasterizer(Rasterizer rasterizer)
Set or clear the rasterizer object. |
Shader |
setShader(Shader shader)
Set or clear the shader object. |
void |
setShadowLayer(float radius,
float dx,
float dy,
int color)
Temporary API to expose layer drawing. |
void |
setStrikeThruText(boolean strikeThruText)
Helper for setFlags(), setting or clearing the STRIKE_THRU_TEXT_FLAG bit |
void |
setStrokeCap(Paint.Cap cap)
Set the paint's Cap. |
void |
setStrokeJoin(Paint.Join join)
Set the paint's Join. |
void |
setStrokeMiter(float miter)
Set the paint's stroke miter value. |
void |
setStrokeWidth(float width)
Set the width for stroking. |
void |
setStyle(Paint.Style style)
Set the paint's style, used for controlling how primitives' geometries are interpreted (except for drawBitmap, which always assumes Fill). |
void |
setSubpixelText(boolean subpixelText)
Helper for setFlags(), setting or clearing the SUBPIXEL_TEXT_FLAG bit |
void |
setTextAlign(Paint.Align align)
Set the paint's text alignment. |
void |
setTextScaleX(float scaleX)
Set the paint's horizontal scale factor for text. |
void |
setTextSize(float textSize)
Set the paint's text size. |
void |
setTextSkewX(float skewX)
Set the paint's horizontal skew factor for text. |
Typeface |
setTypeface(Typeface typeface)
Set or clear the typeface object. |
void |
setUnderlineText(boolean underlineText)
Helper for setFlags(), setting or clearing the UNDERLINE_TEXT_FLAG bit |
Xfermode |
setXfermode(Xfermode xfermode)
Set or clear the xfermode object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
int mNativePaint
public static final int ANTI_ALIAS_FLAG
public static final int FILTER_BITMAP_FLAG
public static final int DITHER_FLAG
public static final int UNDERLINE_TEXT_FLAG
public static final int STRIKE_THRU_TEXT_FLAG
public static final int FAKE_BOLD_TEXT_FLAG
public static final int LINEAR_TEXT_FLAG
public static final int SUBPIXEL_TEXT_FLAG
public static final int DEV_KERN_TEXT_FLAG
| Constructor Detail |
|---|
public Paint()
public Paint(int flags)
flags - initial flag bits, as if they were passed via setFlags().public Paint(Paint paint)
paint - Existing paint used to initialized the attributes of the
new paint.| Method Detail |
|---|
public void reset()
public void set(Paint src)
public int getFlags()
public void setFlags(int flags)
flags - The new flag bits for the paintpublic final boolean isAntiAlias()
public void setAntiAlias(boolean aa)
aa - true to set the antialias bit in the flags, false to clear itpublic final boolean isDither()
public void setDither(boolean dither)
dither - true to set the dithering bit in flags, false to clear itpublic final boolean isLinearText()
public void setLinearText(boolean linearText)
linearText - true to set the linearText bit in the paint's flags,
false to clear it.public final boolean isSubpixelText()
public void setSubpixelText(boolean subpixelText)
subpixelText - true to set the subpixelText bit in the paint's
flags, false to clear it.public final boolean isUnderlineText()
public void setUnderlineText(boolean underlineText)
underlineText - true to set the underlineText bit in the paint's
flags, false to clear it.public final boolean isStrikeThruText()
public void setStrikeThruText(boolean strikeThruText)
strikeThruText - true to set the strikeThruText bit in the paint's
flags, false to clear it.public final boolean isFakeBoldText()
public void setFakeBoldText(boolean fakeBoldText)
fakeBoldText - true to set the fakeBoldText bit in the paint's
flags, false to clear it.public final boolean isFilterBitmap()
setFilterBitmap()public void setFilterBitmap(boolean filter)
filter - true to set the FILTER_BITMAP_FLAG bit in the paint's
flags, false to clear it.public Paint.Style getStyle()
public void setStyle(Paint.Style style)
style - The new style to set in the paintpublic int getColor()
public void setColor(int color)
color - The new color (including alpha) to set in the paint.public int getAlpha()
public void setAlpha(int a)
a - set the alpha component [0..255] of the paint's color.
public void setARGB(int a,
int r,
int g,
int b)
a - The new alpha component (0..255) of the paint's color.r - The new red component (0..255) of the paint's color.g - The new green component (0..255) of the paint's color.b - The new blue component (0..255) of the paint's color.public float getStrokeWidth()
public void setStrokeWidth(float width)
width - set the paint's stroke width, used whenever the paint's
style is Stroke or StrokeAndFill.public float getStrokeMiter()
public void setStrokeMiter(float miter)
miter - set the miter limit on the paint, used whenever the paint's
style is Stroke or StrokeAndFill.public Paint.Cap getStrokeCap()
public void setStrokeCap(Paint.Cap cap)
cap - set the paint's line cap style, used whenever the paint's
style is Stroke or StrokeAndFill.public Paint.Join getStrokeJoin()
public void setStrokeJoin(Paint.Join join)
join - set the paint's Join, used whenever the paint's style is
Stroke or StrokeAndFill.
public boolean getFillPath(Path src,
Path dst)
src - input pathdst - output path (may be the same as src)
public Shader getShader()
public Shader setShader(Shader shader)
shader - May be null. the new shader to be installed in the paint
public ColorFilter getColorFilter()
public ColorFilter setColorFilter(ColorFilter filter)
filter - May be null. The new filter to be installed in the paint
public Xfermode getXfermode()
public Xfermode setXfermode(Xfermode xfermode)
xfermode - May be null. The xfermode to be installed in the paint
public PathEffect getPathEffect()
public PathEffect setPathEffect(PathEffect effect)
effect - May be null. The patheffect to be installed in the paint
public MaskFilter getMaskFilter()
public MaskFilter setMaskFilter(MaskFilter maskfilter)
maskfilter - May be null. The maskfilter to be installed in the
paint
public Typeface getTypeface()
public Typeface setTypeface(Typeface typeface)
typeface - May be null. The typeface to be installed in the paint
public Rasterizer getRasterizer()
public Rasterizer setRasterizer(Rasterizer rasterizer)
rasterizer - May be null. The new rasterizer to be installed in
the paint.
public void setShadowLayer(float radius,
float dx,
float dy,
int color)
public void clearShadowLayer()
public Paint.Align getTextAlign()
public void setTextAlign(Paint.Align align)
align - set the paint's Align value for drawing text.public float getTextSize()
public void setTextSize(float textSize)
textSize - set the paint's text size.public float getTextScaleX()
public void setTextScaleX(float scaleX)
scaleX - set the paint's scale in X for drawing/measuring text.public float getTextSkewX()
public void setTextSkewX(float skewX)
skewX - set the paint's skew factor in X for drawing text.public float ascent()
public float descent()
public float getFontMetrics(Paint.FontMetrics metrics)
metrics - If this object is not null, its fields are filled with
the appropriate values given the paint's text attributes.
public Paint.FontMetrics getFontMetrics()
public int getFontMetricsInt(Paint.FontMetricsInt fmi)
public Paint.FontMetricsInt getFontMetricsInt()
public float getFontSpacing()
public float measureText(char[] text,
int index,
int count)
text - The text to measureindex - The index of the first character to start measuringcount - THe number of characters to measure, beginning with start
public float measureText(String text,
int start,
int end)
text - The text to measurestart - The index of the first character to start measuringend - 1 beyond the index of the last character to measure
public float measureText(String text)
text - The text to measure
public float measureText(CharSequence text,
int start,
int end)
text - The text to measurestart - The index of the first character to start measuringend - 1 beyond the index of the last character to measure
public int breakText(char[] text,
int index,
int count,
float maxWidth,
float[] measuredWidth)
text - The text to measureindex - The offset into text to begin measuring atcount - The number of maximum number of entries to measure. If count
is negative, then the characters before index are measured
in reverse order. This allows for measuring the end of
string.maxWidth - The maximum width to accumulate.measuredWidth - Optional. If not null, returns the actual width
measured.
public int breakText(CharSequence text,
int start,
int end,
boolean measureForwards,
float maxWidth,
float[] measuredWidth)
text - The text to measurestart - The offset into text to begin measuring atend - The end of the text slice to measure.measureForwards - If true, measure forwards, starting at start.
Otherwise, measure backwards, starting with end.maxWidth - The maximum width to accumulate.measuredWidth - Optional. If not null, returns the actual width
measured.
public int breakText(String text,
boolean measureForwards,
float maxWidth,
float[] measuredWidth)
text - The text to measuremeasureForwards - If true, measure forwards, starting at index.
Otherwise, measure backwards, starting with the
last character in the string.maxWidth - The maximum width to accumulate.measuredWidth - Optional. If not null, returns the actual width
measured.
public int getTextWidths(char[] text,
int index,
int count,
float[] widths)
text - The text to measureindex - The index of the first char to to measurecount - The number of chars starting with index to measurewidths - array to receive the advance widths of the characters.
Must be at least a large as count.
public int getTextWidths(CharSequence text,
int start,
int end,
float[] widths)
text - The text to measurestart - The index of the first char to to measureend - The end of the text slice to measurewidths - array to receive the advance widths of the characters.
Must be at least a large as (end - start).
public int getTextWidths(String text,
int start,
int end,
float[] widths)
text - The text to measurestart - The index of the first char to to measureend - The end of the text slice to measurewidths - array to receive the advance widths of the characters.
Must be at least a large as the text.
public int getTextWidths(String text,
float[] widths)
text - The text to measurewidths - array to receive the advance widths of the characters.
Must be at least a large as the text.
public void getTextPath(char[] text,
int index,
int count,
float x,
float y,
Path path)
text - The text to retrieve the path fromindex - The index of the first character in textcount - The number of characterss starting with indexx - The x coordinate of the text's originy - The y coordinate of the text's originpath - The path to receive the data describing the text. Must
be allocated by the caller.
public void getTextPath(String text,
int start,
int end,
float x,
float y,
Path path)
text - The text to retrieve the path fromstart - The first character in the textend - 1 past the last charcter in the textx - The x coordinate of the text's originy - The y coordinate of the text's originpath - The path to receive the data describing the text. Must
be allocated by the caller.
public void getTextBounds(String text,
int start,
int end,
Rect bounds)
text - String to measure and return its boundsstart - Index of the first char in the string to measureend - 1 past the last char in the string measurebounds - Returns the unioned bounds of all the text. Must be
allocated by the caller.
public void getTextBounds(char[] text,
int index,
int count,
Rect bounds)
text - Array of chars to measure and return their unioned boundsindex - Index of the first char in the array to measurecount - The number of chars, beginning at index, to measurebounds - Returns the unioned bounds of all the text. Must be
allocated by the caller.
protected void finalize()
throws Throwable
ObjectNote: The virtual machine assumes that the implementation in class Object is empty.
finalize in class ObjectThrowable - The virtual machine ignores any exceptions which are
thrown during finalization.
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||