public class GGBackground
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
android.graphics.Point |
_drawRectangle(int x1,
int y1,
int x,
int y,
double r,
boolean isHorz) |
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 (without bounding lines to center) 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 bm,
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(int x1,
int y1,
int x2,
int y2)
Draws a rectangle with given opposite corners.
|
void |
drawRectangle(android.graphics.Point pt1,
android.graphics.Point pt2)
Draws a rectangle with given opposite vertexes.
|
android.graphics.Point |
drawRectangle(android.graphics.Point pt1,
android.graphics.Point pt,
double ratio,
boolean isHorz)
Draws a rectangle with one vertex, a point on the line through
the opposite horizotal side and the given side ratio.
|
void |
drawSector(android.graphics.Point pt,
int radius,
double startAngle,
double extentAngle)
Draws a sector (arc with bounding lines to center, pie) with given center, radius, start angle and angle extent.
|
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 (without bounding lines to center) 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(int x1,
int y1,
int x2,
int y2)
Draws a filled rectangle with given opposite vertexes.
|
void |
fillRectangle(android.graphics.Point pt1,
android.graphics.Point pt2)
Draws a filled rectangle with given opposite vertexes.
|
void |
fillSector(android.graphics.Point pt,
int radius,
double startAngle,
double extentAngle)
Fills a sector (arc with bounding lines to center, pie) with given center, radius, start angle and angle extent.
|
void |
floodFill(android.graphics.Point pt,
int oldColor,
int newColor)
Fills a bounded single-colored region with
the given color.
|
int[] |
getBgAry() |
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 myPaint color.
|
android.graphics.Shader |
getShader()
Returns the current shader.
|
void |
restore()
Restores a previously saved background.
|
void |
save()
Saves the current background to an extra buffer.
|
int |
setLineWidth(int width)
Sets the current line width for all future painting.
|
int |
setPaintColor(int color)
Sets the current color for all future painting.
|
void |
setPaintMode()
Removes the XOR paint mode and selects the normal overwrite mode.
|
android.graphics.Shader |
setShader(android.graphics.Shader shader)
Sets the shader for all future painting.
|
void |
setXORMode()
Selects the XOR paint mode.
|
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 int[] getBgAry()
public void drawFrame(int color)
color
- the color of the linespublic android.graphics.Bitmap getBgBitmap()
public int getPaintColor()
public int setPaintColor(int color)
color
- the new color for paintingpublic int getLineWidth()
public int setLineWidth(int width)
width
- the new line width (in pixels) for paintingpublic android.graphics.Shader getShader()
public android.graphics.Shader setShader(android.graphics.Shader shader)
shader
- the new shader 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 vertexy
- the y-coordinate of the upper left vertexpublic 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(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
- one of the rectangle vertexespt2
- the opposite rectangle vertexpublic void drawRectangle(int x1, int y1, int x2, int y2)
x1
- x coordinate of one of the vertexesy1
- y coordinate of this vertexx2
- x coordinate the opposite vertexy2
- y coordinate of this vertexpublic void fillRectangle(android.graphics.Point pt1, android.graphics.Point pt2)
pt1
- one of the rectangle vertexespt2
- the opposite rectangle vertexpublic void fillRectangle(int x1, int y1, int x2, int y2)
x1
- the x-coordinate of one of the rectangle vertexesy1
- the y-coordinate of this vertexx2
- the x-coordinate of the opposite vertexy2
- the y-coordinate of this vertexpublic void drawSector(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 counter-clockwise)extentAngle
- the angle extent in degrees (zero to east, positive counter-clockwise)public void fillSector(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 counter-clockwise)extentAngle
- the angle extent in degrees (zero to east, positive counter-clockwise)public 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 counter-clockwise)extentAngle
- the angle extent in degrees (zero to east, positive counter-clockwise)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 clockwise)extentAngle
- the angle extent in degrees (zero to east, positive clockwise)public 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 baselinepublic void setXORMode()
public void setPaintMode()
public void drawImage(android.graphics.Bitmap bm, int x, int y)
bm
- the bitmap of the imagex
- the x-coordinate of the upper left vertexy
- the y-coordinate of the upper left vertexpublic 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 android.graphics.Point drawRectangle(android.graphics.Point pt1, android.graphics.Point pt, double ratio, boolean isHorz)
pt1
- one of the vertexespt
- a point on a opposite horizontal or vertical lineratio
- the side ratio r = horizontal_side_length / vertical_side_lengthisHorz
- if true, pt is on the opposite horizontal line; otherwise it
is on the opposite vertical linepublic android.graphics.Point _drawRectangle(int x1, int y1, int x, int y, double r, boolean isHorz)