Beispiel #1
0
 void myDraw() {
   float width, height;
   width = getMeasuredWidth();
   height = getMeasuredHeight();
   canvas = holder.lockCanvas();
   canvas.drawColor(Color.GREEN);
   canvas.drawPath(path, paint);
   holder.unlockCanvasAndPost(canvas);
 }
Beispiel #2
0
  public void mDraw() {

    mCanvas = mHolder.lockCanvas(); // 获得画布对象,开始对画布画画

    mCanvas.drawColor(++i); // 设置画布颜色为黑色

    canvasMethod(mCanvas); // 调用自定义的方法,主要是在传进去的画布对象上画画

    mHolder.unlockCanvasAndPost(mCanvas); // 把画布显示在屏幕上
  }
Beispiel #3
0
  /**
   * 画整体chart图
   *
   * @param translatX chart图偏移量
   */
  public void refreshChart(int translatX) {
    synchronized (holder) {
      translationChart(translatX);

      if (holder != null) {
        Canvas canvas = holder.lockCanvas();
        if (canvas != null) {
          canvas.drawColor(backColor);
          drawGridLine(canvas);
          drawChartLine(canvas);
          drawLimitRect(canvas);
          drawAxesLine(canvas);
          drawYValueText(canvas);
          holder.unlockCanvasAndPost(canvas);
        }
      }
    }
  }
Beispiel #4
0
 @Override
 public void run() {
   while (running) {
     Canvas c = null;
     try {
       c = surfaceHolder.lockCanvas(null);
       synchronized (surfaceHolder) {
         if (!game.onEnterFrame(c)) {
           running = false;
           game.shutdown(true);
           view.shutdown();
         }
       }
     } finally {
       // do this in a finally so that if an exception is thrown
       // during the above, we don't leave the Surface in an
       // inconsistent state
       if (c != null) {
         surfaceHolder.unlockCanvasAndPost(c);
       }
     }
   }
 }