public void onSensorChanged(String sensorStr) { Log.v(TAG, "onSensorChanged : " + sensorStr); String[] fs = sensorStr.split(","); if (fs.length == 4) { acceValusW = Float.parseFloat(fs[0]) * (BASE - 10); // 获得x轴的值 acceValusX = Float.parseFloat(fs[1]) * (BASE - 10); // 获得y轴的值 acceValusY = Float.parseFloat(fs[2]) * (BASE - 10); // 获得z轴的值 acceValusZ = Float.parseFloat(fs[3]) * (BASE - 10); // 锁定整个SurfaceView Canvas mCanvas = mSurfaceHolder.lockCanvas(); try { if (mCanvas != null) { // 画笔的颜色(红) mPaint.setColor(Color.RED); // 画X轴的点 mCanvas.drawPoint(x, (int) (BASE + acceValusX), mPaint); // 画笔的颜色(绿) mPaint.setColor(Color.GREEN); // 画Y轴的点 mCanvas.drawPoint(x, (int) (BASE * 2 + acceValusY), mPaint); // 画笔的颜色(蓝) mPaint.setColor(Color.CYAN); // 画Z轴的点 mCanvas.drawPoint(x, (int) (BASE * 3 + acceValusZ), mPaint); // 画笔的颜色(huang) mPaint.setColor(Color.WHITE); // 画W轴的点 mCanvas.drawPoint(x, (int) (BASE * 4 + acceValusW), mPaint); // 横坐标+1 x++; // 如果已经画到了屏幕的最右边 // if (x > getWindowManager().getDefaultDisplay().getWidth()) { if (x > mCanvas.getWidth()) { x = 0; // 清屏 mCanvas.drawColor(Color.BLACK); } // 绘制完成,提交修改 mSurfaceHolder.unlockCanvasAndPost(mCanvas); } } catch (Exception e) { e.printStackTrace(); } finally { if (mCanvas != null) { // 重新锁一次 mSurfaceHolder.lockCanvas(new Rect(0, 0, 0, 0)); mSurfaceHolder.unlockCanvasAndPost(mCanvas); } } } }
@Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); // canvas canvas.drawLine( canvas.getWidth() / 2 - 200, canvas.getHeight() / 2 + 50, canvas.getWidth(), canvas.getHeight() / 2 + 50, red); // xaxis canvas.drawLine( canvas.getWidth() / 2 - 150, canvas.getHeight() / 2 - 800, canvas.getWidth() / 2 - 150, canvas.getHeight() / 2 + 100, red); // yaxis for (int i = 0; i <= 720; i++) // curve { int x = i + (canvas.getWidth() / 2 - 150); int y = (int) ((canvas.getHeight() / 2 + 50) + ((float) Math.sin(Math.toRadians(2 * i))) * 100); canvas.drawPoint(x, y, blue); } }
public void handleResult( final Result scanResult, final Bitmap thumbnailImage, final float thumbnailScaleFactor) { vibrator.vibrate(VIBRATE_DURATION); // superimpose dots to highlight the key features of the qr code final ResultPoint[] points = scanResult.getResultPoints(); if (points != null && points.length > 0) { final Paint paint = new Paint(); paint.setColor(getResources().getColor(R.color.scan_result_dots)); paint.setStrokeWidth(10.0f); final Canvas canvas = new Canvas(thumbnailImage); canvas.scale(thumbnailScaleFactor, thumbnailScaleFactor); for (final ResultPoint point : points) canvas.drawPoint(point.getX(), point.getY(), paint); } scannerView.drawResultBitmap(thumbnailImage); final Intent result = new Intent(); result.putExtra(INTENT_EXTRA_RESULT, scanResult.getText()); setResult(RESULT_OK, result); // delayed finish new Handler() .post( new Runnable() { @Override public void run() { finish(); } }); }
/** * The graphical representation of the legend shape. * * @param canvas the canvas to paint to * @param renderer the series renderer * @param x the x value of the point the shape should be drawn at * @param y the y value of the point the shape should be drawn at * @param seriesIndex the series index * @param paint the paint to be used for drawing */ public void drawLegendShape( Canvas canvas, SimpleSeriesRenderer renderer, float x, float y, int seriesIndex, Paint paint) { if (((XYSeriesRenderer) renderer).isFillPoints()) { paint.setStyle(Style.FILL); } else { paint.setStyle(Style.STROKE); } switch (((XYSeriesRenderer) renderer).getPointStyle()) { case X: drawX(canvas, paint, x + size, y); break; case CIRCLE: drawCircle(canvas, paint, x + size, y); break; case TRIANGLE: drawTriangle(canvas, paint, new float[6], x + size, y); break; case SQUARE: drawSquare(canvas, paint, x + size, y); break; case DIAMOND: drawDiamond(canvas, paint, new float[8], x + size, y); break; case POINT: canvas.drawPoint(x + size, y, paint); break; } }
@Override public void draw(Canvas mCanvas) { // TODO 自動產生的方法 Stub Paint paint = new Paint(); paint.setAntiAlias(true); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(5); paint.setColor(color); float r = (stopY - startY) / 4; /* 心两半圆结点处 */ float topX = startX + 100; float topY = startY - r + 100; /* 左上半圆 */ RectF leftOval = new RectF(topX - 2 * r, topY - r, topX, topY + r); mCanvas.drawArc(leftOval, 180f, 180f, false, paint); /* 右上半圆 */ RectF rightOval = new RectF(topX, topY - r, topX + 2 * r, topY + r); mCanvas.drawArc(rightOval, 180f, 180f, false, paint); /* 下半两sin曲线 */ float base = 3 * r; double argu = Math.PI / 2 / base; float y = base, value; while (y >= 0) { value = (float) (2 * r * Math.sin(argu * (base - y))); mCanvas.drawPoint(topX - value, topY + y, paint); mCanvas.drawPoint(topX + value, topY + y, paint); y -= 1; } }
private void addBezier(Bezier curve, float startWidth, float endWidth) { ensureSignatureBitmap(); float originalWidth = mPaint.getStrokeWidth(); float widthDelta = endWidth - startWidth; float drawSteps = (float) Math.floor(curve.length()); for (int i = 0; i < drawSteps; i++) { // Calculate the Bezier (x, y) coordinate for this step. float t = ((float) i) / drawSteps; float tt = t * t; float ttt = tt * t; float u = 1 - t; float uu = u * u; float uuu = uu * u; float x = uuu * curve.startPoint.x; x += 3 * uu * t * curve.control1.x; x += 3 * u * tt * curve.control2.x; x += ttt * curve.endPoint.x; float y = uuu * curve.startPoint.y; y += 3 * uu * t * curve.control1.y; y += 3 * u * tt * curve.control2.y; y += ttt * curve.endPoint.y; // Set the incremental stroke width and draw. mPaint.setStrokeWidth(startWidth + ttt * widthDelta); mSignatureBitmapCanvas.drawPoint(x, y, mPaint); expandDirtyRect(x, y); } mPaint.setStrokeWidth(originalWidth); }
/*Draws the Snow Flakes*/ public void draw(Canvas canvas) { for (int i = 0; i < nSnow; i++) { moveSnow(snowArray[i]); mPaint.setColor(snowArray[i].color); canvas.drawPoint(snowArray[i].x, snowArray[i].y, mPaint); } }
/** * Superimpose a line for 1D or dots for 2D to highlight the key features of the barcode. * * @param barcode A bitmap of the captured image. * @param scaleFactor amount by which thumbnail was scaled * @param rawResult The decoded results which contains the points to draw. */ private void drawResultPoints(Bitmap barcode, float scaleFactor, Result rawResult) { ResultPoint[] points = rawResult.getResultPoints(); if (points != null && points.length > 0) { Canvas canvas = new Canvas(barcode); Paint paint = new Paint(); paint.setColor(getResources().getColor(R.color.result_points)); if (points.length == 2) { paint.setStrokeWidth(4.0f); drawLine(canvas, paint, points[0], points[1], scaleFactor); } else if (points.length == 4 && (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A || rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) { // Hacky special case -- draw two lines, for the barcode and metadata drawLine(canvas, paint, points[0], points[1], scaleFactor); drawLine(canvas, paint, points[2], points[3], scaleFactor); } else { paint.setStrokeWidth(10.0f); for (ResultPoint point : points) { if (point != null) { canvas.drawPoint(scaleFactor * point.getX(), scaleFactor * point.getY(), paint); } } } } }
/** * @param color Color of result points * @return {@link Bitmap} with result points on it, or plain bitmap, if no result points */ public Bitmap getBitmapWithResultPoints(int color) { Bitmap bitmap = getBitmap(); Bitmap barcode = bitmap; ResultPoint[] points = mResult.getResultPoints(); if (points != null && points.length > 0 && bitmap != null) { barcode = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(barcode); canvas.drawBitmap(bitmap, 0, 0, null); Paint paint = new Paint(); paint.setColor(color); if (points.length == 2) { paint.setStrokeWidth(PREVIEW_LINE_WIDTH); drawLine(canvas, paint, points[0], points[1], mScaleFactor); } else if (points.length == 4 && (mResult.getBarcodeFormat() == BarcodeFormat.UPC_A || mResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) { // Hacky special case -- draw two lines, for the barcode and metadata drawLine(canvas, paint, points[0], points[1], mScaleFactor); drawLine(canvas, paint, points[2], points[3], mScaleFactor); } else { paint.setStrokeWidth(PREVIEW_DOT_WIDTH); for (ResultPoint point : points) { if (point != null) { canvas.drawPoint(point.getX() / mScaleFactor, point.getY() / mScaleFactor, paint); } } } } return barcode; }
protected void drawResultPoints(Bitmap barcode, Result rawResult) { ResultPoint[] points = rawResult.getResultPoints(); if (points != null && points.length > 0) { Canvas canvas = new Canvas(barcode); Paint paint = new Paint(); paint.setColor(getResources().getColor(R.color.result_image_border)); paint.setStrokeWidth(3.0f); paint.setStyle(Paint.Style.STROKE); Rect border = new Rect(2, 2, barcode.getWidth() - 2, barcode.getHeight() - 2); canvas.drawRect(border, paint); paint.setColor(getResources().getColor(R.color.result_points)); if (points.length == 2) { paint.setStrokeWidth(4.0f); drawLine(canvas, paint, points[0], points[1]); } else if (points.length == 4 && (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A || rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) { // Hacky special case -- draw two lines, for the barcode and // metadata drawLine(canvas, paint, points[0], points[1]); drawLine(canvas, paint, points[2], points[3]); } else { paint.setStrokeWidth(10.0f); for (ResultPoint point : points) { canvas.drawPoint(point.getX(), point.getY(), paint); } } } }
private void drawPoints(Canvas canvas, Paint paint) { int color = randomColor(); int stopX = random.nextInt(width); int stopY = random.nextInt(height); paint.setStrokeWidth(1); paint.setColor(color); canvas.drawPoint(stopX, stopY, paint); }
// -- Lo que hace es dibujar un pixel en nuestro frame buffer artificial atravez del metodo canvas // drawPoint --// @Override public void drawPixel(int x, int y, int color) { paint.setColor(color); // Primero configuramos el color de nuestra variable canvas.drawPoint( x, y, paint); // Se lo pasamos al metodo con el cual vamos a dibujar, ademas del color le pasamos // las coordendas de ese pixel }
private void touch_start(float x, float y) { mPath.reset(); mPath.moveTo(x, y); mCanvas.drawPoint(x, y, mPaint); mX = x; mY = y; mCanvas.drawPath(mPath, mPaint); }
public void draw(Canvas canvas) { Paint paint = new Paint(); paint.setStrokeWidth(size); paint.setColor(color); paint.setStyle(Paint.Style.STROKE); paint.setStrokeJoin(Paint.Join.ROUND); paint.setStrokeCap(Paint.Cap.ROUND); canvas.drawPoint(x, y, paint); }
private float debugDrawPoint( Canvas canvas, String name, float X, float Y, int color, float posX, float posY) { mTextPaint.setColor(color); drawTextShadowed(canvas, name, posX, posY, mTextPaint, mTextPaintShadow); Paint paint = new Paint(); paint.setStrokeWidth(5); paint.setColor(color); canvas.drawPoint(X, Y, paint); return posY + 15; }
private void touch_up() { if (mCurrentPath.isEmpty()) { mCanvas.drawPoint(mX, mY, pointPaint); } else { mCurrentPath.lineTo(mX, mY); // commit the path to our offscreen mCanvas.drawPath(mCurrentPath, paint); } // kill this so we don't double draw mCurrentPath.reset(); }
public void drawCirclePoint( Canvas canvas, PointF pointF, PointF dataPointF, T pointData, float textSize, boolean isTextSize, int decimalPlaces) { mPointF.x = pointF.x; mPointF.y = -pointF.y; switch (pointData.getPointShape()) { case CIRCLE: canvas.drawCircle(pointF.x, pointF.y, pointData.getOutRadius(), pointData.getOutPaint()); canvas.drawCircle(pointF.x, pointF.y, pointData.getInRadius(), pointData.getInPaint()); break; case RECT: pointData.getOutPaint().setStrokeCap(Paint.Cap.SQUARE); pointData.getOutPaint().setStrokeWidth(pointData.getOutRadius() * 2); canvas.drawPoint(pointF.x, pointF.y, pointData.getOutPaint()); break; case SOLIDROUND: pointData.getOutPaint().setStrokeCap(Paint.Cap.ROUND); pointData.getOutPaint().setStrokeWidth(pointData.getOutRadius() * 2); canvas.drawPoint(pointF.x, pointF.y, pointData.getOutPaint()); break; } if (isTextSize) { numberFormatY = NumberFormat.getNumberInstance(); numberFormatY.setMaximumFractionDigits(decimalPlaces); mPaint.setTextSize(textSize); fontMetrics = mPaint.getFontMetrics(); mPointF.y = -mPointF.y + (fontMetrics.top - fontMetrics.bottom); textCenter( new String[] {numberFormatY.format(dataPointF.y)}, mPaint, canvas, mPointF, Paint.Align.CENTER); } }
private void handDraw(byte[] packetData) { try { int penWidthNum = myConvertByteArrToInt_bigend(packetData, 4); int penColorNum = myConvertByteArrToInt_bigend(packetData, 8); int nums = myConvertByteArrToInt_bigend(packetData, 12); int BYTES_PER_COORDINATE = 2; for (int i = 0; i < nums / 4; i++) { int x = xCoordinateMap( myConvertByteArrToShort_bigend(packetData, 16 + i * 2 * BYTES_PER_COORDINATE)); int y = yCoordinateMap( myConvertByteArrToShort_bigend( packetData, 16 + i * 2 * BYTES_PER_COORDINATE + BYTES_PER_COORDINATE)); String str = (i + 1) + " (x=" + x + ",y=" + y + ")"; writeToMyLogFile(str); if (i == 0) { lastX = x; lastY = y; mPath = new Path(); mPath.moveTo(x, y); mPaint = getAPaint(); mPaint.setStrokeWidth(penWidthMap.get(penWidthNum)); mPaint.setColor(penColorMap.get(penColorNum)); HistoryItem item = new HistoryItem(HistoryItem.TYPE_PATH, mPaint, mPath, null, null); undoPathList.add(item); // mCacheCanvas.drawPoint(x, y, mPaint); } else { int dx = Math.abs(x - lastX); int dy = Math.abs(y - lastY); if (dx >= BezierCurveMinGap || dy >= BezierCurveMinGap) { mPath.quadTo(lastX, lastY, ((lastX + x) / 2.0f), ((lastY + y) / 2.0f)); lastX = x; lastY = y; mCacheCanvas.drawPath(mPath, mPaint); handler.sendEmptyMessage(CustomDrawViewCH_INVALIDATE); } } } } catch (Exception e) { e.printStackTrace(); Logg.e(TAG, "handdraw error"); } }
public static Bitmap getChromakey(Context c) { Bitmap chroma = BitmapFactory.decodeResource(c.getResources(), R.drawable.test_chromakey); Bitmap bg = BitmapFactory.decodeResource(c.getResources(), R.drawable.landscape1); Bitmap composite = Bitmap.createBitmap(bg.getWidth(), bg.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(composite); Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG); // canvas.drawBitmap(bg, 0, 0, paint); // Slow method: scan all input (layer) image pixels and corresponding background pixels. // Calculate its "greenness" and translucency and recreate the pixels' values, plotting // them over the background. int bgPixel, lPixel; float targetHue = 97f / 360f; float tolerance = 0.1f; int bgRed, bgGreen, bgBlue, lRed, lGreen, lBlue, oRed, oGreen, oBlue; for (int w = 0; w < bg.getWidth(); w++) for (int h = 0; h < bg.getHeight(); h++) { // Background pixels. bgPixel = bg.getPixel(w, h); bgRed = Color.red(bgPixel); // Red level bgGreen = Color.green(bgPixel); // Green level bgBlue = Color.blue(bgPixel); // Blue level // Layer pixels. lPixel = chroma.getPixel(w, h); lRed = Color.red(lPixel); // Red level lGreen = Color.green(lPixel); // Green level lBlue = Color.blue(lPixel); // Blue level float[] lHSB = new float[3]; Color.RGBToHSV(lRed, lGreen, lBlue, lHSB); // Calculate the translucency, based on the green value of the layer, using HSB coordinates. // To make calculations easier, let's assume that the translucency is a value between 0 // (invisible) and 1 (opaque). float deltaHue = Math.abs((lHSB[0] / 360) - targetHue); float translucency = (deltaHue / tolerance); translucency = Math.min(translucency, 1f); // Recalculate the RGB coordinates of the layer and background pixels, using the // translucency // as a weight. oRed = (int) (translucency * lRed + (1 - translucency) * bgRed); oGreen = (int) (translucency * lGreen + (1 - translucency) * bgGreen); oBlue = (int) (translucency * lBlue + (1 - translucency) * bgBlue); // Set the pixel on the output image's raster. // raster.setPixel(w+shiftX,h+shiftY,new int[]{oRed,oGreen,oBlue,255}); paint = new Paint(); paint.setColor(Color.rgb(oRed, oGreen, oBlue)); canvas.drawPoint(w, h, paint); } // end for return composite; }
public void drawPoint(Canvas canvas, Point point) { Paint paint; paint = new Paint(); if (isSatelliteMap) { paint.setColor(Color.YELLOW); } else { paint.setColor(Color.BLUE); } paint.setAntiAlias(true); paint.setStyle(Style.STROKE); paint.setStrokeWidth(3); canvas.drawPoint(point.x, point.y, paint); }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); mPaint.setColor(Color.GREEN); int i, j; double x, y, r; // x = r * Math.cos(Math.PI / 45 * j) * Math.sin(Math.PI / 45 * i) + 320 / 2; // y = -r * Math.sin(Math.PI / 45 * j) + 400 / 4; for (i = width; i <= 90; i++) { for (j = height; j <= 90; j++) { r = Math.PI / 45 * i * (1 - Math.sin(Math.PI / 45 * j)) * 20; x = r * Math.cos(Math.PI / 45 * j) * Math.sin(Math.PI / 45 * i) + 320 / 2; y = -r * Math.sin(Math.PI / 45 * j) + 400 / 4; canvas.drawPoint((float) x, (float) y, mPaint); } } }
protected void drawCircle(Canvas canvas, Point curScreenCoords, MapView mapView) { Paint lp4; lp4 = new Paint(); lp4.setColor(Color.RED); lp4.setAntiAlias(true); lp4.setStyle(Style.STROKE); canvas.drawCircle(mapView.getWidth() / 2, mapView.getHeight() / 2, 20, lp4); // Paint lp4; lp4 = new Paint(); lp4.setColor(Color.RED); lp4.setAntiAlias(true); lp4.setStyle(Style.STROKE); canvas.drawCircle(mapView.getWidth() / 2, mapView.getHeight() / 2, 5, lp4); Paint point; point = new Paint(); point.setColor(Color.RED); point.setAntiAlias(true); point.setStyle(Style.STROKE); point.setStrokeWidth(3); canvas.drawPoint(mapView.getWidth() / 2, mapView.getHeight() / 2, point); }
/** * Superimpose a line for 1D or dots for 2D to highlight the key features of the barcode. * * @param barcode A bitmap of the captured image. * @param rawResult The decoded results which contains the points to draw. */ private void drawResultPoints(Bitmap barcode, Result rawResult) { ResultPoint[] points = rawResult.getResultPoints(); if (points != null && points.length > 0) { Canvas canvas = new Canvas(barcode); Paint paint = new Paint(); paint.setColor(getResources().getColor(R.color.result_image_border)); paint.setStrokeWidth(3.0f); paint.setStyle(Paint.Style.STROKE); Rect border = new Rect(2, 2, barcode.getWidth() - 2, barcode.getHeight() - 2); canvas.drawRect(border, paint); paint.setColor(getResources().getColor(R.color.result_points)); if (points.length == 2) { paint.setStrokeWidth(4.0f); canvas.drawLine( points[0].getX(), points[0].getY(), points[1].getX(), points[1].getY(), paint); } else { paint.setStrokeWidth(10.0f); for (ResultPoint point : points) { canvas.drawPoint(point.getX(), point.getY(), paint); } } } }
@Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); int counter = permissionModle.getNumOfPermissions(); if (counter == 0) { // 放入一张图片 } else { float horbetween = (rightBound - leftBound) / 7; float verbetween = (bottomBound - topBound) / 28; mPaint.setAntiAlias(true); // 绘制坐标 mPaint.setColor(Color.BLACK); canvas.drawLine(leftBound, bottomBound, rightBound, bottomBound, mPaint); canvas.drawLine(leftBound, topBound, leftBound, bottomBound, mPaint); // 警戒线 mPaint.setColor(Color.RED); mPaint.setStrokeWidth(5); canvas.drawLine( leftBound, bottomBound - ((bottomBound - topBound) / 28) * 20, rightBound, bottomBound - ((bottomBound - topBound) / 28) * 20, mPaint); // App只获得一个权限 if (counter == 1) { float x = 0, y = 0; if (permissionModle.isSendMsg()) { x = horbetween; y = verbetween * 1; setSendMsgColor(); } if (permissionModle.isReadCtc()) { x = horbetween; y = verbetween * 2; setReadCtcColor(); } if (permissionModle.isReadPhone()) { x = horbetween; y = verbetween * 3; setReadPhoneColor(); } if (permissionModle.isTrack()) { x = horbetween; y = verbetween * 4; setTrackColor(); } if (permissionModle.isIMEI()) { x = horbetween; y = verbetween * 5; setIMEIColor(); } if (permissionModle.isRoot()) { x = horbetween; y = verbetween * 6; setRootColor(); } if (permissionModle.isMonitorCall()) { x = horbetween; y = verbetween * 7; setMonitorCallColor(); } mPaint.setStrokeWidth(8); canvas.drawPoint(x + leftBound, bottomBound - y, mPaint); } // App获得三个权限 if (counter == 3) { float x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0; int j = 0; int beforeOne = 0, beforeTwo = 0; int[] flags = {1, 2, 3, 4, 5, 6, 7}; x1 = horbetween * 1; x2 = horbetween * 2; x3 = horbetween * 3; while (j < 3) { if (permissionModle.isSendMsg() && (flags[0] == 1)) { y1 = verbetween * 1; beforeOne = 1; flags[0] = 0; setSendMsgColor(); } else if (permissionModle.isReadCtc() && (flags[1] == 2)) { switch (j) { case 0: y1 = verbetween * 2; beforeOne = 2; break; case 1: y2 = verbetween * (2 + beforeOne); beforeTwo = 2; break; case 2: y3 = verbetween * (2 + beforeOne + beforeTwo); break; default: break; } flags[1] = 0; setReadCtcColor(); } else if (permissionModle.isReadPhone() && (flags[2] == 3)) { switch (j) { case 0: y1 = verbetween * 3; beforeOne = 3; break; case 1: y2 = verbetween * (3 + beforeOne); beforeTwo = 3; break; case 2: y3 = verbetween * (3 + beforeOne + beforeTwo); break; default: break; } flags[2] = 0; setReadPhoneColor(); } else if (permissionModle.isTrack() && (flags[3] == 4)) { switch (j) { case 0: y1 = verbetween * 4; beforeOne = 4; break; case 1: y2 = verbetween * (4 + beforeOne); beforeTwo = 4; break; case 2: y3 = verbetween * (4 + beforeOne + beforeTwo); break; default: break; } flags[3] = 0; setTrackColor(); } else if (permissionModle.isIMEI() && (flags[4] == 5)) { switch (j) { case 0: y1 = verbetween * 5; beforeOne = 5; break; case 1: y2 = verbetween * (5 + beforeOne); beforeTwo = 5; break; case 2: y3 = verbetween * (5 + beforeOne + beforeTwo); break; default: break; } flags[4] = 0; setIMEIColor(); } else if (permissionModle.isRoot() && (flags[5] == 6)) { switch (j) { case 0: y1 = verbetween * 6; beforeOne = 6; break; case 1: y2 = verbetween * (6 + beforeOne); beforeTwo = 6; break; case 2: y3 = verbetween * (6 + beforeOne + beforeTwo); break; default: break; } flags[5] = 0; setRootColor(); } else if (permissionModle.isMonitorCall() && (flags[6] == 7)) { switch (j) { case 0: y1 = verbetween * 7; beforeOne = 7; break; case 1: y2 = verbetween * (7 + beforeOne); beforeTwo = 7; break; case 2: y3 = verbetween * (7 + beforeOne + beforeTwo); break; default: break; } flags[6] = 0; setMonitorCallColor(); } if (j == 0) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x1, bottomBound - y1, mPaint); } if (j == 1) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x2, bottomBound - y2, mPaint); } if (j == 2) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x3, bottomBound - y3, mPaint); } j++; } mPaint.setStrokeWidth(5); mPaint.setColor(Color.BLUE); canvas.drawLine(leftBound + x1, bottomBound - y1, leftBound + x2, bottomBound - y2, mPaint); canvas.drawLine(leftBound + x2, bottomBound - y2, leftBound + x3, bottomBound - y3, mPaint); } // App取得两个权限 if (counter == 2) { float x1 = 0, y1 = 0, x2 = 0, y2 = 0; int j = 0; int beforeOne = 0; int[] flags = {1, 2, 3, 4, 5, 6, 7}; x1 = horbetween * 1; x2 = horbetween * 2; while (j < 2) { if (permissionModle.isSendMsg() && (flags[0] == 1)) { y1 = verbetween * 1; flags[0] = 0; beforeOne = 1; setSendMsgColor(); } else if (permissionModle.isReadCtc() && (flags[1] == 2)) { switch (j) { case 0: y1 = verbetween * 2; beforeOne = 2; break; case 1: y2 = verbetween * (2 + beforeOne); break; default: break; } flags[1] = 0; setReadCtcColor(); } else if (permissionModle.isReadPhone() && (flags[2] == 3)) { switch (j) { case 0: y1 = verbetween * 3; beforeOne = 3; break; case 1: y2 = verbetween * (3 + beforeOne); break; default: break; } flags[2] = 0; setReadPhoneColor(); } else if (permissionModle.isTrack() && (flags[3] == 4)) { switch (j) { case 0: y1 = verbetween * 4; beforeOne = 4; break; case 1: y2 = verbetween * (4 + beforeOne); break; default: break; } flags[3] = 0; setTrackColor(); } else if (permissionModle.isIMEI() && (flags[4] == 5)) { switch (j) { case 0: y1 = verbetween * 5; beforeOne = 5; break; case 1: y2 = verbetween * (5 + beforeOne); break; default: break; } flags[4] = 0; setIMEIColor(); } else if (permissionModle.isRoot() && (flags[5] == 6)) { switch (j) { case 0: y1 = verbetween * 6; beforeOne = 6; break; case 1: y2 = verbetween * (6 + beforeOne); break; default: break; } flags[5] = 0; setRootColor(); } else if (permissionModle.isMonitorCall() && (flags[6] == 7)) { switch (j) { case 0: y1 = verbetween * 7; beforeOne = 7; break; case 1: y2 = verbetween * (7 + beforeOne); break; default: break; } flags[6] = 0; setMonitorCallColor(); } if (j == 0) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x1, bottomBound - y1, mPaint); } if (j == 1) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x2, bottomBound - y2, mPaint); } j++; } mPaint.setStrokeWidth(5); mPaint.setColor(Color.BLUE); canvas.drawLine(leftBound + x1, bottomBound - y1, leftBound + x2, bottomBound - y2, mPaint); } // App获得四个权限 if (counter == 4) { float x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0, x4 = 0, y4 = 0; int j = 0; int beforeOne = 0, beforeTwo = 0, beforeThree = 0; int[] flags = {1, 2, 3, 4, 5, 6, 7}; x1 = horbetween * 1; x2 = horbetween * 2; x3 = horbetween * 3; x4 = horbetween * 4; while (j < 4) { if (permissionModle.isSendMsg() && (flags[0] == 1)) { y1 = verbetween * 1; beforeOne = 1; flags[0] = 0; setSendMsgColor(); } else if (permissionModle.isReadCtc() && (flags[1] == 2)) { switch (j) { case 0: y1 = verbetween * 2; beforeOne = 2; break; case 1: y2 = verbetween * (2 + beforeOne); beforeTwo = 2; break; case 2: y3 = verbetween * (2 + beforeOne + beforeTwo); break; case 3: y4 = verbetween * (2 + beforeOne + beforeTwo + beforeThree); break; default: break; } flags[1] = 0; setReadCtcColor(); } else if (permissionModle.isReadPhone() && (flags[2] == 3)) { switch (j) { case 0: y1 = verbetween * 3; beforeOne = 3; break; case 1: y2 = verbetween * (3 + beforeOne); beforeTwo = 3; break; case 2: y3 = verbetween * (3 + beforeOne + beforeTwo); beforeThree = 3; break; case 3: y4 = verbetween * (3 + beforeOne + beforeTwo + beforeThree); break; default: break; } flags[2] = 0; setReadPhoneColor(); } else if (permissionModle.isTrack() && (flags[3] == 4)) { switch (j) { case 0: y1 = verbetween * 4; beforeOne = 4; break; case 1: y2 = verbetween * (4 + beforeOne); beforeTwo = 4; break; case 2: y3 = verbetween * (4 + beforeOne + beforeTwo); beforeThree = 4; break; case 3: y4 = verbetween * (4 + beforeOne + beforeTwo + beforeThree); break; default: break; } flags[3] = 0; setTrackColor(); } else if (permissionModle.isIMEI() && (flags[4] == 5)) { switch (j) { case 0: y1 = verbetween * 5; beforeOne = 5; break; case 1: y2 = verbetween * (5 + beforeOne); beforeTwo = 5; break; case 2: y3 = verbetween * (5 + beforeOne + beforeTwo); beforeThree = 5; break; case 3: y4 = verbetween * (5 + beforeOne + beforeTwo + beforeThree); break; default: break; } flags[4] = 0; setIMEIColor(); } else if (permissionModle.isRoot() && (flags[5] == 6)) { switch (j) { case 0: y1 = verbetween * 6; beforeOne = 6; break; case 1: y2 = verbetween * (6 + beforeOne); beforeTwo = 6; break; case 2: y3 = verbetween * (6 + beforeOne + beforeTwo); beforeThree = 6; break; case 3: y4 = verbetween * (6 + beforeOne + beforeTwo + beforeThree); break; default: break; } flags[5] = 0; setRootColor(); } else if (permissionModle.isMonitorCall() && (flags[6] == 7)) { switch (j) { case 0: y1 = verbetween * 7; break; case 1: y2 = verbetween * (7 + beforeOne); break; case 2: y3 = verbetween * (7 + beforeOne + beforeTwo); break; case 3: y4 = verbetween * (6 + beforeOne + beforeTwo + beforeThree); break; default: break; } flags[6] = 0; setMonitorCallColor(); } if (j == 0) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x1, bottomBound - y1, mPaint); } if (j == 1) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x2, bottomBound - y2, mPaint); } if (j == 2) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x3, bottomBound - y3, mPaint); } if (j == 3) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x4, bottomBound - y4, mPaint); } j++; } mPaint.setStrokeWidth(5); mPaint.setColor(Color.BLUE); canvas.drawLine(leftBound + x1, bottomBound - y1, leftBound + x2, bottomBound - y2, mPaint); canvas.drawLine(leftBound + x2, bottomBound - y2, leftBound + x3, bottomBound - y3, mPaint); canvas.drawLine(leftBound + x3, bottomBound - y3, leftBound + x4, bottomBound - y4, mPaint); } // app获得6个权限 if (counter == 6) { float x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0, x4 = 0, y4 = 0, x5 = 0, y5 = 0, x6 = 0, y6 = 0; int j = 0; int beforeOne = 0, beforeTwo = 0, beforeThree = 0, beforeFour = 0, beforeFive = 0; int[] flags = {1, 2, 3, 4, 5, 6, 7}; x1 = horbetween * 1; x2 = horbetween * 2; x3 = horbetween * 3; x4 = horbetween * 4; x5 = horbetween * 5; x6 = horbetween * 6; while (j < 6) { if (permissionModle.isSendMsg() && (flags[0] == 1)) { y1 = verbetween * 1; beforeOne = 1; flags[0] = 0; setSendMsgColor(); } else if (permissionModle.isReadCtc() && (flags[1] == 2)) { switch (j) { case 0: y1 = verbetween * 2; beforeOne = 2; break; case 1: y2 = verbetween * (2 + beforeOne); beforeTwo = 2; break; default: break; } flags[1] = 0; setReadCtcColor(); } else if (permissionModle.isReadPhone() && (flags[2] == 3)) { switch (j) { case 0: y1 = verbetween * 3; beforeOne = 3; break; case 1: y2 = verbetween * (3 + beforeOne); beforeTwo = 3; break; case 2: y3 = verbetween * (3 + beforeOne + beforeTwo); beforeThree = 3; break; default: break; } flags[2] = 0; setReadPhoneColor(); } else if (permissionModle.isTrack() && (flags[3] == 4)) { switch (j) { case 0: y1 = verbetween * 4; beforeOne = 4; break; case 1: y2 = verbetween * (4 + beforeOne); beforeTwo = 4; break; case 2: y3 = verbetween * (4 + beforeOne + beforeTwo); beforeThree = 4; break; case 3: y4 = verbetween * (4 + beforeOne + beforeTwo + beforeThree); beforeFour = 4; break; default: break; } flags[3] = 0; setTrackColor(); } else if (permissionModle.isIMEI() && (flags[4] == 5)) { switch (j) { case 0: y1 = verbetween * 5; beforeOne = 5; break; case 1: y2 = verbetween * (5 + beforeOne); beforeTwo = 5; break; case 2: y3 = verbetween * (5 + beforeOne + beforeTwo); beforeThree = 5; break; case 3: y4 = verbetween * (5 + beforeOne + beforeTwo + beforeThree); beforeFour = 5; break; case 4: y5 = verbetween * (5 + beforeOne + beforeTwo + beforeThree + beforeFour); beforeFive = 5; default: break; } flags[4] = 0; setIMEIColor(); } else if (permissionModle.isRoot() && (flags[5] == 6)) { switch (j) { case 0: y1 = verbetween * 6; beforeOne = 6; break; case 1: y2 = verbetween * (6 + beforeOne); beforeTwo = 6; break; case 2: y3 = verbetween * (6 + beforeOne + beforeTwo); beforeThree = 6; break; case 3: y4 = verbetween * (6 + beforeOne + beforeTwo + beforeThree); break; case 4: y5 = verbetween * (5 + beforeOne + beforeTwo + beforeThree + beforeFour); beforeFive = 5; break; case 5: y6 = verbetween * (6 + beforeOne + beforeTwo + beforeThree + beforeFour + beforeFive); break; default: break; } flags[5] = 0; setRootColor(); } else if (permissionModle.isMonitorCall() && (flags[6] == 7)) { switch (j) { case 0: y1 = verbetween * 7; break; case 1: y2 = verbetween * (7 + beforeOne); break; case 2: y3 = verbetween * (7 + beforeOne + beforeTwo); break; case 3: y4 = verbetween * (6 + beforeOne + beforeTwo + beforeThree); break; case 4: y5 = verbetween * (5 + beforeOne + beforeTwo + beforeThree + beforeFour); beforeFive = 5; break; case 5: y6 = verbetween * (7 + beforeOne + beforeTwo + beforeThree + beforeFour + beforeFive); break; default: break; } flags[6] = 0; setMonitorCallColor(); } if (j == 0) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x1, bottomBound - y1, mPaint); } if (j == 1) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x2, bottomBound - y2, mPaint); } if (j == 2) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x3, bottomBound - y3, mPaint); } if (j == 3) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x4, bottomBound - y4, mPaint); } if (j == 4) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x5, bottomBound - y5, mPaint); } if (j == 5) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x6, bottomBound - y6, mPaint); } j++; } mPaint.setStrokeWidth(5); mPaint.setColor(Color.BLUE); canvas.drawLine(leftBound + x1, bottomBound - y1, leftBound + x2, bottomBound - y2, mPaint); canvas.drawLine(leftBound + x2, bottomBound - y2, leftBound + x3, bottomBound - y3, mPaint); canvas.drawLine(leftBound + x3, bottomBound - y3, leftBound + x4, bottomBound - y4, mPaint); canvas.drawLine(leftBound + x4, bottomBound - y4, leftBound + x5, bottomBound - y5, mPaint); canvas.drawLine(leftBound + x5, bottomBound - y5, leftBound + x6, bottomBound - y6, mPaint); } // App获得5个权限 if (counter == 5) { float x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0, x4 = 0, y4 = 0, x5 = 0, y5 = 0; int j = 0; int beforeOne = 0, beforeTwo = 0, beforeThree = 0, beforeFour = 0; int[] flags = {1, 2, 3, 4, 5, 6, 7}; x1 = horbetween * 1; x2 = horbetween * 2; x3 = horbetween * 3; x4 = horbetween * 4; x5 = horbetween * 5; while (j < 5) { if (permissionModle.isSendMsg() && (flags[0] == 1)) { y1 = verbetween * 1; beforeOne = 1; flags[0] = 0; setSendMsgColor(); } else if (permissionModle.isReadCtc() && (flags[1] == 2)) { switch (j) { case 0: y1 = verbetween * 2; beforeOne = 2; break; case 1: y2 = verbetween * (2 + beforeOne); beforeTwo = 2; break; default: break; } flags[1] = 0; setReadCtcColor(); } else if (permissionModle.isReadPhone() && (flags[2] == 3)) { switch (j) { case 0: y1 = verbetween * 3; beforeOne = 3; break; case 1: y2 = verbetween * (3 + beforeOne); beforeTwo = 3; break; case 2: y3 = verbetween * (3 + beforeOne + beforeTwo); beforeThree = 3; break; default: break; } flags[2] = 0; setReadPhoneColor(); } else if (permissionModle.isTrack() && (flags[3] == 4)) { switch (j) { case 0: y1 = verbetween * 4; beforeOne = 4; break; case 1: y2 = verbetween * (4 + beforeOne); beforeTwo = 4; break; case 2: y3 = verbetween * (4 + beforeOne + beforeTwo); beforeThree = 4; break; case 3: y4 = verbetween * (4 + beforeOne + beforeTwo + beforeThree); beforeFour = 4; break; default: break; } flags[3] = 0; setTrackColor(); } else if (permissionModle.isIMEI() && (flags[4] == 5)) { switch (j) { case 0: y1 = verbetween * 5; beforeOne = 5; break; case 1: y2 = verbetween * (5 + beforeOne); beforeTwo = 5; break; case 2: y3 = verbetween * (5 + beforeOne + beforeTwo); beforeThree = 5; break; case 3: y4 = verbetween * (5 + beforeOne + beforeTwo + beforeThree); beforeFour = 5; break; case 4: y5 = verbetween * (5 + beforeOne + beforeTwo + beforeThree + beforeFour); default: break; } flags[4] = 0; setIMEIColor(); } else if (permissionModle.isRoot() && (flags[5] == 6)) { switch (j) { case 0: y1 = verbetween * 6; beforeOne = 6; break; case 1: y2 = verbetween * (6 + beforeOne); beforeTwo = 6; break; case 2: y3 = verbetween * (6 + beforeOne + beforeTwo); beforeThree = 6; break; case 3: y4 = verbetween * (6 + beforeOne + beforeTwo + beforeThree); break; case 4: y5 = verbetween * (5 + beforeOne + beforeTwo + beforeThree + beforeFour); default: break; } flags[5] = 0; setRootColor(); } else if (permissionModle.isMonitorCall() && (flags[6] == 7)) { switch (j) { case 0: y1 = verbetween * 7; break; case 1: y2 = verbetween * (7 + beforeOne); break; case 2: y3 = verbetween * (7 + beforeOne + beforeTwo); break; case 3: y4 = verbetween * (6 + beforeOne + beforeTwo + beforeThree); break; case 4: y5 = verbetween * (5 + beforeOne + beforeTwo + beforeThree + beforeFour); default: break; } flags[6] = 0; setMonitorCallColor(); } if (j == 0) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x1, bottomBound - y1, mPaint); } if (j == 1) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x2, bottomBound - y2, mPaint); } if (j == 2) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x3, bottomBound - y3, mPaint); } if (j == 3) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x4, bottomBound - y4, mPaint); } if (j == 4) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x5, bottomBound - y5, mPaint); } j++; } mPaint.setStrokeWidth(5); mPaint.setColor(Color.BLUE); canvas.drawLine(leftBound + x1, bottomBound - y1, leftBound + x2, bottomBound - y2, mPaint); canvas.drawLine(leftBound + x2, bottomBound - y2, leftBound + x3, bottomBound - y3, mPaint); canvas.drawLine(leftBound + x3, bottomBound - y3, leftBound + x4, bottomBound - y4, mPaint); canvas.drawLine(leftBound + x4, bottomBound - y4, leftBound + x5, bottomBound - y5, mPaint); } // App获得7个权限 if (counter == 7) { float x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0, x4 = 0, y4 = 0, x5 = 0, y5 = 0, x6 = 0, y6 = 0, x7 = 0, y7 = 0; int j = 0; int beforeOne = 0, beforeTwo = 0, beforeThree = 0, beforeFour = 0, beforeFive = 0, beforeSix = 0; int[] flags = {1, 2, 3, 4, 5, 6, 7}; x1 = horbetween * 1; x2 = horbetween * 2; x3 = horbetween * 3; x4 = horbetween * 4; x5 = horbetween * 5; x6 = horbetween * 6; x7 = horbetween * 7; while (j < 7) { if (permissionModle.isSendMsg() && (flags[0] == 1)) { y1 = verbetween * 1; beforeOne = 1; flags[0] = 0; setSendMsgColor(); } else if (permissionModle.isReadCtc() && (flags[1] == 2)) { switch (j) { case 0: y1 = verbetween * 2; beforeOne = 2; break; case 1: y2 = verbetween * (2 + beforeOne); beforeTwo = 2; break; default: break; } flags[1] = 0; setReadCtcColor(); } else if (permissionModle.isReadPhone() && (flags[2] == 3)) { switch (j) { case 0: y1 = verbetween * 3; beforeOne = 3; break; case 1: y2 = verbetween * (3 + beforeOne); beforeTwo = 3; break; case 2: y3 = verbetween * (3 + beforeOne + beforeTwo); beforeThree = 3; break; default: break; } flags[2] = 0; setReadPhoneColor(); } else if (permissionModle.isTrack() && (flags[3] == 4)) { switch (j) { case 0: y1 = verbetween * 4; beforeOne = 4; break; case 1: y2 = verbetween * (4 + beforeOne); beforeTwo = 4; break; case 2: y3 = verbetween * (4 + beforeOne + beforeTwo); beforeThree = 4; break; case 3: y4 = verbetween * (4 + beforeOne + beforeTwo + beforeThree); beforeFour = 4; break; default: break; } flags[3] = 0; setTrackColor(); } else if (permissionModle.isIMEI() && (flags[4] == 5)) { switch (j) { case 0: y1 = verbetween * 5; beforeOne = 5; break; case 1: y2 = verbetween * (5 + beforeOne); beforeTwo = 5; break; case 2: y3 = verbetween * (5 + beforeOne + beforeTwo); beforeThree = 5; break; case 3: y4 = verbetween * (5 + beforeOne + beforeTwo + beforeThree); beforeFour = 5; break; case 4: y5 = verbetween * (5 + beforeOne + beforeTwo + beforeThree + beforeFour); beforeFive = 5; default: break; } flags[4] = 0; setIMEIColor(); } else if (permissionModle.isRoot() && (flags[5] == 6)) { switch (j) { case 0: y1 = verbetween * 6; beforeOne = 6; break; case 1: y2 = verbetween * (6 + beforeOne); beforeTwo = 6; break; case 2: y3 = verbetween * (6 + beforeOne + beforeTwo); beforeThree = 6; break; case 3: y4 = verbetween * (6 + beforeOne + beforeTwo + beforeThree); break; case 4: y5 = verbetween * (5 + beforeOne + beforeTwo + beforeThree + beforeFour); beforeFive = 5; break; case 5: y6 = verbetween * (6 + beforeOne + beforeTwo + beforeThree + beforeFour + beforeFive); beforeSix = 6; break; default: break; } flags[5] = 0; setRootColor(); } else if (permissionModle.isMonitorCall() && (flags[6] == 7)) { switch (j) { case 0: y1 = verbetween * 7; break; case 1: y2 = verbetween * (7 + beforeOne); break; case 2: y3 = verbetween * (7 + beforeOne + beforeTwo); break; case 3: y4 = verbetween * (6 + beforeOne + beforeTwo + beforeThree); break; case 4: y5 = verbetween * (5 + beforeOne + beforeTwo + beforeThree + beforeFour); beforeFive = 5; break; case 5: y6 = verbetween * (7 + beforeOne + beforeTwo + beforeThree + beforeFour + beforeFive); break; case 6: y7 = verbetween * (7 + beforeOne + beforeTwo + beforeThree + beforeFour + beforeFive + beforeSix); break; default: break; } flags[6] = 0; setMonitorCallColor(); } if (j == 0) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x1, bottomBound - y1, mPaint); } if (j == 1) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x2, bottomBound - y2, mPaint); } if (j == 2) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x3, bottomBound - y3, mPaint); } if (j == 3) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x4, bottomBound - y4, mPaint); } if (j == 4) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x5, bottomBound - y5, mPaint); } if (j == 3) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x6, bottomBound - y6, mPaint); } if (j == 4) { mPaint.setStrokeWidth(8); canvas.drawPoint(leftBound + x7, bottomBound - y7, mPaint); } j++; } mPaint.setStrokeWidth(5); mPaint.setColor(Color.BLUE); canvas.drawLine(leftBound + x1, bottomBound - y1, leftBound + x2, bottomBound - y2, mPaint); canvas.drawLine(leftBound + x2, bottomBound - y2, leftBound + x3, bottomBound - y3, mPaint); canvas.drawLine(leftBound + x3, bottomBound - y3, leftBound + x4, bottomBound - y4, mPaint); canvas.drawLine(leftBound + x4, bottomBound - y4, leftBound + x5, bottomBound - y5, mPaint); canvas.drawLine(leftBound + x5, bottomBound - y5, leftBound + x6, bottomBound - y6, mPaint); canvas.drawLine(leftBound + x6, bottomBound - y6, leftBound + x7, bottomBound - y7, mPaint); } } }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); mPaint.reset(); mPaint.setAntiAlias(true); mPaint.setColor(Color.BLUE); mPaint.setStrokeWidth(10); float radius = 0; canvas.save(); canvas.translate(Math.min(mPoint.x, mTargetPoint.x), Math.min(mPoint.y, mTargetPoint.y)); switch (mType) { case TO_RADIUS: radius = Math.abs(mPoint.x - mTargetPoint.x) / 2; for (int i = 0; i < mDegress; i++) { int dx = (int) (radius + Math.cos((float) i / 360f * 2 * Math.PI) * radius); int dy = (int) (radius - Math.sin((float) i / 360f * 2 * Math.PI) * radius); canvas.drawPoint(dx, dy, mPaint); } break; case TO_CIRCLE: radius = Math.abs(mPoint.x - mTargetPoint.x); for (int i = 0; i < mDegress; i++) { int dx = (int) (radius + Math.cos((float) i / 360f * 2 * Math.PI) * radius); int dy = (int) (radius - Math.sin((float) i / 360f * 2 * Math.PI) * radius); canvas.drawPoint(dx, dy, mPaint); } break; case TO_POINT: float dx = 0, dy = 0; float width = Math.abs(mPoint.x - mTargetPoint.x); float height = Math.abs(mPoint.y - mTargetPoint.y); // 绘制长度 int length = (int) Math.max(width, height); // 短点的递增点 float value = Math.min(width, height) / length; // 确定方位 for (int i = 0; i < mDegress; i++) { if (mPoint.x < mTargetPoint.x) { if (width > height) { dx += 1; dy += value; } else { dy = mPoint.y; dx += value; dy += 1; } } else { dx = mTargetPoint.x; dy = mTargetPoint.y; if (width > height) { dx -= 1; dy -= value; } else { dx -= value; dy -= 1; } } canvas.drawPoint(dx, dy, mPaint); } break; default: break; } canvas.restore(); // 绘查看标记 canvas.drawCircle(mPoint.x, mPoint.y, 10f, mPaint); canvas.drawCircle(mTargetPoint.x, mTargetPoint.y, 10f, mPaint); if (TO_POINT != mType) { canvas.drawLine(mPoint.x, mPoint.y, mTargetPoint.x, mTargetPoint.y, mPaint); canvas.drawLine(mPoint.x, mPoint.y, mPoint.x, mPoint.y + radius, mPaint); canvas.drawLine( mTargetPoint.x, mTargetPoint.y, mTargetPoint.x, mTargetPoint.y + radius, mPaint); } }
@Override public void drawPixel(int x, int y, int color) { canvas.drawPoint(x, y, paint); }
@Override public void drawPixel(int x, int y, int color) { paint.setColor(color); canvas.drawPoint(x, y, paint); }
public boolean onTouch(View view, MotionEvent event) { float rx, ry; type = event.getAction(); // イベントのタイプ posx = event.getX(); // イベントが起きたX座標 posy = event.getY(); // イベントが起きたY座標 // イベントのタイプごとに処理を設定 switch (type) { case MotionEvent.ACTION_DOWN: // 最初のポイント // 現状の保存 bmpUndo = bmp.copy(Bitmap.Config.ARGB_8888, false); switch (mode) { // 通常描画時 case MODE_LINE: // パスを初期化 path = new Path(); // パスの始点へ移動 path.moveTo(posx, posy); break; // 円・四角描画時 case MODE_CIRCLE: case MODE_RECT: sttx = posx; stty = posy; break; } break; case MotionEvent.ACTION_MOVE: // 途中のポイント switch (mode) { // 通常描画時 case MODE_LINE: // ひとつ前のポイントから線を引く path.lineTo(posx, posy); // 描画バッファにパスを描画する if (path != null) { bmpCanvas.drawPath(path, paint); } break; // 円描画時 case MODE_CIRCLE: if (rr >= 0) { bmp2 = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); bmpCanvas2 = new Canvas(bmp2); bmpCanvas2.drawColor(Color.TRANSPARENT); } centerx = sttx + ((posx - sttx) / 2); centery = stty + ((posy - stty) / 2); rx = (float) Math.pow(posx - sttx, 2); ry = (float) Math.pow(posy - stty, 2); rr = (float) (Math.sqrt(rx + ry) / 2); bmpCanvas2.drawCircle(centerx, centery, rr, paint); break; // 四角描画時 case MODE_RECT: bmp2 = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); bmpCanvas2 = new Canvas(bmp2); bmpCanvas2.drawColor(Color.TRANSPARENT); float top, bottom, left, right; if (sttx > posx) { left = posx; right = sttx; } else { left = sttx; right = posx; } if (stty > posy) { top = posy; bottom = stty; } else { top = stty; bottom = posy; } bmpCanvas2.drawRect(left, top, right, bottom, paint); break; } break; case MotionEvent.ACTION_UP: // 最後のポイント switch (mode) { // 通常描画時 case MODE_LINE: // 点を打つ if ((posx == bakx) && (posy == baky)) { bmpCanvas.drawPoint(posx, posy, paint); } // ひとつ前のポイントから線を引く else { path.lineTo(posx, posy); // 描画バッファにパスを描画する if (path != null) { bmpCanvas.drawPath(path, paint); } } break; // 円描画時 case MODE_CIRCLE: bmp2 = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); bmpCanvas2 = new Canvas(bmp2); bmpCanvas2.drawColor(Color.TRANSPARENT); centerx = sttx + ((posx - sttx) / 2); centery = stty + ((posy - stty) / 2); rx = (float) Math.pow(posx - sttx, 2); ry = (float) Math.pow(posy - stty, 2); rr = (float) (Math.sqrt(rx + ry) / 2); bmpCanvas.drawCircle(centerx, centery, rr, paint); break; // 四角描画時 case MODE_RECT: bmp2 = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); bmpCanvas2 = new Canvas(bmp2); bmpCanvas2.drawColor(Color.TRANSPARENT); float top, bottom, left, right; if (sttx > posx) { left = posx; right = sttx; } else { left = sttx; right = posx; } if (stty > posy) { top = posy; bottom = stty; } else { top = stty; bottom = posy; } bmpCanvas.drawRect(left, top, right, bottom, paint); break; } break; default: break; } // 座標の保存 bakx = posx; baky = posy; return true; }
public void draw(Canvas canvas, Paint paint) { canvas.drawPoint(x, y, paint); }
/** * 自定义的方法,简单绘制一些基本图形 * * @param mCanvas 把图形画在mCanvas上 */ public void canvasMethod(Canvas mCanvas) { // 创建对应坐标的矩形区域 RectF mArc = new RectF(mX, mY - 70, mX + 50, mY - 20); // 画填充弧,在矩形区域内,从弧的最右边开始,画270度,然后再通过连接圆心来填充 mCanvas.drawArc(mArc, 0, 270, true, mPaint); // 获得icon的Bitmap对象 Bitmap mBitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); // 画图片 mCanvas.drawBitmap(mBitmap, mX, mY, mPaint); // 画圆,(x轴,y轴,半径,画笔) mCanvas.drawCircle(mX + 10, mY + 60, 10, mPaint); // 画一条线,(起点横坐标,起点纵坐标,终点横坐标,终点纵坐标,画笔) mCanvas.drawLine(mX, mY + 75, mX + 20, mY + 75, mPaint); // 画多条线,(坐标数组,画笔)坐标数组里每四个值构成一条线 mCanvas.drawLines( new float[] {mX + 50, mY + 45, mX + 50, mY + 75, mX + 60, mY + 45, mX + 60, mY + 75}, mPaint); // 创建对应矩形区域 RectF mOval = new RectF(mX, mY + 80, mX + 60, mY + 110); // 画椭圆 mCanvas.drawOval(mOval, mPaint); /* * Paint qPaint = new Paint(); qPaint.setColor(Color.RED); * mCanvas.drawPaint(qPaint); */ // 重置Path里的所有路径 mPath.reset(); // 设置Path的起点 mPath.moveTo(mX, mY + 120); // 第二个点 mPath.lineTo(screenW - 10, mY + 120); // 第三个点 mPath.lineTo(screenW - 10, mY + 150); // 画出路径,这里画的是三角形 mCanvas.drawPath(mPath, mPaint); // 重置Path里的所有路径 qPath.reset(); // 设置Path的起点 qPath.moveTo(qStartX, qStartY); // 设置贝塞尔曲线的控制点坐标和终点坐标 qPath.quadTo(qControlX, qCOntrolY, qEndX, qEndY); // 画出贝塞尔曲线 mCanvas.drawPath(qPath, qPaint); // 画点 mCanvas.drawPoint(mX, mY + 155, qPaint); // 画多个点,坐标数组每两个值代表一个点的坐标 mCanvas.drawPoints(new float[] {mX, mY + 160, mX + 5, mY + 160, mX + 5, mY + 160}, qPaint); // 画矩形 mCanvas.drawRect(mX, mY + 170, mX + 100, mY + 220, mPaint); // 设置矩形区域 RectF mRect = new RectF(mX, mY + 230, mX + 100, mY + 260); // 画圆角矩形,这个方法的第二第三个参数在后面有图讲解 mCanvas.drawRoundRect(mRect, 10, 10, mPaint); // 画文本 mCanvas.drawText("drawText", mX, mY + 290, mPaint); // 画文本,数组里每两个值代表文本的一个字符的坐标,数组的坐标可以比字符串里的字符多,但不可以少 mCanvas.drawPosText( "哈哈你好", new float[] {mX, mY + 310, mX + 20, mY + 310, mX + 40, mY + 310, mX + 60, mY + 310}, mPaint); // 重置Path tPath.reset(); // 添加一个圆形路径,坐标,半径,方向(顺时针还是逆时针) tPath.addCircle(mX + 10, mY + 340, 10, Path.Direction.CW); // 画出路径 mCanvas.drawPath(tPath, qPaint); // 把文本画在路径上,但不会画出路径 mCanvas.drawTextOnPath("draw", tPath, 30, 0, mPaint); }