public class GGBackground
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the frame buffer by painting it with the current background color.
|
void |
clear(int color)
Sets the background color to the given color and clears the frame buffer
by painting it with the given color.
|
void |
drawArc(android.graphics.Point pt,
int radius,
double startAngle,
double extentAngle)
Draws an arc with given center, radius, start angle and angle extent.
|
void |
drawCircle(android.graphics.Point center,
int radius)
Draws a circle with given center and given radius.
|
void |
drawFrame(int color)
Draws a rectangular frame around the playground.
|
void |
drawGridLines(int color)
Draws the grid lines using the given color.
|
void |
drawImage(android.graphics.Bitmap image,
int x,
int y)
Draws a given bitmap image into the background at the given position.
|
void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draws a line from one coordinate pair to another coordinate pair.
|
void |
drawLine(android.graphics.Point pt1,
android.graphics.Point pt2)
Draws a line from one coordinate pair to another coordinate pair.
|
void |
drawPoint(int x,
int y)
Draws a single point into the background.
|
void |
drawPolygon(android.graphics.Point[] vertexes)
Draws a polygon with given vertexes.
|
void |
drawRectangle(android.graphics.Point pt1,
android.graphics.Point pt2)
Draws a rectangle with given opposite corners.
|
void |
drawSprite(android.graphics.Bitmap sprite,
int x,
int y)
Deprecated.
Use GGBackground.drawImage instead.
|
void |
drawText(java.lang.String text,
android.graphics.Point pt)
Displays the given text at the given position using the current font.
|
void |
fillArc(android.graphics.Point pt,
int radius,
double startAngle,
double extentAngle)
Fills an arc with given center, radius, start angle and angle extent.
|
void |
fillCell(Location location,
int fillColor)
Fills a cell with given color.
|
void |
fillCell(Location location,
int fillColor,
boolean boundary)
Fills a cell with given color.
|
void |
fillCircle(android.graphics.Point center,
int radius)
Draws a filled circle with given center and given radius.
|
void |
fillPolygon(android.graphics.Point[] vertexes)
Draws a filled polygon with given vertexes.
|
void |
fillRectangle(android.graphics.Point pt1,
android.graphics.Point pt2)
Draws a filled rectangle with given opposite corners.
|
void |
floodFill(android.graphics.Point pt,
int oldColor,
int newColor)
Fills a bounded single-colored region with
the given color.
|
android.graphics.Bitmap |
getBgBitmap()
Returns the Bitmap reference of the current background buffer.
|
android.graphics.Bitmap |
getBgBuffer()
Returns the Bitmap reference of the current background (offscreen buffer).
|
int |
getBgColor()
Returns the current background color.
|
android.graphics.Bitmap |
getBgImage()
Returns the Bitmap reference of the current background image.
|
android.graphics.Canvas |
getCanvas()
Returns a Canvas reference of the current background pffscreen buffer.
|
int |
getColor(Location location)
Returns the color of the pixel of the background at given cell's center.
|
int |
getColor(android.graphics.Point pt)
Returns the color of the pixel of the background at given point.
|
int |
getLineWidth()
Returns the current line width in pixels.
|
int |
getPaintColor()
Returns the current paint color.
|
void |
restore()
Restores a previously saved background.
|
void |
save()
Saves the current background to an extra buffer.
|
void |
setLineWidth(int width)
Sets the current line width for all future painting.
|
void |
setPaintColor(int color)
Sets the current color for all future painting.
|
public android.graphics.Bitmap getBgBuffer()
public android.graphics.Canvas getCanvas()
public android.graphics.Bitmap getBgImage()
public void floodFill(android.graphics.Point pt, int oldColor, int newColor)
pt
- a point inside the regionoldColor
- the old color of the regionnewColor
- the new color of the regionpublic void drawFrame(int color)
color
- the color of the linespublic android.graphics.Bitmap getBgBitmap()
public int getPaintColor()
public void setPaintColor(int color)
color
- the new color for paintingpublic int getLineWidth()
public void setLineWidth(int width)
width
- the new line width (in pixels) for painting@Deprecated public void drawSprite(android.graphics.Bitmap sprite, int x, int y)
sprite
- the bitmap of the imagex
- the x-coordinate of the upper left cornery
- the y-coordinate of the upper left cornerpublic void drawImage(android.graphics.Bitmap image, int x, int y)
image
- the bitmap of the imagex
- the x-coordinate of the upper left cornery
- the y-coordinate of the upper left cornerpublic void drawPoint(int x, int y)
x
- the x-coordinate of the pointy
- the y-coordinate of the pointpublic void clear(int color)
public void clear()
public int getBgColor()
public void save()
public void restore()
public void drawLine(int x1, int y1, int x2, int y2)
x1
- the x-coordinate of the start pointy1
- the y-coordinate of the start pointx2
- the x-coordinate of the endpointy2
- the y-coordinate of the endpointpublic void drawLine(android.graphics.Point pt1, android.graphics.Point pt2)
pt1
- the start pointpt2
- the endpointpublic void drawCircle(android.graphics.Point center, int radius)
radius
- the radius of the circlepublic void fillCircle(android.graphics.Point center, int radius)
center
- the center of the circleradius
- the radius of the circlepublic void drawRectangle(android.graphics.Point pt1, android.graphics.Point pt2)
pt1
- upper left vertex of the rectanglept2
- lower right vertex of the rectanglepublic void fillRectangle(android.graphics.Point pt1, android.graphics.Point pt2)
pt1
- upper left vertex of the rectanglept2
- lower right vertex of the rectanglepublic void drawArc(android.graphics.Point pt, int radius, double startAngle, double extentAngle)
pt
- the center of the arcradius
- the radius of the arcstartAngle
- the start angle in degrees (zero to east, positive counterclockwise)extentAngle
- the angle extent in degrees (zero to east, positive counterclockwise)public void fillArc(android.graphics.Point pt, int radius, double startAngle, double extentAngle)
pt
- the center of the arcradius
- the radius of the arcstartAngle
- the start angle in degrees (zero to east, positive counterclockwise)extentAngle
- the angle extentpublic void drawPolygon(android.graphics.Point[] vertexes)
vertexes
- the vertexes of the polygonpublic void fillPolygon(android.graphics.Point[] vertexes)
vertexes
- the vertexes of the polygonpublic void fillCell(Location location, int fillColor)
location
- the cell's location (cell indices).fillColor
- the filling color of the cellpublic void fillCell(Location location, int fillColor, boolean boundary)
location
- the cell's location (cell indices).fillColor
- the filling color of the cellboundary
- if true the boundary lines are considered to be part of the cell;
otherwise the boundary lines are left intactpublic int getColor(android.graphics.Point pt)
pt
- point, where to pick the color; if pt is outside
the grid, returns Color.black.public int getColor(Location location)
location
- cell's location where to pick the color; if location is outside
the grid, returns Color.black.public void drawGridLines(int color)
color
- the color of the grid linespublic void drawText(java.lang.String text, android.graphics.Point pt)
text
- the text to displaypt
- the start point of the text baseline