public class SafeTranslatedCanvas extends android.graphics.Canvas implements ISafeCanvas
ISafeCanvas
that wraps a Canvas
and adjusts drawing calls to
the wrapped Canvas so that they are relative to an origin that is always at the center of the
screen.ISafeCanvas
for detailsandroid.graphics.Canvas.EdgeType, android.graphics.Canvas.VertexMode
ISafeCanvas.UnsafeCanvasHandler
Constructor and Description |
---|
SafeTranslatedCanvas() |
SafeTranslatedCanvas(android.graphics.Canvas canvas) |
Modifier and Type | Method and Description |
---|---|
boolean |
clipPath(SafeTranslatedPath path)
Intersect the current clip with the specified path.
|
boolean |
clipPath(SafeTranslatedPath path,
android.graphics.Region.Op op)
Modify the current clip with the specified path.
|
boolean |
clipRect(double left,
double top,
double right,
double bottom)
Intersect the current clip with the specified rectangle, which is expressed in local
coordinates.
|
boolean |
clipRect(double left,
double top,
double right,
double bottom,
android.graphics.Region.Op op)
Modify the current clip with the specified rectangle, which is expressed in local
coordinates.
|
boolean |
clipRect(int left,
int top,
int right,
int bottom)
Intersect the current clip with the specified rectangle, which is expressed in local
coordinates.
|
boolean |
clipRect(android.graphics.Rect rect)
Intersect the current clip with the specified rectangle, which is expressed in local
coordinates.
|
boolean |
clipRect(android.graphics.Rect rect,
android.graphics.Region.Op op)
Modify the current clip with the specified rectangle, which is expressed in local
coordinates.
|
boolean |
clipRegion(android.graphics.Region region)
Intersect the current clip with the specified region.
|
boolean |
clipRegion(android.graphics.Region region,
android.graphics.Region.Op op)
Modify the current clip with the specified region.
|
protected Object |
clone() |
void |
concat(android.graphics.Matrix matrix)
Preconcat the current matrix with the specified matrix.
|
void |
drawArc(android.graphics.Rect oval,
float startAngle,
float sweepAngle,
boolean useCenter,
SafePaint paint)
Draw the specified arc, which will be scaled to fit inside the specified oval.
|
void |
drawARGB(int a,
int r,
int g,
int b)
Fill the entire canvas' bitmap (restricted to the current clip) with the specified ARGB
color, using srcover porterduff mode.
|
void |
drawBitmap(android.graphics.Bitmap bitmap,
double left,
double top,
SafePaint paint)
Draw the specified bitmap, with its top/left corner at (x,y), using the specified paint,
transformed by the current matrix.
|
void |
drawBitmap(android.graphics.Bitmap bitmap,
android.graphics.Matrix matrix,
SafePaint paint)
Draw the bitmap using the specified matrix.
|
void |
drawBitmap(android.graphics.Bitmap bitmap,
android.graphics.Rect src,
android.graphics.Rect dst,
android.graphics.Paint paint) |
void |
drawBitmap(android.graphics.Bitmap bitmap,
android.graphics.Rect src,
android.graphics.Rect dst,
SafePaint paint)
Draw the specified bitmap, scaling/translating automatically to fill the destination
rectangle.
|
void |
drawBitmap(int[] colors,
int offset,
int stride,
double x,
double y,
int width,
int height,
boolean hasAlpha,
SafePaint paint)
Treat the specified array of colors as a bitmap, and draw it.
|
void |
drawBitmap(int[] colors,
int offset,
int stride,
int x,
int y,
int width,
int height,
boolean hasAlpha,
SafePaint paint)
Legacy version of drawBitmap(int[] colors, ...) that took ints for x,y
|
void |
drawBitmapMesh(android.graphics.Bitmap bitmap,
int meshWidth,
int meshHeight,
double[] verts,
int vertOffset,
int[] colors,
int colorOffset,
SafePaint paint)
Draw the bitmap through the mesh, where mesh vertices are evenly distributed across the
bitmap.
|
void |
drawCircle(double cx,
double cy,
float radius,
SafePaint paint)
Draw the specified circle using the specified paint.
|
void |
drawColor(int color)
Fill the entire canvas' bitmap (restricted to the current clip) with the specified color,
using srcover porterduff mode.
|
void |
drawColor(int color,
android.graphics.PorterDuff.Mode mode)
Fill the entire canvas' bitmap (restricted to the current clip) with the specified color and
porter-duff xfermode.
|
void |
drawLine(double startX,
double startY,
double stopX,
double stopY,
SafePaint paint)
Draw a line segment with the specified start and stop x,y coordinates, using the specified
paint.
|
void |
drawLines(double[] pts,
int offset,
int count,
SafePaint paint)
Draw a series of lines.
|
void |
drawLines(double[] pts,
SafePaint paint) |
void |
drawOval(android.graphics.Rect oval,
SafePaint paint)
Draw the specified oval using the specified paint.
|
void |
drawPaint(SafePaint paint)
Fill the entire canvas' bitmap (restricted to the current clip) with the specified paint.
|
void |
drawPath(SafeTranslatedPath path,
SafePaint paint)
Draw the specified path using the specified paint.
|
void |
drawPicture(android.graphics.Picture picture)
Save the canvas state, draw the picture, and restore the canvas state.
|
void |
drawPicture(android.graphics.Picture picture,
android.graphics.Rect dst)
Draw the picture, stretched to fit into the dst rectangle.
|
void |
drawPoint(double x,
double y,
SafePaint paint)
Helper for drawPoints() for drawing a single point.
|
void |
drawPoints(double[] pts,
int offset,
int count,
SafePaint paint)
Draw a series of points.
|
void |
drawPoints(double[] pts,
SafePaint paint)
Helper for drawPoints() that assumes you want to draw the entire array
|
void |
drawPosText(char[] text,
int index,
int count,
double[] pos,
SafePaint paint)
Draw the text in the array, with each character's origin specified by the pos array.
|
void |
drawPosText(String text,
double[] pos,
SafePaint paint)
Draw the text in the array, with each character's origin specified by the pos array.
|
void |
drawRect(double left,
double top,
double right,
double bottom,
SafePaint paint)
Draw the specified Rect using the specified paint.
|
void |
drawRect(android.graphics.Rect r,
SafePaint paint)
Draw the specified Rect using the specified Paint.
|
void |
drawRGB(int r,
int g,
int b)
Fill the entire canvas' bitmap (restricted to the current clip) with the specified RGB color,
using srcover porterduff mode.
|
void |
drawRoundRect(android.graphics.Rect rect,
float rx,
float ry,
SafePaint paint)
Draw the specified round-rect using the specified paint.
|
void |
drawText(char[] text,
int index,
int count,
double x,
double y,
SafePaint paint)
Draw the text, with origin at (x,y), using the specified paint.
|
void |
drawText(CharSequence text,
int start,
int end,
double x,
double y,
SafePaint paint)
Draw the specified range of text, specified by start/end, with its origin at (x,y), in the
specified Paint.
|
void |
drawText(String text,
double x,
double y,
SafePaint paint)
Draw the text, with origin at (x,y), using the specified paint.
|
void |
drawText(String text,
int start,
int end,
double x,
double y,
SafePaint paint)
Draw the text, with origin at (x,y), using the specified paint.
|
void |
drawTextOnPath(char[] text,
int index,
int count,
SafeTranslatedPath path,
float hOffset,
float vOffset,
SafePaint paint)
Draw the text, with origin at (x,y), using the specified paint, along the specified path.
|
void |
drawTextOnPath(String text,
SafeTranslatedPath path,
float hOffset,
float vOffset,
SafePaint paint)
Draw the text, with origin at (x,y), using the specified paint, along the specified path.
|
void |
drawVertices(android.graphics.Canvas.VertexMode mode,
int vertexCount,
double[] verts,
int vertOffset,
float[] texs,
int texOffset,
int[] colors,
int colorOffset,
short[] indices,
int indexOffset,
int indexCount,
SafePaint paint)
Draw the array of vertices, interpreted as triangles (based on mode).
|
boolean |
equals(Object o) |
boolean |
getClipBounds(android.graphics.Rect bounds)
Retrieve the clip bounds, returning true if they are non-empty.
|
int |
getDensity()
Returns the target density of the canvas.
|
android.graphics.DrawFilter |
getDrawFilter() |
int |
getHeight()
Returns the height of the current drawing layer
|
void |
getMatrix(android.graphics.Matrix ctm)
Return, in ctm, the current transformation matrix.
|
android.graphics.Matrix |
getOriginalMatrix() |
android.graphics.Canvas |
getSafeCanvas()
Gets this safe canvas as an Android
Native class. |
int |
getSaveCount()
Returns the number of matrix/clip states on the Canvas' private stack.
|
void |
getUnsafeCanvas(ISafeCanvas.UnsafeCanvasHandler handler)
Allows access to the original unsafe canvas through an
ISafeCanvas.UnsafeCanvasHandler . |
int |
getWidth()
Returns the width of the current drawing layer
|
android.graphics.Canvas |
getWrappedCanvas()
Gets the wrapped canvas.
|
int |
getXOffset()
Gets the x-offset that will be used to adjust all drawing values.
|
int |
getYOffset()
Gets the y-offset that will be used to adjust all drawing values.
|
int |
hashCode() |
boolean |
isOpaque()
Return true if the device that the current layer draws into is opaque (i.e.
|
boolean |
quickReject(double left,
double top,
double right,
double bottom,
android.graphics.Canvas.EdgeType type)
Return true if the specified rectangle, after being transformed by the current matrix, would
lie completely outside of the current clip.
|
boolean |
quickReject(android.graphics.Rect rect,
android.graphics.Canvas.EdgeType type)
Return true if the specified rectangle, after being transformed by the current matrix, would
lie completely outside of the current clip.
|
boolean |
quickReject(SafeTranslatedPath path,
android.graphics.Canvas.EdgeType type)
Return true if the specified path, after being transformed by the current matrix, would lie
completely outside of the current clip.
|
void |
restore()
This call balances a previous call to save(), and is used to remove all modifications to the
matrix/clip state since the last save call.
|
void |
restoreToCount(int saveCount)
Efficient way to pop any calls to save() that happened after the save count reached
saveCount.
|
void |
rotate(float degrees)
Preconcat the current matrix with the specified rotation.
|
void |
rotate(float degrees,
double px,
double py)
Preconcat the current matrix with the specified rotation.
|
int |
save()
Saves the current matrix and clip onto a private stack.
|
int |
save(int saveFlags)
Based on saveFlags, can save the current matrix and clip onto a private stack.
|
int |
saveLayer(double left,
double top,
double right,
double bottom,
SafePaint paint,
int saveFlags)
Helper version of saveLayer() that takes 4 values rather than a RectF.
|
int |
saveLayer(android.graphics.Rect bounds,
SafePaint paint,
int saveFlags)
This behaves the same as save(), but in addition it allocates an offscreen bitmap.
|
int |
saveLayerAlpha(double left,
double top,
double right,
double bottom,
int alpha,
int saveFlags)
Helper for saveLayerAlpha() that takes 4 values instead of a RectF.
|
int |
saveLayerAlpha(android.graphics.Rect bounds,
int alpha,
int saveFlags)
This behaves the same as save(), but in addition it allocates an offscreen bitmap.
|
void |
scale(float sx,
float sy)
Preconcat the current matrix with the specified scale.
|
void |
scale(float sx,
float sy,
double px,
double py)
Preconcat the current matrix with the specified scale.
|
void |
setBitmap(android.graphics.Bitmap bitmap)
Specify a bitmap for the canvas to draw into.
|
void |
setCanvas(android.graphics.Canvas canvas) |
void |
setDensity(int density)
Specifies the density for this Canvas' backing bitmap.
|
void |
setDrawFilter(android.graphics.DrawFilter filter) |
void |
setMatrix(android.graphics.Matrix matrix)
Completely replace the current matrix with the specified matrix.
|
void |
skew(float sx,
float sy)
Preconcat the current matrix with the specified skew.
|
protected float[] |
toOffsetFloatAry(double[] rect,
float[] reuse)
Helper function to convert a Rect to RectF and adjust the values of the Rect by the offsets.
|
protected android.graphics.RectF |
toOffsetRectF(android.graphics.Rect rect,
android.graphics.RectF reuse)
Helper function to convert a Rect to RectF and adjust the values of the Rect by the offsets.
|
String |
toString() |
void |
translate(float dx,
float dy)
Preconcat the current matrix with the specified translation
|
clipPath, clipPath, clipRect, clipRect, clipRect, clipRect, drawArc, drawBitmap, drawBitmap, drawBitmap, drawBitmap, drawBitmap, drawBitmapMesh, drawCircle, drawLine, drawLines, drawLines, drawOval, drawPaint, drawPath, drawPicture, drawPoint, drawPoints, drawPoints, drawPosText, drawPosText, drawRect, drawRect, drawRect, drawRoundRect, drawText, drawText, drawText, drawText, drawTextOnPath, drawTextOnPath, drawVertices, getClipBounds, getMatrix, getMaximumBitmapHeight, getMaximumBitmapWidth, isHardwareAccelerated, quickReject, quickReject, quickReject, rotate, saveLayer, saveLayer, saveLayerAlpha, saveLayerAlpha, scale
finalize, getClass, notify, notifyAll, wait, wait, wait
getClipBounds, getMatrix
public SafeTranslatedCanvas()
public SafeTranslatedCanvas(android.graphics.Canvas canvas)
public android.graphics.Canvas getSafeCanvas()
ISafeCanvas
Native
class. This canvas will have a coordinate
system where the origin is at the center of the screen, and will automatically adjust values
passed to its drawing methods by ISafeCanvas.getXOffset()
and ISafeCanvas.getYOffset()
.getSafeCanvas
in interface ISafeCanvas
public int getXOffset()
ISafeCanvas
getXOffset
in interface ISafeCanvas
public int getYOffset()
ISafeCanvas
getYOffset
in interface ISafeCanvas
public void setCanvas(android.graphics.Canvas canvas)
public void getUnsafeCanvas(ISafeCanvas.UnsafeCanvasHandler handler)
ISafeCanvas
ISafeCanvas.UnsafeCanvasHandler
.getUnsafeCanvas
in interface ISafeCanvas
public android.graphics.Canvas getWrappedCanvas()
ISafeCanvas
getWrappedCanvas
in interface ISafeCanvas
public android.graphics.Matrix getOriginalMatrix()
public boolean clipPath(SafeTranslatedPath path, android.graphics.Region.Op op)
ISafeCanvas
clipPath
in interface ISafeCanvas
path
- The path to operate on the current clipop
- How the clip is modifiedpublic boolean clipPath(SafeTranslatedPath path)
ISafeCanvas
clipPath
in interface ISafeCanvas
path
- The path to intersect with the current clippublic boolean clipRect(double left, double top, double right, double bottom, android.graphics.Region.Op op)
ISafeCanvas
clipRect
in interface ISafeCanvas
left
- The left side of the rectangle to intersect with the current cliptop
- The top of the rectangle to intersect with the current clipright
- The right side of the rectangle to intersect with the current clipbottom
- The bottom of the rectangle to intersect with the current clipop
- How the clip is modifiedpublic boolean clipRect(double left, double top, double right, double bottom)
ISafeCanvas
clipRect
in interface ISafeCanvas
left
- The left side of the rectangle to intersect with the current cliptop
- The top of the rectangle to intersect with the current clipright
- The right side of the rectangle to intersect with the current clipbottom
- The bottom of the rectangle to intersect with the current clippublic boolean clipRect(int left, int top, int right, int bottom)
ISafeCanvas
clipRect
in interface ISafeCanvas
clipRect
in class android.graphics.Canvas
left
- The left side of the rectangle to intersect with the current cliptop
- The top of the rectangle to intersect with the current clipright
- The right side of the rectangle to intersect with the current clipbottom
- The bottom of the rectangle to intersect with the current clippublic boolean clipRect(android.graphics.Rect rect, android.graphics.Region.Op op)
ISafeCanvas
clipRect
in interface ISafeCanvas
clipRect
in class android.graphics.Canvas
rect
- The rectangle to intersect with the current clip.op
- How the clip is modifiedpublic boolean clipRect(android.graphics.Rect rect)
ISafeCanvas
clipRect
in interface ISafeCanvas
clipRect
in class android.graphics.Canvas
rect
- The rectangle to intersect with the current clip.public boolean clipRegion(android.graphics.Region region, android.graphics.Region.Op op)
ISafeCanvas
clipRegion
in interface ISafeCanvas
clipRegion
in class android.graphics.Canvas
region
- The region to operate on the current clip, based on opop
- How the clip is modifiedpublic boolean clipRegion(android.graphics.Region region)
ISafeCanvas
clipRegion
in interface ISafeCanvas
clipRegion
in class android.graphics.Canvas
region
- The region to operate on the current clip, based on oppublic void concat(android.graphics.Matrix matrix)
ISafeCanvas
concat
in interface ISafeCanvas
concat
in class android.graphics.Canvas
matrix
- The matrix to preconcatenate with the current matrixpublic void drawARGB(int a, int r, int g, int b)
ISafeCanvas
drawARGB
in interface ISafeCanvas
drawARGB
in class android.graphics.Canvas
a
- alpha component (0..255) of the color to draw onto the canvasr
- red component (0..255) of the color to draw onto the canvasg
- green component (0..255) of the color to draw onto the canvasb
- blue component (0..255) of the color to draw onto the canvaspublic void drawArc(android.graphics.Rect oval, float startAngle, float sweepAngle, boolean useCenter, SafePaint paint)
ISafeCanvas
Draw the specified arc, which will be scaled to fit inside the specified oval.
If the start angle is negative or >= 360, the start angle is treated as start angle modulo 360.
If the sweep angle is >= 360, then the oval is drawn completely. Note that this differs slightly from SkPath::arcTo, which treats the sweep angle modulo 360. If the sweep angle is negative, the sweep angle is treated as sweep angle modulo 360
The arc is drawn clockwise. An angle of 0 degrees correspond to the geometric angle of 0 degrees (3 o'clock on a watch.)
drawArc
in interface ISafeCanvas
oval
- The bounds of oval used to define the shape and size of the arcstartAngle
- Starting angle (in degrees) where the arc beginssweepAngle
- Sweep angle (in degrees) measured clockwiseuseCenter
- If true, include the center of the oval in the arc, and close it if it is being
stroked. This will draw a wedgepaint
- The paint used to draw the arcpublic void drawBitmap(android.graphics.Bitmap bitmap, double left, double top, SafePaint paint)
ISafeCanvas
Note: if the paint contains a maskfilter that generates a mask which extends beyond the bitmap's original width/height (e.g. BlurMaskFilter), then the bitmap will be drawn as if it were in a Shader with CLAMP mode. Thus the color outside of the original width/height will be the edge color replicated.
If the bitmap and canvas have different densities, this function will take care of automatically scaling the bitmap to draw at the same density as the canvas.
drawBitmap
in interface ISafeCanvas
bitmap
- The bitmap to be drawnleft
- The position of the left side of the bitmap being drawntop
- The position of the top side of the bitmap being drawnpaint
- The paint used to draw the bitmap (may be null)public void drawBitmap(android.graphics.Bitmap bitmap, android.graphics.Matrix matrix, SafePaint paint)
ISafeCanvas
drawBitmap
in interface ISafeCanvas
bitmap
- The bitmap to drawmatrix
- The matrix used to transform the bitmap when it is drawnpaint
- May be null. The paint used to draw the bitmappublic void drawBitmap(android.graphics.Bitmap bitmap, android.graphics.Rect src, android.graphics.Rect dst, SafePaint paint)
ISafeCanvas
Note: if the paint contains a maskfilter that generates a mask which extends beyond the bitmap's original width/height (e.g. BlurMaskFilter), then the bitmap will be drawn as if it were in a Shader with CLAMP mode. Thus the color outside of the original width/height will be the edge color replicated.
This function ignores the density associated with the bitmap. This is because the source and destination rectangle coordinate spaces are in their respective densities, so must already have the appropriate scaling factor applied.
drawBitmap
in interface ISafeCanvas
bitmap
- The bitmap to be drawnsrc
- May be null. The subset of the bitmap to be drawndst
- The rectangle that the bitmap will be scaled/translated to fit intopaint
- May be null. The paint used to draw the bitmappublic void drawBitmap(android.graphics.Bitmap bitmap, android.graphics.Rect src, android.graphics.Rect dst, android.graphics.Paint paint)
drawBitmap
in class android.graphics.Canvas
public void drawBitmap(int[] colors, int offset, int stride, double x, double y, int width, int height, boolean hasAlpha, SafePaint paint)
ISafeCanvas
drawBitmap
in interface ISafeCanvas
colors
- Array of colors representing the pixels of the bitmapoffset
- Offset into the array of colors for the first pixelstride
- The number of colors in the array between rows (must be >= width or <= -width).x
- The X coordinate for where to draw the bitmapy
- The Y coordinate for where to draw the bitmapwidth
- The width of the bitmapheight
- The height of the bitmaphasAlpha
- 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).paint
- May be null. The paint used to draw the bitmappublic void drawBitmap(int[] colors, int offset, int stride, int x, int y, int width, int height, boolean hasAlpha, SafePaint paint)
ISafeCanvas
drawBitmap
in interface ISafeCanvas
public void drawBitmapMesh(android.graphics.Bitmap bitmap, int meshWidth, int meshHeight, double[] verts, int vertOffset, int[] colors, int colorOffset, SafePaint paint)
ISafeCanvas
drawBitmapMesh
in interface ISafeCanvas
bitmap
- The bitmap to draw using the meshmeshWidth
- The number of columns in the mesh. Nothing is drawn if this is 0meshHeight
- The number of rows in the mesh. Nothing is drawn if this is 0verts
- Array of x,y pairs, specifying where the mesh should be drawn. There must be at
least (meshWidth+1) * (meshHeight+1) * 2 + meshOffset values in the arrayvertOffset
- Number of verts elements to skip before drawingcolors
- May be null. Specifies a color at each vertex, which is interpolated across the
cell, and whose values are multiplied by the corresponding bitmap colors. If not
null, there must be at least (meshWidth+1) * (meshHeight+1) + colorOffset values
in the array.colorOffset
- Number of color elements to skip before drawingpaint
- May be null. The paint used to draw the bitmappublic void drawCircle(double cx, double cy, float radius, SafePaint paint)
ISafeCanvas
drawCircle
in interface ISafeCanvas
cx
- The x-coordinate of the center of the cirle to be drawncy
- The y-coordinate of the center of the cirle to be drawnradius
- The radius of the cirle to be drawnpaint
- The paint used to draw the circlepublic void drawColor(int color, android.graphics.PorterDuff.Mode mode)
ISafeCanvas
drawColor
in interface ISafeCanvas
drawColor
in class android.graphics.Canvas
color
- the color to draw withmode
- the porter-duff mode to apply to the colorpublic void drawColor(int color)
ISafeCanvas
drawColor
in interface ISafeCanvas
drawColor
in class android.graphics.Canvas
color
- the color to draw onto the canvaspublic void drawLine(double startX, double startY, double stopX, double stopY, SafePaint paint)
ISafeCanvas
drawLine
in interface ISafeCanvas
startX
- The x-coordinate of the start point of the linestartY
- The y-coordinate of the start point of the linepaint
- The paint used to draw the linepublic void drawLines(double[] pts, int offset, int count, SafePaint paint)
ISafeCanvas
drawLines
in interface ISafeCanvas
pts
- Array of points to draw [x0 y0 x1 y1 x2 y2 ...]offset
- Number of values in the array to skip before drawing.count
- The number of values in the array to process, after skipping "offset" of them.
Since each line uses 4 values, the number of "lines" that are drawn is really
(count >> 2).paint
- The paint used to draw the pointspublic void drawLines(double[] pts, SafePaint paint)
drawLines
in interface ISafeCanvas
public void drawOval(android.graphics.Rect oval, SafePaint paint)
ISafeCanvas
drawOval
in interface ISafeCanvas
oval
- The rectangle bounds of the oval to be drawnpublic void drawPaint(SafePaint paint)
ISafeCanvas
drawPaint
in interface ISafeCanvas
paint
- The paint used to draw onto the canvaspublic void drawPath(SafeTranslatedPath path, SafePaint paint)
ISafeCanvas
drawPath
in interface ISafeCanvas
path
- The path to be drawnpaint
- The paint used to draw the pathpublic void drawPicture(android.graphics.Picture picture, android.graphics.Rect dst)
ISafeCanvas
drawPicture
in interface ISafeCanvas
drawPicture
in class android.graphics.Canvas
public void drawPicture(android.graphics.Picture picture)
ISafeCanvas
drawPicture
in interface ISafeCanvas
drawPicture
in class android.graphics.Canvas
picture
- The picture to be drawnpublic void drawPoint(double x, double y, SafePaint paint)
ISafeCanvas
drawPoint
in interface ISafeCanvas
public void drawPoints(double[] pts, int offset, int count, SafePaint paint)
ISafeCanvas
drawPoints
in interface ISafeCanvas
pts
- Array of points to draw [x0 y0 x1 y1 x2 y2 ...]offset
- Number of values to skip before starting to draw.count
- The number of values to process, after skipping offset of them. Since one point
uses two values, the number of "points" that are drawn is really (count >> 1).paint
- The paint used to draw the pointspublic void drawPoints(double[] pts, SafePaint paint)
ISafeCanvas
drawPoints
in interface ISafeCanvas
public void drawPosText(char[] text, int index, int count, double[] pos, SafePaint paint)
ISafeCanvas
drawPosText
in interface ISafeCanvas
text
- The text to be drawnindex
- The index of the first character to drawcount
- The number of characters to draw, starting from index.pos
- Array of [x,y] positions, used to position each characterpaint
- The paint used for the text (e.g. color, size, style)public void drawPosText(String text, double[] pos, SafePaint paint)
ISafeCanvas
drawPosText
in interface ISafeCanvas
text
- The text to be drawnpos
- Array of [x,y] positions, used to position each characterpaint
- The paint used for the text (e.g. color, size, style)public void drawRGB(int r, int g, int b)
ISafeCanvas
drawRGB
in interface ISafeCanvas
drawRGB
in class android.graphics.Canvas
r
- red component (0..255) of the color to draw onto the canvasg
- green component (0..255) of the color to draw onto the canvasb
- blue component (0..255) of the color to draw onto the canvaspublic void drawRect(double left, double top, double right, double bottom, SafePaint paint)
ISafeCanvas
drawRect
in interface ISafeCanvas
left
- The left side of the rectangle to be drawntop
- The top side of the rectangle to be drawnright
- The right side of the rectangle to be drawnbottom
- The bottom side of the rectangle to be drawnpaint
- The paint used to draw the rectpublic void drawRect(android.graphics.Rect r, SafePaint paint)
ISafeCanvas
drawRect
in interface ISafeCanvas
r
- The rectangle to be drawn.paint
- The paint used to draw the rectanglepublic void drawRoundRect(android.graphics.Rect rect, float rx, float ry, SafePaint paint)
ISafeCanvas
drawRoundRect
in interface ISafeCanvas
rect
- The rectangular bounds of the roundRect to be drawnrx
- The x-radius of the oval used to round the cornersry
- The y-radius of the oval used to round the cornerspaint
- The paint used to draw the roundRectpublic void drawText(String text, double x, double y, SafePaint paint)
ISafeCanvas
drawText
in interface ISafeCanvas
text
- The text to be drawnx
- The x-coordinate of the origin of the text being drawny
- The y-coordinate of the origin of the text being drawnpaint
- The paint used for the text (e.g. color, size, style)public void drawText(char[] text, int index, int count, double x, double y, SafePaint paint)
ISafeCanvas
drawText
in interface ISafeCanvas
text
- The text to be drawnx
- The x-coordinate of the origin of the text being drawnpaint
- The paint used for the text (e.g. color, size, style)public void drawText(CharSequence text, int start, int end, double x, double y, SafePaint paint)
ISafeCanvas
drawText
in interface ISafeCanvas
text
- The text to be drawnstart
- The index of the first character in text to drawend
- (end - 1) is the index of the last character in text to drawx
- The x-coordinate of origin for where to draw the texty
- The y-coordinate of origin for where to draw the textpaint
- The paint used for the text (e.g. color, size, style)public void drawText(String text, int start, int end, double x, double y, SafePaint paint)
ISafeCanvas
drawText
in interface ISafeCanvas
text
- The text to be drawnstart
- The index of the first character in text to drawend
- (end - 1) is the index of the last character in text to drawx
- The x-coordinate of the origin of the text being drawny
- The y-coordinate of the origin of the text being drawnpaint
- The paint used for the text (e.g. color, size, style)public void drawTextOnPath(char[] text, int index, int count, SafeTranslatedPath path, float hOffset, float vOffset, SafePaint paint)
ISafeCanvas
drawTextOnPath
in interface ISafeCanvas
text
- The text to be drawnpath
- The path the text should follow for its baselinehOffset
- The distance along the path to add to the text's starting positionvOffset
- The distance above(-) or below(+) the path to position the textpaint
- The paint used for the text (e.g. color, size, style)public void drawTextOnPath(String text, SafeTranslatedPath path, float hOffset, float vOffset, SafePaint paint)
ISafeCanvas
drawTextOnPath
in interface ISafeCanvas
text
- The text to be drawnpath
- The path the text should follow for its baselinehOffset
- The distance along the path to add to the text's starting positionvOffset
- The distance above(-) or below(+) the path to position the textpaint
- The paint used for the text (e.g. color, size, style)public void drawVertices(android.graphics.Canvas.VertexMode mode, int vertexCount, double[] verts, int vertOffset, float[] texs, int texOffset, int[] colors, int colorOffset, short[] indices, int indexOffset, int indexCount, SafePaint paint)
ISafeCanvas
drawVertices
in interface ISafeCanvas
mode
- How to interpret the array of verticesvertexCount
- The number of values in the vertices array (and corresponding texs and colors
arrays if non-null). Each logical vertex is two values (x, y), vertexCount must be
a multiple of 2.verts
- Array of vertices for the meshvertOffset
- Number of values in the verts to skip before drawing.texs
- May be null. If not null, specifies the coordinates to sample into the current
shader (e.g. bitmap tile or gradient)texOffset
- Number of values in texs to skip before drawing.colors
- May be null. If not null, specifies a color for each vertex, to be interpolated
across the triangle.colorOffset
- Number of values in colors to skip before drawing.indices
- If not null, array of indices to reference into the vertex (texs, colors) array.indexCount
- number of entries in the indices array (if not null).paint
- Specifies the shader to use if the texs array is non-null.public boolean getClipBounds(android.graphics.Rect bounds)
ISafeCanvas
getClipBounds
in interface ISafeCanvas
getClipBounds
in class android.graphics.Canvas
bounds
- Return the clip bounds here. If it is null, ignore it but still return true if the
current clip is non-empty.public int getDensity()
ISafeCanvas
Returns the target density of the canvas. The default density is derived from the density of
its backing bitmap, or Bitmap.DENSITY_NONE
if there is not one.
getDensity
in interface ISafeCanvas
getDensity
in class android.graphics.Canvas
ISafeCanvas.setDensity(int)
,
Bitmap.getDensity()
public android.graphics.DrawFilter getDrawFilter()
getDrawFilter
in interface ISafeCanvas
getDrawFilter
in class android.graphics.Canvas
public int getHeight()
ISafeCanvas
getHeight
in interface ISafeCanvas
getHeight
in class android.graphics.Canvas
public void getMatrix(android.graphics.Matrix ctm)
ISafeCanvas
getMatrix
in interface ISafeCanvas
getMatrix
in class android.graphics.Canvas
public int getSaveCount()
ISafeCanvas
getSaveCount
in interface ISafeCanvas
getSaveCount
in class android.graphics.Canvas
public int getWidth()
ISafeCanvas
getWidth
in interface ISafeCanvas
getWidth
in class android.graphics.Canvas
public boolean isOpaque()
ISafeCanvas
isOpaque
in interface ISafeCanvas
isOpaque
in class android.graphics.Canvas
public boolean quickReject(double left, double top, double right, double bottom, android.graphics.Canvas.EdgeType type)
ISafeCanvas
quickReject
in interface ISafeCanvas
left
- The left side of the rectangle to compare with the current cliptop
- The top of the rectangle to compare with the current clipright
- The right side of the rectangle to compare with the current clipbottom
- The bottom of the rectangle to compare with the current cliptype
- true if the rect should be considered antialiased, since that means it may affect
a larger area (more pixels) than non-antialiased.public boolean quickReject(SafeTranslatedPath path, android.graphics.Canvas.EdgeType type)
ISafeCanvas
quickReject
in interface ISafeCanvas
path
- The path to compare with the current cliptype
- true if the path should be considered antialiased, since that means it may affect
a larger area (more pixels) than non-antialiased.public boolean quickReject(android.graphics.Rect rect, android.graphics.Canvas.EdgeType type)
ISafeCanvas
quickReject
in interface ISafeCanvas
rect
- the rect to compare with the current cliptype
- specifies how to treat the edges (BW or antialiased)public void restore()
ISafeCanvas
restore
in interface ISafeCanvas
restore
in class android.graphics.Canvas
public void restoreToCount(int saveCount)
ISafeCanvas
restoreToCount
in interface ISafeCanvas
restoreToCount
in class android.graphics.Canvas
saveCount
- The save level to restore to.public void rotate(float degrees)
ISafeCanvas
rotate
in interface ISafeCanvas
rotate
in class android.graphics.Canvas
degrees
- The amount to rotate, in degreespublic void rotate(float degrees, double px, double py)
ISafeCanvas
rotate
in interface ISafeCanvas
degrees
- The amount to rotate, in degreespx
- The x-coord for the pivot point (unchanged by the rotation)py
- The y-coord for the pivot point (unchanged by the rotation)public int save()
ISafeCanvas
save
in interface ISafeCanvas
save
in class android.graphics.Canvas
public int save(int saveFlags)
ISafeCanvas
save
in interface ISafeCanvas
save
in class android.graphics.Canvas
saveFlags
- flag bits that specify which parts of the Canvas state to save/restorepublic int saveLayer(double left, double top, double right, double bottom, SafePaint paint, int saveFlags)
ISafeCanvas
saveLayer
in interface ISafeCanvas
public int saveLayer(android.graphics.Rect bounds, SafePaint paint, int saveFlags)
ISafeCanvas
saveLayer
in interface ISafeCanvas
bounds
- May be null. The maximum size the offscreen bitmap needs to be (in local
coordinates)paint
- This is copied, and is applied to the offscreen when restore() is called.saveFlags
- see _SAVE_FLAG constantspublic int saveLayerAlpha(double left, double top, double right, double bottom, int alpha, int saveFlags)
ISafeCanvas
saveLayerAlpha
in interface ISafeCanvas
public int saveLayerAlpha(android.graphics.Rect bounds, int alpha, int saveFlags)
ISafeCanvas
saveLayerAlpha
in interface ISafeCanvas
bounds
- The maximum size the offscreen bitmap needs to be (in local coordinates)alpha
- The alpha to apply to the offscreen when when it is drawn during restore()saveFlags
- see _SAVE_FLAG constantspublic void scale(float sx, float sy)
ISafeCanvas
scale
in interface ISafeCanvas
scale
in class android.graphics.Canvas
sx
- The amount to scale in Xsy
- The amount to scale in Ypublic void scale(float sx, float sy, double px, double py)
ISafeCanvas
scale
in interface ISafeCanvas
sx
- The amount to scale in Xsy
- The amount to scale in Ypx
- The x-coord for the pivot point (unchanged by the scale)py
- The y-coord for the pivot point (unchanged by the scale)public void setBitmap(android.graphics.Bitmap bitmap)
ISafeCanvas
setBitmap
in interface ISafeCanvas
setBitmap
in class android.graphics.Canvas
bitmap
- Specifies a mutable bitmap for the canvas to draw into.ISafeCanvas.setDensity(int)
,
ISafeCanvas.getDensity()
public void setDensity(int density)
ISafeCanvas
Specifies the density for this Canvas' backing bitmap. This modifies the target density of
the canvas itself, as well as the density of its backing bitmap via
Bitmap.setDensity(int)
.
setDensity
in interface ISafeCanvas
setDensity
in class android.graphics.Canvas
density
- The new target density of the canvas, which is used to determine the scaling
factor when drawing a bitmap into it. Use Bitmap.DENSITY_NONE
to disable
bitmap scaling.ISafeCanvas.getDensity()
,
Bitmap.setDensity(int)
public void setDrawFilter(android.graphics.DrawFilter filter)
setDrawFilter
in interface ISafeCanvas
setDrawFilter
in class android.graphics.Canvas
public void setMatrix(android.graphics.Matrix matrix)
ISafeCanvas
setMatrix
in interface ISafeCanvas
setMatrix
in class android.graphics.Canvas
matrix
- The matrix to replace the current matrix with. If it is null, set the current
matrix to identity.public void skew(float sx, float sy)
ISafeCanvas
skew
in interface ISafeCanvas
skew
in class android.graphics.Canvas
sx
- The amount to skew in Xsy
- The amount to skew in Ypublic void translate(float dx, float dy)
ISafeCanvas
translate
in interface ISafeCanvas
translate
in class android.graphics.Canvas
dx
- The distance to translate in Xdy
- The distance to translate in Yprotected Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
protected final android.graphics.RectF toOffsetRectF(android.graphics.Rect rect, android.graphics.RectF reuse)
protected final float[] toOffsetFloatAry(double[] rect, float[] reuse)
Copyright © 2014. All Rights Reserved.