|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanger.ui.Pen
public abstract class Pen
Basic drawing primitives. This class implements the basic drawing primitives that would normally be found in the abstract windowing toolbox.
| Field Summary | |
|---|---|
static int |
HINT_DEFAULT
Default rendering. |
static int |
HINT_FAST_ALPHA_GLYPHS
Signal that we are displaying fonts on a plain black or white background, and may be able to use a faster glyph rendering function. |
static int |
HINT_FONT_ANTIALIAS_OFF
Turn off font anti-aliasing. |
static int |
HORIZONTAL
Specify that a gradient should be horizontal. |
static int |
ROUND_END
Specify that the ending corners (bottom for vertical gradients and right for horizontal gradients) should be round instead of square. |
static int |
ROUND_START
Specify that the starting corners (top for vertical gradients and left for horizontal gradients) should be round instead of square. |
static int |
VERTICAL
Specify that a gradient should be vertical. |
| Constructor Summary | |
|---|---|
Pen()
|
|
| Method Summary | |
|---|---|
abstract Pen |
clonePen()
Clone the current pen. |
protected abstract void |
copy(Pen from)
|
abstract void |
drawArc(int left,
int top,
int right,
int bottom,
int startAngle,
int arcAngle)
|
void |
drawArc(Rect bounds,
int startAngle,
int arcAngle)
|
abstract void |
drawBitmap(int x,
int y,
Bitmap bm)
Draw a bitmap. |
abstract void |
drawBitmap(int x,
int y,
Bitmap inBitmap,
boolean inInverted)
Draw a bitmap that may be inverted. |
void |
drawBitmap(int x,
int y,
Bitmap inBitmap,
int weight)
Translucently draw a Bitmap. |
void |
drawBitmap(int x,
int y,
Bitmap bm1,
int w1,
Bitmap bm2,
int w2)
Draw a blend of two Bitmaps. |
abstract void |
drawBitmap(int x,
int y,
Bitmap bm,
int left,
int top,
int right,
int bottom)
Draw a portion of a bitmap. |
void |
drawBitmap(int x,
int y,
Bitmap bm,
Rect r)
|
abstract int |
drawChar(int x,
int y,
char c)
Draw a character. |
abstract void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draw a line. |
abstract void |
drawOval(int left,
int top,
int right,
int bottom)
Draw an oval. |
void |
drawOval(Rect r)
Draw an oval. |
abstract void |
drawPoint(int x,
int y)
Draw a point. |
void |
drawPoint(Point p)
Draw a point. |
abstract void |
drawPoly(int[] x,
int[] y)
Draw a polygon. |
abstract void |
drawRect(int left,
int top,
int right,
int bottom)
Draw a rectangle. |
void |
drawRect(Rect r)
Draw a rectangle. |
abstract void |
drawRoundRect(int left,
int top,
int right,
int bottom,
int arcWidth,
int arcHeight)
Draw a round-cornered rectangle. |
void |
drawRoundRect(Rect r,
int arcWidth,
int arcHeight)
Draw a round-cornered rectangle. |
int |
drawText(int x,
int y,
byte[] data,
int offset,
int length)
Draw a string. |
int |
drawText(int x,
int y,
char[] data,
int offset,
int length)
Draw a string. |
int |
drawText(int x,
int y,
CharSequence str)
|
int |
drawText(int x,
int y,
CharSequence cs,
int offset,
int len)
|
abstract int |
drawText(int x,
int y,
String str)
Draw a string. |
int |
drawText(int x,
int y,
String s,
int offset,
int len)
|
abstract void |
drawTriangle(int x1,
int y1,
int x2,
int y2,
int x3,
int y3)
Draw a triangle. |
abstract void |
fillArc(int left,
int top,
int right,
int bottom,
int startAngle,
int arcAngle)
|
void |
fillArc(Rect bounds,
int startAngle,
int arcAngle)
|
void |
fillGradientRect(Rect rect,
int orientation,
int startColor,
int endColor)
Draw a simple gradient inside the rectangle. |
void |
fillGradientRoundRect(Rect rect,
int orientation,
int arcSize,
int startColor,
int endColor)
Draw a simple gradient with rounded corners inside the rectangle. |
abstract void |
fillOval(int left,
int top,
int right,
int bottom)
Fill an oval. |
void |
fillOval(Rect r)
Fill an oval. |
abstract void |
fillPoly(int[] x,
int[] y)
Fill a polygon. |
abstract void |
fillRect(int left,
int top,
int right,
int bottom)
Fill a rectangle. |
void |
fillRect(Rect r)
Fill a rectangle. |
abstract void |
fillRoundRect(int left,
int top,
int right,
int bottom,
int arcWidth,
int arcHeight)
Fill a round-cornered rectangle. |
void |
fillRoundRect(Rect r,
int arcWidth,
int arcHeight)
Fill a round-cornered rectangle. |
void |
fillSplitGradientRect(Rect rect,
int orientation,
int cornerOptions,
int arcSize,
int[] colorsAndPositions)
Draw a gradient split in multiple parts inside the rectangle. |
void |
fillSplitGradientRect(Rect rect,
int orientation,
int cornerOptions,
int arcSize,
int[] colors,
int[] positionPcts)
Draw a gradient split in multiple parts inside the rectangle. |
abstract void |
fillTexturedPoly(Bitmap sourceMap,
int[] x,
int[] y,
int[] u,
int[] v)
Fill a polygon with a Textured bitmap Fill a polygon from a list of coordinates passed in using a bitmap as a texture. |
abstract void |
fillTexturedPoly(Bitmap sourceMap,
int[] x,
int[] y,
int[] u,
int[] v,
int vertexOffset,
int numVertexes)
Fill a polygon with a Textured bitmap Fill a polygon from a list of coordinates passed in using a bitmap as a texture. |
abstract void |
fillTriangle(int x1,
int y1,
int x2,
int y2,
int x3,
int y3)
Fill a triangle. |
Rect |
getClip()
Get the clipping rectangle in local coordinates. |
abstract Rect |
getClip(Rect rect)
Get the clipping rectangle in local coordinates. |
Rect |
getClipGlobal()
Get the clipping rectangle in global coordinates. |
abstract Rect |
getClipGlobal(Rect rect)
Get the clipping rectangle in global coordinates. |
abstract int |
getColor()
|
abstract Font |
getFont()
Get the current font. |
abstract int |
getLeft()
Get the horizontal offset of the pen. |
abstract int |
getRenderHints()
Get this Pen's rendering hints. |
abstract int |
getTextOutlineColor()
|
abstract int |
getTextShadowColor()
Get the current shadow color used when rendering a font with F_SHADOW. |
abstract int |
getTextureColor()
Get the current texture color used when rendering with fillTexturedPoly(). |
abstract int |
getTop()
Get the vertical offset of the pen. |
abstract int |
getVisibleBottom()
return the last visible line (in local coordinates) |
abstract void |
getVisibleRect(Rect r)
return a rectangle that encloses all the visible points (in local coordinates) |
abstract int |
getVisibleTop()
return the first visible line (in local coordinates) |
boolean |
isClipEmpty()
returns true if *nothing* will be drawn with this pen |
abstract boolean |
isDashed()
Query the state of dashed-style drawing. |
int |
maxStack()
|
abstract void |
offset(int dx,
int dy)
Offset coordinate space. |
void |
pop()
Restores the last copy of this pen saved on the statestack. |
void |
popAll()
Pops all saved state off the statestack |
void |
push()
Saves a copy of this pen on the statestack. |
void |
setClip(int l,
int t,
int r,
int b)
Adjust the clip-rect of the Pen using local coordinates. |
abstract void |
setClipGlobal(int l,
int t,
int r,
int b)
Adjust the clip-rect of the Pen using global coordinates. |
void |
setColor(Color c)
|
void |
setColor(int color)
|
void |
setColor(int r,
int g,
int b)
|
void |
setColor(int r,
int g,
int b,
int a)
|
abstract void |
setColorAlpha(int color)
Set the pen drawing color. |
void |
setColorAlpha(int color,
int alpha)
|
abstract void |
setDashed(boolean dashed)
enable/disable dashed-style drawing |
abstract void |
setFont(Font f)
Set the current font. |
abstract void |
setRenderHints(int hints)
Set this Pen's rendering hints. |
abstract void |
setSize(int inWidth,
int inHeight)
Set the current pen size. |
void |
setTextOutlineColor(Color c)
|
abstract void |
setTextOutlineColor(int color)
Set the current outline text color. |
void |
setTextOutlineColor(int r,
int g,
int b)
|
abstract void |
setTextShadowColor(int packedColor)
Set the current shadow color used when rendering a font with F_SHADOW. |
void |
setTextShadowColor(int r,
int g,
int b)
Set the current shadow color used when rendering a font with F_SHADOW. |
abstract void |
setTextureColor(int packedColor)
Set the current texture color used when rendering with fillTexturedPoly(). |
void |
setTextureColor(int r,
int g,
int b)
Set the current texture color used when rendering with fillTexturedPoly(). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int HINT_DEFAULT
setRenderHints(int)
public static final int HINT_FONT_ANTIALIAS_OFF
setRenderHints(int)
public static final int HINT_FAST_ALPHA_GLYPHS
setRenderHints(int)
public static final int VERTICAL
fillGradientRect(danger.ui.Rect, int, int, int),
fillGradientRoundRect(danger.ui.Rect, int, int, int, int), and
fillSplitGradientRect(danger.ui.Rect, int, int, int, int[]).
public static final int HORIZONTAL
fillGradientRect(danger.ui.Rect, int, int, int),
fillGradientRoundRect(danger.ui.Rect, int, int, int, int), and
fillSplitGradientRect(danger.ui.Rect, int, int, int, int[]).
public static final int ROUND_START
public static final int ROUND_END
| Constructor Detail |
|---|
public Pen()
| Method Detail |
|---|
public abstract void drawPoint(int x,
int y)
public abstract void drawLine(int x1,
int y1,
int x2,
int y2)
x1 - An integer specifying the beginning x location in pixels.x2 - An integer specifying the ending x location in pixels.y1 - An integer specifying the beginning y location in pixels.y2 - An integer specifying the ending y location in pixels.
public abstract void drawRect(int left,
int top,
int right,
int bottom)
left - An integer specifying the left coordinate of the rectangle.top - An integer specifying the top coordinate of the rectangle.right - An integer specifying the right coordinate of the rectangle.bottom - An integer specifying the bottom coordinate of the rectangle.
public abstract void fillRect(int left,
int top,
int right,
int bottom)
left - An integer specifying the left coordinate of the rectangle.top - An integer specifying the top coordinate of the rectangle.right - An integer specifying the right coordinate of the rectangle.bottom - An integer specifying the bottom coordinate of the rectangle.
public void fillGradientRect(Rect rect,
int orientation,
int startColor,
int endColor)
orientation should be VERTICAL or
HORIZONTAL.
If the gradient is vertical, then startColor is
the color of the leftmost
line, and endColor is the color of the rightmost
line. If the gradient is horizontal, then startColor
is the color of the
topmost line, and endColor is the color of the
bottommost line.
public void fillGradientRoundRect(Rect rect,
int orientation,
int arcSize,
int startColor,
int endColor)
orientation should be VERTICAL or
HORIZONTAL.
If the gradient is vertical, then startColor is
the color of the leftmost
line, and endColor is the color of the rightmost
line. If the gradient is horizontal, then startColor
is the color of the
topmost line, and endColor is the color of the
bottommost line.
public void fillSplitGradientRect(Rect rect,
int orientation,
int cornerOptions,
int arcSize,
int[] colorsAndPositions)
fillGradientRoundRect(danger.ui.Rect, int, int, int, int) for an explanation of the first
four parameters.
colorsAndPositions defines the colors and inflection
points. colorsAndPositions[0] defines the starting color.
colorsAndPositions[1] defines the placement of the first
inflection point, as a percentage of distance between the start and
end points. colorsAndPositions[2] defines the color of
the first inflection point. The last value in the array defines the
color at the end point. The length of the array must be even.
cornerOptions can include ROUND_START and
ROUND_END. If not otherwise specified, corners are square.
This method is basically the same as
fillSplitGradientRect(Rect,int,int,int,int[],int[]); it simply
provides a convenient way to pass in the colors and positions as one
array instead of two.
public void fillSplitGradientRect(Rect rect,
int orientation,
int cornerOptions,
int arcSize,
int[] colors,
int[] positionPcts)
fillGradientRoundRect(danger.ui.Rect, int, int, int, int) for an explanation of the first
four parameters.
colors[0] defines the starting color. The other colors
in the array define the colors at the inflection points and the
end color.
positionPcts[0] defines the placement of the first
inflection point, as a percentage of distance between the start and
end points. The size of positionPcts should be 2 less
than the size of colors.
cornerOptions can include ROUND_START and
ROUND_END. If not otherwise specified, corners are square.
public abstract void drawOval(int left,
int top,
int right,
int bottom)
left - An integer specifying the left coordinate of the oval.top - An integer specifying the top coordinate of the oval.right - An integer specifying the right coordinate of the oval.bottom - An integer specifying the bottom coordinate of the oval.
public abstract void drawArc(int left,
int top,
int right,
int bottom,
int startAngle,
int arcAngle)
public void drawArc(Rect bounds,
int startAngle,
int arcAngle)
public abstract void fillArc(int left,
int top,
int right,
int bottom,
int startAngle,
int arcAngle)
public void fillArc(Rect bounds,
int startAngle,
int arcAngle)
public abstract void fillOval(int left,
int top,
int right,
int bottom)
left - An integer specifying the left coordinate of the oval.top - An integer specifying the top coordinate of the oval.right - An integer specifying the right coordinate of the oval.bottom - An integer specifying the bottom coordinate of the oval.
public abstract int drawChar(int x,
int y,
char c)
x - An integer specifying the x location for the character in pixels.y - An integer specifying the y location for the character in pixels.c - A char specifying the Unicode character to be drawn.
public abstract int drawText(int x,
int y,
String str)
x - An integer specifying the x location for the string in pixels.y - An integer specifying the y location for the string in pixels.str - A String specifying the Unicode character string to be drawn.
public int drawText(int x,
int y,
CharSequence str)
public int drawText(int x,
int y,
String s,
int offset,
int len)
public int drawText(int x,
int y,
CharSequence cs,
int offset,
int len)
public int drawText(int x,
int y,
byte[] data,
int offset,
int length)
x - An integer specifying the x location for the string in pixels.y - An integer specifying the y location for the string in pixels.data - Array of UTF-8 encoded Unicode chars to drawoffset - Offset into chars arraylength - Number of chars in chars array to draw
public int drawText(int x,
int y,
char[] data,
int offset,
int length)
x - An integer specifying the x location for the string in pixels.y - An integer specifying the y location for the string in pixels.data - Array of Unicode chars to drawoffset - Offset into chars arraylength - Number of chars in chars array to draw
public abstract void drawBitmap(int x,
int y,
Bitmap bm)
x - An integer specifying the x location for the bitmap in pixels.y - An integer specifying the y location for the bitmap in pixels.bm - A Bitmap specifying the bitmap to be drawn.
public abstract void drawBitmap(int x,
int y,
Bitmap bm,
int left,
int top,
int right,
int bottom)
x - An integer specifying the x location for the bitmap in pixels.y - An integer specifying the y location for the bitmap in pixels.bm - A Bitmap specifying the bitmap to be drawn.left - An integer specifying the left coordinate of the source rectangle.top - An integer specifying the top coordinate of the source rectangle.right - An integer specifying the right coordinate of the source rectangle.bottom - An integer specifying the bottom coordinate of the source rectangle.
public void drawBitmap(int x,
int y,
Bitmap bm,
Rect r)
public abstract void drawBitmap(int x,
int y,
Bitmap inBitmap,
boolean inInverted)
x - An integer specifying the x location for the bitmap in pixels.y - An integer specifying the y location for the bitmap in pixels.inBitmap - A Bitmap specifying the bitmap to be drawn.inInverted - A boolean specifying whether or not to invert the bitmap.
public void drawBitmap(int x,
int y,
Bitmap inBitmap,
int weight)
x - An integer specifying the x location for the bitmap in pixels.y - An integer specifying the y location for the bitmap in pixels.inBitmap - A Bitmap specifying the bitmap to be drawn.weight - The alpha value for the Bitmap. A value of 0 results in
no drawing. A value of 255 is equivalent to an opaque draw.
public void drawBitmap(int x,
int y,
Bitmap bm1,
int w1,
Bitmap bm2,
int w2)
x - An integer specifying the x location for the bitmaps in pixels.y - An integer specifying the y location for the bitmaps in pixels.bm1 - The first Bitmap to draw.w1 - The weight for the first Bitmap. Note that the Bitmap is not
actually drawn with this weight. The value of this parameter is
merely checked to see if, when added to w2, the sum is 255.bm2 - The second Bitmap to draw.w2 - The weight for the second Bitmap.
public abstract void drawRoundRect(int left,
int top,
int right,
int bottom,
int arcWidth,
int arcHeight)
left - An integer specifying the left coordinate of the rectangle.top - An integer specifying the top coordinate of the rectangle.right - An integer specifying the right coordinate of the rectangle.bottom - An integer specifying the bottom coordinate of the rectangle.arcWidth - An integer specifying the width of the arc to be used for the corners.arcHeight - An integer specifying the height of the arc to be used for the corners.
public abstract void fillRoundRect(int left,
int top,
int right,
int bottom,
int arcWidth,
int arcHeight)
left - An integer specifying the left coordinate of the rectangle.top - An integer specifying the top coordinate of the rectangle.right - An integer specifying the right coordinate of the rectangle.bottom - An integer specifying the bottom coordinate of the rectangle.arcWidth - An integer specifying the width of the arc to be used for the corners.arcHeight - An integer specifying the height of the arc to be used for the corners.public void drawRect(Rect r)
r - A Rect specifying the coordinates of the rectangle.public void drawPoint(Point p)
public void fillRect(Rect r)
r - A Rect specifying the coordinates of the rectangle.public void drawOval(Rect r)
r - A Rect specifying the coordinates of the rectangle.public void fillOval(Rect r)
r - A Rect specifying the coordinates of the rectangle.
public void drawRoundRect(Rect r,
int arcWidth,
int arcHeight)
r - A Rect specifying the coordinates of the rectangle.arcWidth - An integer specifying the width of the arc to be used for the corners.arcHeight - An integer specifying the height of the arc to be used for the corners.
public void fillRoundRect(Rect r,
int arcWidth,
int arcHeight)
r - A Rect specifying the coordinates of the rectangle.arcWidth - An integer specifying the width of the arc to be used for the corners.arcHeight - An integer specifying the height of the arc to be used for the corners.
public abstract void drawTriangle(int x1,
int y1,
int x2,
int y2,
int x3,
int y3)
drawPoly.
x1 - the x coordinate of the first vertexy1 - the y coordinate of the first vertexx2 - the x coordinate of the second vertexy2 - the y coordinate of the second vertexx3 - the x coordinate of the third vertexy3 - the y coordinate of the third vertex
public abstract void fillTriangle(int x1,
int y1,
int x2,
int y2,
int x3,
int y3)
fillPoly.
x1 - the x coordinate of the first vertexy1 - the y coordinate of the first vertexx2 - the x coordinate of the second vertexy2 - the y coordinate of the second vertexx3 - the x coordinate of the third vertexy3 - the y coordinate of the third vertex
public abstract void drawPoly(int[] x,
int[] y)
x - An integer array of x coordinates.y - An integer array of y coordinates.
public abstract void fillPoly(int[] x,
int[] y)
x - An integer array of x coordinates.y - An integer array of y coordinates.
public abstract void fillTexturedPoly(Bitmap sourceMap,
int[] x,
int[] y,
int[] u,
int[] v)
sourceMap - An Bitmap.x - An integer array of x coordinates that mark the polygon.y - An integer array of y coordinates that mark the polygon.u - An integer array of x coordinates in the source Bitmap's
coordinates space.v - An integer array of y coordinates in the source Bitmap's
coordinates space.
x/y vertices must run in a clockwise direction
This is a tweaked port of Michael Abrash's DDA from chapter 56 of the _Graphics Programming Black Book (Special Edition)_ Also Dr Dobbs Journal September 1992.
public abstract void fillTexturedPoly(Bitmap sourceMap,
int[] x,
int[] y,
int[] u,
int[] v,
int vertexOffset,
int numVertexes)
sourceMap - An Bitmap.x - An integer array of x coordinates that mark the polygon.y - An integer array of y coordinates that mark the polygon.u - An integer array of x coordinates in the source Bitmap's
coordinates space.v - An integer array of y coordinates in the source Bitmap's
coordinates space.vertexOffset - An integer that is the starting index when
reading from the []x, []y, []u, and []v arrays.numVertexes - An integer for how many vertexes to read.
Example for vertexOffset and numVertexes would be 0 and length of all
arrays, which is the same as calling fillTexturedPoly() without
these last two parameters.
x/y vertices must run in a clockwise direction
This is a tweaked port of Michael Abrash's DDA from chapter 56 of the _Graphics Programming Black Book (Special Edition)_ Also Dr Dobbs Journal September 1992.
public abstract void offset(int dx,
int dy)
dx - An integer specifying the delta for the x origin.dy - An integer specifying the delta for the y origin.public Rect getClipGlobal()
public Rect getClip()
public abstract Rect getClipGlobal(Rect rect)
rect - the Rect whose values will be set to the clip region
public abstract Rect getClip(Rect rect)
rect - the Rect whose values will be set to the clip region
public abstract void setColorAlpha(int color)
color - A packed RGB integer specifying the color.public void setColor(int color)
public void setColor(int r,
int g,
int b)
public void setColor(int r,
int g,
int b,
int a)
public void setColorAlpha(int color,
int alpha)
public void setColor(Color c)
public abstract int getColor()
public abstract void setTextureColor(int packedColor)
packedColor - RGB packed color. Use setTextureColor(int,int,int)
to set with red, green, blue values.public abstract int getTextureColor()
public void setTextureColor(int r,
int g,
int b)
r - red component of colorg - green component of colorb - blue component of colorpublic abstract void setTextOutlineColor(int color)
public void setTextOutlineColor(int r,
int g,
int b)
public void setTextOutlineColor(Color c)
public abstract int getTextOutlineColor()
public abstract void setTextShadowColor(int packedColor)
packedColor - RGB packed color. Use setTextShadowColor(int,int,int)
to set with red, green, blue values.public abstract int getTextShadowColor()
public void setTextShadowColor(int r,
int g,
int b)
r - red component of colorg - green component of colorb - blue component of colorpublic abstract void setRenderHints(int hints)
hints - bitwise or'd bits, or HINT_DEFAULT for
defaultspublic abstract int getRenderHints()
HINT_DEFAULT for defaultpublic abstract void setFont(Font f)
f - A Font specifying the font to be used.public abstract Font getFont()
public abstract void setSize(int inWidth,
int inHeight)
inWidth - An int specifying the width for the pen.inHeight - An int specifying the height for the pen.
public abstract void setClipGlobal(int l,
int t,
int r,
int b)
public boolean isClipEmpty()
public void setClip(int l,
int t,
int r,
int b)
public abstract int getTop()
public abstract int getLeft()
public abstract Pen clonePen()
public abstract void getVisibleRect(Rect r)
public abstract int getVisibleTop()
public abstract int getVisibleBottom()
public abstract void setDashed(boolean dashed)
public abstract boolean isDashed()
true iff line drawing happens in a "dashed"
styleprotected abstract void copy(Pen from)
public void push()
public void pop()
public int maxStack()
public void popAll()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||