当前位置: 首页>>代码示例>>Java>>正文


Java Canvas.drawPoint方法代码示例

本文整理汇总了Java中android.graphics.Canvas.drawPoint方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.drawPoint方法的具体用法?Java Canvas.drawPoint怎么用?Java Canvas.drawPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Canvas的用法示例。


在下文中一共展示了Canvas.drawPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    mPath.reset();
    //贝塞尔曲线
    mPath.moveTo(mStartXPoint, mStartYPoint);
    mPath.cubicTo(mConOneXPoint, mConOneYPoint, mConTwoXPoint, mConTwoYPoint, mEndXPoint, mEndYPoint);
    canvas.drawPath(mPath, mPaint);

    //辅助线
    canvas.drawLine(mStartXPoint, mStartYPoint, mConOneXPoint, mConOneYPoint, mLinePaint);
    canvas.drawLine(mConOneXPoint, mConOneYPoint, mConTwoXPoint, mConTwoYPoint, mLinePaint);
    canvas.drawLine(mConTwoXPoint, mConTwoYPoint, mEndXPoint, mEndYPoint, mLinePaint);

    //文字
    canvas.drawPoint(mStartXPoint, mStartYPoint, mPaint);
    canvas.drawText("起始点", mStartXPoint, mStartYPoint + 30, mTextPaint);
    canvas.drawPoint(mEndXPoint, mEndYPoint, mPaint);
    canvas.drawText("结束点", mEndXPoint, mEndYPoint + 30, mTextPaint);
    canvas.drawPoint(mConOneXPoint, mConOneYPoint, mPaint);
    canvas.drawText("控制点1", mConOneXPoint, mConOneYPoint - 30, mTextPaint);
    canvas.drawPoint(mConTwoXPoint, mConTwoYPoint, mPaint);
    canvas.drawText("控制点2", mConTwoXPoint, mConTwoYPoint - 30, mTextPaint);


}
 
开发者ID:Lichenwei-Dev,项目名称:BezierView,代码行数:27,代码来源:BezierCubicView.java

示例2: drawPointsAndFill

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawPointsAndFill(Canvas canvas) {
    Path path = new Path();

    path.moveTo(mUnitPointFs[0].x * mOffsets[0] / 100 * mNetLength,
            mUnitPointFs[0].y * mOffsets[0] / 100 * mNetLength);

    for (int i = 0; i < mUnitPointFs.length; i++) {
        /* draw point */
        canvas.drawPoint(mUnitPointFs[i].x * mOffsets[i] / 100 * mNetLength,
                mUnitPointFs[i].y * mOffsets[i] / 100 * mNetLength,
                mPointPaint);
        /* draw line */
        if (i + 1 != mUnitPointFs.length) {
            path.lineTo(mUnitPointFs[i + 1].x * mOffsets[i + 1] / 100 * mNetLength,
                    mUnitPointFs[i + 1].y * mOffsets[i + 1] / 100 * mNetLength);
        } else {
           path.lineTo(mUnitPointFs[0].x * mOffsets[0] / 100 * mNetLength,
                   mUnitPointFs[0].y * mOffsets[0] / 100 * mNetLength);
        }

    }
    path.close();
    canvas.drawPath(path, mFillPaint);
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:25,代码来源:SpiderNetView.java

示例3: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    mPath.reset();
    mPath.moveTo(mStartPointX, mStartPointY);
    mPath.quadTo(mFlagPointX, mFlagPointY, mEndPointX, mEndPointY);


    canvas.drawPoint(mStartPointX, mStartPointY, mPaintFlag);
    canvas.drawText("起点", mStartPointX, mStartPointY, mPaintFlagText);

    canvas.drawPoint(mEndPointX, mEndPointY, mPaintFlag);
    canvas.drawText("终点", mEndPointX, mEndPointY, mPaintFlagText);

    canvas.drawPoint(mFlagPointX, mFlagPointY, mPaintFlag);
    canvas.drawText("控制点", mFlagPointX, mFlagPointY, mPaintFlagText);

    canvas.drawLine(mStartPointX, mStartPointY, mFlagPointX, mFlagPointY, mPaintFlag);
    canvas.drawLine(mEndPointX, mEndPointY, mFlagPointX, mFlagPointY, mPaintFlag);

    canvas.drawPath(mPath, mPaintBezier);
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:23,代码来源:SecondBezierView.java

示例4: debugDrawPoints

import android.graphics.Canvas; //导入方法依赖的package包/类
private void debugDrawPoints(final Canvas canvas, final int startIndex, final int endIndex,
        final Paint paint) {
    final int[] xCoords = mXCoordinates.getPrimitiveArray();
    final int[] yCoords = mYCoordinates.getPrimitiveArray();
    final int[] pointTypes = mPointTypes.getPrimitiveArray();
    // {@link Paint} that is zero width stroke and anti alias off draws exactly 1 pixel.
    paint.setAntiAlias(false);
    paint.setStrokeWidth(0);
    for (int i = startIndex; i < endIndex; i++) {
        final int pointType = pointTypes[i];
        if (pointType == POINT_TYPE_INTERPOLATED) {
            paint.setColor(Color.RED);
        } else if (pointType == POINT_TYPE_SAMPLED) {
            paint.setColor(0xFFA000FF);
        } else {
            paint.setColor(Color.GREEN);
        }
        canvas.drawPoint(getXCoordValue(xCoords[i]), yCoords[i], paint);
    }
    paint.setAntiAlias(true);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:22,代码来源:GestureTrailDrawingPoints.java

示例5: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.translate(((float) this.width) / 2.0f, ((float) this.height) / 2.0f);
    this.mBackgroundPaint.setColor(2113929215);
    canvas.drawArc(this.mRect, 120.0f, 300.0f, false, this.mBackgroundPaint);
    if (this.percent < -0.001f) {
        this.mBackgroundPaint.setColor(-94880);
        canvas.drawArc(this.mRect, 120.0f, 300.0f, false, this.mBackgroundPaint);
        return;
    }
    this.mBackgroundPaint.setColor(Color.GREEN);
    float sweep = Math.min(Math.max(this.percent * 300.0f, 1.0f), 300.0f);
    canvas.drawArc(this.mRect, 120.0f, sweep, false, this.mBackgroundPaint);
    double radians = Math.toRadians((double) (120.0f + sweep));
    canvas.drawPoint((float) (Math.cos(radians) * ((double) this.radius)), (float) (Math.sin
            (radians) * ((double) this.radius)), this.mCirclePaint);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:ArcProgressView.java

示例6: drawResultPoints

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * 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);
                }
            }
        }
    }
}
 
开发者ID:10045125,项目名称:QrCode,代码行数:33,代码来源:QrCodeView.java

示例7: drawDownLoading

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * Draw the Progress
 */
private void drawDownLoading(Canvas canvas, RectF arcBounds) {
    final float progress_degree = mProgress;
    publicPaint.setColor(getProgressColor());

    if (progress_degree <= 0) {
        canvas.drawPoint(mRealLeft + radius, mRealTop, publicPaint);
    } else {
        canvas.drawArc(arcBounds, START_ANGLE, (progress_degree) * TOTAL_ANGLE, false, publicPaint);
    }
    drawText(canvas, progress_degree);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:FreshDownloadView.java

示例8: drawLegendShape

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * 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 + SHAPE_WIDTH, y);
    break;
  case CIRCLE:
    drawCircle(canvas, paint, x + SHAPE_WIDTH, y);
    break;
  case TRIANGLE:
    drawTriangle(canvas, paint, new float[6], x + SHAPE_WIDTH, y);
    break;
  case SQUARE:
    drawSquare(canvas, paint, x + SHAPE_WIDTH, y);
    break;
  case DIAMOND:
    drawDiamond(canvas, paint, new float[8], x + SHAPE_WIDTH, y);
    break;
  case POINT:
    canvas.drawPoint(x + SHAPE_WIDTH, y, paint);
    break;
  }
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:39,代码来源:ScatterChart.java

示例9: drawResultPoints

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * 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(Color.parseColor("#c099cc00"));
        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);
                }
            }
        }
    }
}
 
开发者ID:yun2win,项目名称:tvConnect_android,代码行数:40,代码来源:CaptureActivity.java

示例10: drawDpPoint

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawDpPoint(Canvas canvas,Point point,Paint paint){
	int u = 3;
	//�����imageview��ԭ����ƽ��һ��(50,30)
	x=(point.x+50)*u;
	y=(point.y+30)*u;
	canvas.drawPoint(x*10,y*10,paint);
}
 
开发者ID:HyfUestc,项目名称:PDR,代码行数:8,代码来源:drawAstarPath.java

示例11: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    // 绘制数据点和控制点
    mPaint.setColor(Color.GRAY);
    mPaint.setStrokeWidth(10);
    canvas.drawPoint(mStart.x, mStart.y, mPaint);
    canvas.drawPoint(mEnd.x, mEnd.y, mPaint);
    canvas.drawPoint(mControl1.x, mControl1.y, mPaint);
    canvas.drawPoint(mControl2.x, mControl2.y, mPaint);

    // 绘制辅助线
    mPaint.setStrokeWidth(4);
    canvas.drawLine(mStart.x, mStart.y, mControl1.x, mControl1.y, mPaint);
    canvas.drawLine(mControl1.x, mControl1.y, mControl2.x, mControl2.y, mPaint);
    canvas.drawLine(mControl2.x, mControl2.y, mEnd.x, mEnd.y, mPaint);

    // 绘制贝塞尔曲线
    mPaint.setColor(Color.RED);
    mPaint.setStrokeWidth(8);

    Path path = new Path();
    path.moveTo(mStart.x, mStart.y);
    path.cubicTo(mControl1.x, mControl1.y, mControl2.x, mControl2.y, mEnd.x, mEnd.y);

    canvas.drawPath(path, mPaint);
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:29,代码来源:Bezier3View.java

示例12: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    mPath.reset();
    mPath.moveTo(mStartPointX, mStartPointY);
    mPath.cubicTo(mFlagPointOneX, mFlagPointOneY, mFlagPointTwoX, mFlagPointTwoY, mEndPointX, mEndPointY); // 没r的方法是绝对坐标,有r的是相对坐标


    canvas.drawPoint(mStartPointX, mStartPointY, mPaintFlag);
    canvas.drawText("起点", mStartPointX, mStartPointY, mPaintFlagText);

    canvas.drawPoint(mEndPointX, mEndPointY, mPaintFlag);
    canvas.drawText("终点", mEndPointX, mEndPointY, mPaintFlagText);

    canvas.drawPoint(mFlagPointOneX, mFlagPointOneY, mPaintFlag);
    canvas.drawText("控制点1", mFlagPointOneX, mFlagPointOneY, mPaintFlagText);

    canvas.drawPoint(mFlagPointOneX, mFlagPointOneY, mPaintFlag);
    canvas.drawText("控制点2", mFlagPointTwoX, mFlagPointTwoY, mPaintFlagText);

    canvas.drawLine(mFlagPointOneX, mFlagPointOneY, mFlagPointTwoX, mFlagPointTwoY, mPaintFlag);

    canvas.drawLine(mStartPointX, mStartPointY, mFlagPointOneX, mFlagPointOneY, mPaintFlag);
    canvas.drawLine(mEndPointX, mEndPointY, mFlagPointTwoX, mFlagPointTwoY, mPaintFlag);

    canvas.drawPath(mPath, mPaintBezier);
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:28,代码来源:ThirdBezierView.java

示例13: drawResultPoints

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * 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);
                }
            }
        }
    }
}
 
开发者ID:kkyflying,项目名称:CodeScaner,代码行数:34,代码来源:CaptureActivity.java

示例14: getBitmapWithResultPoints

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * @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;
}
 
开发者ID:yinhaojun,项目名称:ZxingForAndroid,代码行数:36,代码来源:BarcodeResult.java

示例15: drawDpPoint

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawDpPoint(Canvas canvas,Point point,Paint paint){
	//�����������ֻ��������������绪Ϊ��mate2Ϊ2,LG������nexus5Ϊ3�����Ժ�����С��λ�Ŀ��ܻ�������
	int u = 3;
	//�����imageview��ԭ����ƽ��һ��(50,30)
		x=(point.x+20)*u;
		y=(point.y+30)*u;
		canvas.drawPoint(x,y,paint);
}
 
开发者ID:HyfUestc,项目名称:PDR,代码行数:9,代码来源:MapView.java


注:本文中的android.graphics.Canvas.drawPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。