@Override
public void draw(Canvas canvas) {
if (!isInitialized) {
calculateRegions();
connected = getResources().getDrawable(A.drawable.remote_control_connected);
disconnected = getResources().getDrawable(A.drawable.remote_control_disconnected);
isInitialized = true;
}
int width = this.getWidth();
int height = this.getHeight();
Paint paint = new Paint();
paint.setColor(Color.LTGRAY);
paint.setStyle(Style.STROKE);
if (isScrollPadActive()) {
int sbLeft = width - (xScrollBar * 2 / 3);
int sbRight = width - (xScrollBar / 3);
Path path = new Path();
path.setFillType(FillType.EVEN_ODD);
path.moveTo((sbLeft + sbRight) / 2, scrollPad.top);
path.lineTo(sbLeft, scrollPad.top + yBorder / 2);
path.lineTo(sbRight, scrollPad.top + yBorder / 2);
path.lineTo((sbLeft + sbRight) / 2, scrollPad.top);
path.close();
canvas.drawPath(path, paint);
path = new Path();
path.setFillType(FillType.EVEN_ODD);
path.moveTo((sbLeft + sbRight) / 2, scrollPad.bottom);
path.lineTo(sbLeft, scrollPad.bottom - yBorder / 2);
path.lineTo(sbRight, scrollPad.bottom - yBorder / 2);
path.lineTo((sbLeft + sbRight) / 2, scrollPad.bottom);
path.close();
canvas.drawPath(path, paint);
for (int i = (2 * yBorder); i < height - (2 * yBorder); i += yScrollBarItem) {
canvas.drawRect(
new Rect(sbLeft, i, sbRight, Math.min((i + (yScrollBarItem / 2)), (height - (2 * yScrollBarItem)))), paint);
}
}
if (isButtonsActive()) {
canvas.drawRoundRect(leftButton, 5, 5, paint);
canvas.drawRoundRect(rightButton, 5, 5, paint);
}
if (isTouchPadActive()) {
canvas.drawLines(new float[] { touchPad.left, touchPad.top + yBorder, touchPad.left, touchPad.bottom - yBorder,
touchPad.right, touchPad.top + yBorder, touchPad.right, touchPad.bottom - yBorder, touchPad.left + xBorder,
touchPad.top, touchPad.right - xBorder, touchPad.top, touchPad.left + xBorder, touchPad.bottom,
touchPad.right - xBorder, touchPad.bottom }, paint);
}
if (isPointerStickActive()) {
canvas.drawOval(pointerStick, paint);
canvas.drawOval(pointerStickCenter, paint);
}
Drawable image = ((client != null) && client.isConnected()) ? connected : disconnected;
if (image instanceof BitmapDrawable) {
Bitmap bitmap = ((BitmapDrawable) image).getBitmap();
Matrix matrix = new Matrix();
matrix.setScale(0.5F, 0.5F);
canvas.drawBitmap(bitmap, matrix, new Paint());
}
invalidate();
}
TouchSink.java 文件源码
java
阅读 25
收藏 0
点赞 0
评论 0
项目:dev
作者:
评论列表
文章目录