|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectView
com.WorldLibAndroid.CanvasPanel
public class CanvasPanel
A panel to hold the drawings.
Constructor Summary | |
---|---|
CanvasPanel(Context context,
int width,
int height)
The constructor to create an object with a specific width and height. |
Method Summary | |
---|---|
void |
cleanCanvas()
Clears the canvas. |
void |
drawBitmap(int[] colors,
int offset,
int stride,
float x,
float y,
int width,
int height,
boolean hasAlpha)
Treat the specified array of colors as a bitmap, and draw it. |
void |
drawCircle(float x,
float y,
float radius,
IColor p)
Draws a filled circle. |
void |
drawDrawable(Drawable image)
Draws the specified drawable image. |
void |
drawLine(float x1,
float y1,
float x2,
float y2,
IColor p)
Draws a line. |
void |
drawRect(float x1,
float y1,
float x2,
float y2,
IColor p)
Draws a filled rectangle. |
void |
drawText(java.lang.String m,
float x,
float y,
IColor p)
Draws a text. |
Canvas |
getAndroidCanvas()
Get the canvas. |
void |
onDraw(Canvas canvas)
Method to draw the figures on the canvas panel. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CanvasPanel(Context context, int width, int height)
context
- allows access to application-specific resources and classes,
as well as up-calls for application-level operations such as
launching activities, broadcasting and receiving intents, etc.width
- of the canvas.height
- of the canvas.Method Detail |
---|
public void onDraw(Canvas canvas)
canvas
- host the draw calls (writing into the bitmap).public void drawCircle(float x, float y, float radius, IColor p)
drawCircle
in interface ICanvas
x
- coordinate of the canvas panel.y
- coordinate of the canvas panel.radius
- of the circle.p
- object that holds the color of the circle.public void drawLine(float x1, float y1, float x2, float y2, IColor p)
drawLine
in interface ICanvas
x1
- coordinate of the beginning of the line.y1
- coordinate of the beginning of the line.x2
- coordinate of the end of the line.y2
- coordinate of the end of the line.p
- object that holds the color of the line.public void drawRect(float x1, float y1, float x2, float y2, IColor p)
drawRect
in interface ICanvas
x1
- The left side of the rectangle to be drawn.y1
- The top side of the rectangle to be drawn.x2
- The right side of the rectangle to be drawn.y2
- The bottom side of the rectangle to be drawn.p
- object that holds the color of the rectangle.public void drawText(java.lang.String m, float x, float y, IColor p)
drawText
in interface ICanvas
m
- The text to be drawn.x
- The x-coordinate of the origin of the text being drawn.y
- The y-coordinate of the origin of the text being drawn.p
- object that holds the color of the text.public void cleanCanvas()
cleanCanvas
in interface ICanvas
public void drawBitmap(int[] colors, int offset, int stride, float x, float y, int width, int height, boolean hasAlpha)
drawBitmap
in interface ICanvas
colors
- Array of colors representing the pixels of the bitmap.offset
- into the array of colors for the first pixel.stride
- The number of colors in the array between rows (must be >=
width or <= -width).x
- The X coordinate for where to draw the bitmap.y
- The Y coordinate for where to draw the bitmap.width
- The width of the bitmap.height
- The height of the bitmap.hasAlpha
- True if the alpha channel of the colors contains valid values.
If false, the alpha byte is ignored (assumed to be 0xFF for
every pixel).public void drawDrawable(Drawable image)
ICanvas
drawDrawable
in interface ICanvas
image
- the Drawable
to be drawnpublic Canvas getAndroidCanvas()
getAndroidCanvas
in interface ICanvas
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |