Package org.robolectric.shadows
Class ShadowCanvas
- java.lang.Object
-
- org.robolectric.shadows.ShadowCanvas
-
- Direct Known Subclasses:
ShadowDisplayListCanvas
,ShadowRecordingCanvas
@Implements(android.graphics.Canvas.class) public class ShadowCanvas extends Object
Broken. This implementation is very specific to the application for which it was developed. Todo: Reimplement. Consider using the same strategy of collecting a history of draw events and providing methods for writing queries based on type, number, and order of events.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ShadowCanvas.ArcPaintHistoryEvent
static class
ShadowCanvas.CirclePaintHistoryEvent
static class
ShadowCanvas.LinePaintHistoryEvent
static class
ShadowCanvas.OvalPaintHistoryEvent
static class
ShadowCanvas.RectPaintHistoryEvent
static class
ShadowCanvas.RoundRectPaintHistoryEvent
Captures round rectangle drawing eventsstatic class
ShadowCanvas.TextHistoryEvent
-
Field Summary
Fields Modifier and Type Field Description protected org.robolectric.shadows.ShadowCanvas.CanvasReflector
canvasReflector
protected Canvas
realCanvas
-
Constructor Summary
Constructors Constructor Description ShadowCanvas()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
__constructor__(Bitmap bitmap)
void
appendDescription(String s)
protected void
drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter, Paint paint)
protected void
drawBitmap(Bitmap bitmap, float left, float top, Paint paint)
protected void
drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint)
protected void
drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint)
protected void
drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint)
protected void
drawCircle(float cx, float cy, float radius, Paint paint)
protected void
drawColor(int color)
protected void
drawLine(float startX, float startY, float stopX, float stopY, Paint paint)
protected void
drawOval(RectF oval, Paint paint)
protected void
drawPaint(Paint paint)
protected void
drawPath(Path path, Paint paint)
protected void
drawRect(float left, float top, float right, float bottom, Paint paint)
protected void
drawRect(Rect r, Paint paint)
protected void
drawRoundRect(RectF rect, float rx, float ry, Paint paint)
protected void
drawText(char[] text, int index, int count, float x, float y, Paint paint)
protected void
drawText(CharSequence text, int start, int end, float x, float y, Paint paint)
protected void
drawText(String text, float x, float y, Paint paint)
protected void
drawText(String text, int start, int end, float x, float y, Paint paint)
int
getArcPaintHistoryCount()
int
getCirclePaintHistoryCount()
String
getDescription()
ShadowCanvas.ArcPaintHistoryEvent
getDrawnArc(int i)
ShadowCanvas.CirclePaintHistoryEvent
getDrawnCircle(int i)
ShadowCanvas.LinePaintHistoryEvent
getDrawnLine(int i)
ShadowCanvas.OvalPaintHistoryEvent
getDrawnOval(int i)
Paint
getDrawnPaint()
Path
getDrawnPath(int i)
Paint
getDrawnPathPaint(int i)
ShadowCanvas.RectPaintHistoryEvent
getDrawnRect(int i)
ShadowCanvas.RoundRectPaintHistoryEvent
getDrawnRoundRect(int i)
ShadowCanvas.TextHistoryEvent
getDrawnTextEvent(int i)
protected int
getHeight()
ShadowCanvas.RectPaintHistoryEvent
getLastDrawnRect()
ShadowCanvas.RoundRectPaintHistoryEvent
getLastDrawnRoundRect()
int
getLinePaintHistoryCount()
int
getOvalPaintHistoryCount()
int
getPathPaintHistoryCount()
int
getRectPaintHistoryCount()
int
getRoundRectPaintHistoryCount()
protected int
getSaveCount()
int
getTextHistoryCount()
protected int
getWidth()
boolean
hasDrawnCircle()
boolean
hasDrawnPath()
protected static int
initRaster(int bitmapHandle)
protected static long
initRaster(long bitmapHandle)
protected static long
initRaster(Bitmap bitmap)
protected static int
native_saveLayer(int nativeCanvas, float l, float t, float r, float b, int paint, int layerFlags)
protected static int
native_saveLayer(int nativeCanvas, RectF bounds, int paint, int layerFlags)
protected static int
native_saveLayer(long nativeCanvas, float l, float t, float r, float b, long nativePaint, int layerFlags)
protected static int
native_saveLayerAlpha(int nativeCanvas, float l, float t, float r, float b, int alpha, int layerFlags)
protected static int
native_saveLayerAlpha(int nativeCanvas, RectF bounds, int alpha, int layerFlags)
protected static int
native_saveLayerAlpha(long nativeCanvas, float l, float t, float r, float b, int alpha, int layerFlags)
protected static int
nGetSaveCount(long canvasHandle)
protected static long
nInitRaster(long bitmapHandle)
protected static long
nInitRaster(Bitmap bitmap)
protected static boolean
nRestore(long canvasHandle)
protected static void
nRestoreToCount(long canvasHandle, int saveCount)
protected static int
nSave(long canvasHandle, int saveFlags)
protected static int
nSaveLayer(long nativeCanvas, float l, float t, float r, float b, long nativePaint)
protected static int
nSaveLayer(long nativeCanvas, float l, float t, float r, float b, long nativePaint, int layerFlags)
protected static int
nSaveLayerAlpha(long nativeCanvas, float l, float t, float r, float b, int alpha)
protected static int
nSaveLayerAlpha(long nativeCanvas, float l, float t, float r, float b, int alpha, int layerFlags)
protected void
release()
static void
reset()
void
resetCanvasHistory()
protected void
restore()
protected void
restoreToCount(int saveCount)
protected int
save()
protected void
scale(float sx, float sy)
protected void
scale(float sx, float sy, float px, float py)
protected void
setBitmap(Bitmap bitmap)
void
setHeight(int height)
void
setWidth(int width)
protected void
translate(float x, float y)
static String
visualize(Canvas canvas)
Returns a textual representation of the appearance of the object.
-
-
-
Field Detail
-
realCanvas
@RealObject protected Canvas realCanvas
-
canvasReflector
@ReflectorObject protected org.robolectric.shadows.ShadowCanvas.CanvasReflector canvasReflector
-
-
Method Detail
-
visualize
public static String visualize(Canvas canvas)
Returns a textual representation of the appearance of the object.- Parameters:
canvas
- the canvas to visualize- Returns:
- The textual representation of the appearance of the object.
-
__constructor__
@Implementation protected void __constructor__(Bitmap bitmap)
-
appendDescription
public void appendDescription(String s)
-
getDescription
public String getDescription()
-
setBitmap
@Implementation protected void setBitmap(Bitmap bitmap)
-
drawText
@Implementation protected void drawText(String text, float x, float y, Paint paint)
-
drawText
@Implementation protected void drawText(CharSequence text, int start, int end, float x, float y, Paint paint)
-
drawText
@Implementation protected void drawText(char[] text, int index, int count, float x, float y, Paint paint)
-
drawText
@Implementation protected void drawText(String text, int start, int end, float x, float y, Paint paint)
-
translate
@Implementation protected void translate(float x, float y)
-
scale
@Implementation protected void scale(float sx, float sy)
-
scale
@Implementation protected void scale(float sx, float sy, float px, float py)
-
drawPaint
@Implementation protected void drawPaint(Paint paint)
-
drawColor
@Implementation protected void drawColor(int color)
-
drawBitmap
@Implementation protected void drawBitmap(Bitmap bitmap, float left, float top, Paint paint)
-
drawBitmap
@Implementation protected void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint)
-
drawBitmap
@Implementation protected void drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint)
-
drawBitmap
@Implementation protected void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint)
-
drawPath
@Implementation protected void drawPath(Path path, Paint paint)
-
drawCircle
@Implementation protected void drawCircle(float cx, float cy, float radius, Paint paint)
-
drawArc
@Implementation protected void drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter, Paint paint)
-
drawRect
@Implementation protected void drawRect(float left, float top, float right, float bottom, Paint paint)
-
drawRect
@Implementation protected void drawRect(Rect r, Paint paint)
-
drawRoundRect
@Implementation protected void drawRoundRect(RectF rect, float rx, float ry, Paint paint)
-
drawLine
@Implementation protected void drawLine(float startX, float startY, float stopX, float stopY, Paint paint)
-
drawOval
@Implementation protected void drawOval(RectF oval, Paint paint)
-
getPathPaintHistoryCount
public int getPathPaintHistoryCount()
-
getCirclePaintHistoryCount
public int getCirclePaintHistoryCount()
-
getArcPaintHistoryCount
public int getArcPaintHistoryCount()
-
hasDrawnPath
public boolean hasDrawnPath()
-
hasDrawnCircle
public boolean hasDrawnCircle()
-
getDrawnPathPaint
public Paint getDrawnPathPaint(int i)
-
getDrawnPath
public Path getDrawnPath(int i)
-
getDrawnCircle
public ShadowCanvas.CirclePaintHistoryEvent getDrawnCircle(int i)
-
getDrawnArc
public ShadowCanvas.ArcPaintHistoryEvent getDrawnArc(int i)
-
resetCanvasHistory
public void resetCanvasHistory()
-
getDrawnPaint
public Paint getDrawnPaint()
-
setHeight
public void setHeight(int height)
-
setWidth
public void setWidth(int width)
-
getWidth
@Implementation protected int getWidth()
-
getHeight
@Implementation protected int getHeight()
-
getDrawnTextEvent
public ShadowCanvas.TextHistoryEvent getDrawnTextEvent(int i)
-
getTextHistoryCount
public int getTextHistoryCount()
-
getDrawnRect
public ShadowCanvas.RectPaintHistoryEvent getDrawnRect(int i)
-
getLastDrawnRect
public ShadowCanvas.RectPaintHistoryEvent getLastDrawnRect()
-
getRectPaintHistoryCount
public int getRectPaintHistoryCount()
-
getDrawnRoundRect
public ShadowCanvas.RoundRectPaintHistoryEvent getDrawnRoundRect(int i)
-
getLastDrawnRoundRect
public ShadowCanvas.RoundRectPaintHistoryEvent getLastDrawnRoundRect()
-
getRoundRectPaintHistoryCount
public int getRoundRectPaintHistoryCount()
-
getDrawnLine
public ShadowCanvas.LinePaintHistoryEvent getDrawnLine(int i)
-
getLinePaintHistoryCount
public int getLinePaintHistoryCount()
-
getOvalPaintHistoryCount
public int getOvalPaintHistoryCount()
-
getDrawnOval
public ShadowCanvas.OvalPaintHistoryEvent getDrawnOval(int i)
-
save
@Implementation(maxSdk=25) protected int save()
-
restore
@Implementation(maxSdk=25) protected void restore()
-
getSaveCount
@Implementation(maxSdk=25) protected int getSaveCount()
-
restoreToCount
@Implementation(maxSdk=25) protected void restoreToCount(int saveCount)
-
release
@Implementation(minSdk=19) protected void release()
-
initRaster
@Implementation(maxSdk=20) protected static int initRaster(int bitmapHandle)
-
initRaster
@Implementation(minSdk=21, maxSdk=22) protected static long initRaster(long bitmapHandle)
-
initRaster
@Implementation(minSdk=23, maxSdk=25) protected static long initRaster(Bitmap bitmap)
-
nInitRaster
@Implementation(minSdk=26, maxSdk=28) protected static long nInitRaster(Bitmap bitmap)
-
nInitRaster
@Implementation(minSdk=29) protected static long nInitRaster(long bitmapHandle)
-
nGetSaveCount
@Implementation(minSdk=26) protected static int nGetSaveCount(long canvasHandle)
-
nSave
@Implementation(minSdk=26) protected static int nSave(long canvasHandle, int saveFlags)
-
native_saveLayer
@Implementation(maxSdk=20) protected static int native_saveLayer(int nativeCanvas, RectF bounds, int paint, int layerFlags)
-
native_saveLayer
@Implementation(maxSdk=20) protected static int native_saveLayer(int nativeCanvas, float l, float t, float r, float b, int paint, int layerFlags)
-
native_saveLayer
@Implementation(minSdk=21, maxSdk=25) protected static int native_saveLayer(long nativeCanvas, float l, float t, float r, float b, long nativePaint, int layerFlags)
-
nSaveLayer
@Implementation(minSdk=26, maxSdk=30) protected static int nSaveLayer(long nativeCanvas, float l, float t, float r, float b, long nativePaint, int layerFlags)
-
nSaveLayer
@Implementation(minSdk=31) protected static int nSaveLayer(long nativeCanvas, float l, float t, float r, float b, long nativePaint)
-
native_saveLayerAlpha
@Implementation(maxSdk=20) protected static int native_saveLayerAlpha(int nativeCanvas, RectF bounds, int alpha, int layerFlags)
-
native_saveLayerAlpha
@Implementation(maxSdk=20) protected static int native_saveLayerAlpha(int nativeCanvas, float l, float t, float r, float b, int alpha, int layerFlags)
-
native_saveLayerAlpha
@Implementation(minSdk=21, maxSdk=25) protected static int native_saveLayerAlpha(long nativeCanvas, float l, float t, float r, float b, int alpha, int layerFlags)
-
nSaveLayerAlpha
@Implementation(minSdk=26, maxSdk=30) protected static int nSaveLayerAlpha(long nativeCanvas, float l, float t, float r, float b, int alpha, int layerFlags)
-
nSaveLayerAlpha
@Implementation(minSdk=31) protected static int nSaveLayerAlpha(long nativeCanvas, float l, float t, float r, float b, int alpha)
-
nRestore
@Implementation(minSdk=26) protected static boolean nRestore(long canvasHandle)
-
nRestoreToCount
@Implementation(minSdk=26) protected static void nRestoreToCount(long canvasHandle, int saveCount)
-
reset
@Resetter public static void reset()
-
-