예제 #1
0
 /**
  * Pinta la figura
  *
  * @param canvas
  */
 public void draw(Canvas canvas) {
   canvas.save();
   this.tr.applyTransformations(canvas);
   canvas.drawOval(rectElement, paint);
   canvas.drawOval(rectElement, paintBorder);
   canvas.restore();
 }
예제 #2
0
 private void drawFace(Canvas canvas) {
   canvas.drawOval(faceRect, facePaint);
   // draw the inner rim circle
   canvas.drawOval(faceRect, rimCirclePaint);
   // draw the rim shadow inside the face
   canvas.drawOval(faceRect, rimShadowPaint);
 }
  @Override
  public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    // Get the map projection to convert lat/long to screen coordinates
    Projection projection = mapView.getProjection();

    Point lPoint = new Point();
    projection.toPixels(locationPoint, lPoint);

    // Draw the overlay
    if (shadow == false) {
      if (friendLocations.size() > 0) {
        Iterator<String> e = friendLocations.keySet().iterator();
        do {
          // Get the name and location of each contact
          String name = e.next();
          Location location = friendLocations.get(name);

          // Convert the lat / long to a Geopoint
          Double latitude = location.getLatitude() * 1E6;
          Double longitude = location.getLongitude() * 1E6;
          GeoPoint geopoint = new GeoPoint(latitude.intValue(), longitude.intValue());

          // Ensure each contact is within 10km
          float dist = location.distanceTo(getLocation());
          if (dist < 10000) {
            Point point = new Point();
            projection.toPixels(geopoint, point);

            // Draw a line connecting the contact to your current location.
            canvas.drawLine(lPoint.x, lPoint.y, point.x, point.y, paint);

            // Draw a marker at the contact's location.
            RectF oval =
                new RectF(
                    point.x - markerRadius,
                    point.y - markerRadius,
                    point.x + markerRadius,
                    point.y + markerRadius);

            canvas.drawOval(oval, backPaint);
            oval.inset(2, 2);
            canvas.drawOval(oval, paint);

            // Draw the contact's name next to their position.
            float textWidth = paint.measureText(name);
            float textHeight = paint.getTextSize();
            RectF textRect =
                new RectF(
                    point.x + markerRadius,
                    point.y - textHeight,
                    point.x + markerRadius + 8 + textWidth,
                    point.y + 4);
            canvas.drawRoundRect(textRect, 3, 3, backPaint);
            canvas.drawText(name, point.x + markerRadius + 4, point.y, paint);
          }
        } while (e.hasNext());
      }
    }
    super.draw(canvas, mapView, shadow);
  }
예제 #4
0
  @Override
  public void draw(Canvas canvas) {
    if (mRebuildShader) {
      mBitmapShader = new BitmapShader(mBitmap, mTileModeX, mTileModeY);
      if (mTileModeX == Shader.TileMode.CLAMP && mTileModeY == Shader.TileMode.CLAMP) {
        mBitmapShader.setLocalMatrix(mShaderMatrix);
      }
      mBitmapPaint.setShader(mBitmapShader);
      mRebuildShader = false;
    }

    if (mOval) {
      if (mBorderWidth > 0) {
        canvas.drawOval(mDrawableRect, mBitmapPaint);
        canvas.drawOval(mBorderRect, mBorderPaint);
      } else {
        canvas.drawOval(mDrawableRect, mBitmapPaint);
      }
    } else {
      if (mBorderWidth > 0) {
        canvas.drawRoundRect(
            mDrawableRect, Math.max(mCornerRadius, 0), Math.max(mCornerRadius, 0), mBitmapPaint);
        canvas.drawRoundRect(mBorderRect, mCornerRadius, mCornerRadius, mBorderPaint);
      } else {
        canvas.drawRoundRect(mDrawableRect, mCornerRadius, mCornerRadius, mBitmapPaint);
      }
    }
  }
 private void drawFace(final Canvas canvas) {
   // Draw the face gradient
   canvas.drawOval(mFaceRect, mFacePaint);
   // Draw the face border
   canvas.drawOval(mFaceRect, mFaceBorderPaint);
   // Draw the inner face shadow
   canvas.drawOval(mFaceRect, mFaceShadowPaint);
 }
 /**
  * Place a small circle on the 2D palette to indicate the current values.
  *
  * @param canvas
  * @param markerPosX
  * @param markerPosY
  */
 private void mark2DPalette(Canvas canvas, int markerPosX, int markerPosY) {
   mPosMarker.setColor(Color.BLACK);
   canvas.drawOval(
       new RectF(markerPosX - 5, markerPosY - 5, markerPosX + 5, markerPosY + 5), mPosMarker);
   mPosMarker.setColor(Color.WHITE);
   canvas.drawOval(
       new RectF(markerPosX - 3, markerPosY - 3, markerPosX + 3, markerPosY + 3), mPosMarker);
 }
 /**
  * Frame the 2D palette to indicate that it has trackball focus.
  *
  * @param canvas
  */
 private void hilightFocusedOvalPalette(Canvas canvas) {
   mPosMarker.setColor(Color.WHITE);
   canvas.drawOval(
       new RectF(-PALETTE_RADIUS, -PALETTE_RADIUS, PALETTE_RADIUS, PALETTE_RADIUS), mPosMarker);
   mPosMarker.setColor(Color.BLACK);
   canvas.drawOval(
       new RectF(
           -PALETTE_RADIUS + 2, -PALETTE_RADIUS + 2, PALETTE_RADIUS - 2, PALETTE_RADIUS - 2),
       mPosMarker);
 }
예제 #8
0
  @Override
  protected void onDraw(Canvas canvas) {
    // All of our positions are using our internal coordinate system.
    // Instead of translating
    // them we let Canvas do the work for us.
    canvas.translate(mTranslationOffset, mTranslationOffset);

    // Draw the color wheel.
    canvas.drawOval(mColorWheelRectangle, mColorWheelPaint);

    float[] pointerPosition = calculatePointerPosition(mAngle);

    // Draw the pointer's "halo"
    canvas.drawCircle(
        pointerPosition[0], pointerPosition[1], mColorPointerHaloRadius, mPointerHaloPaint);

    // Draw the pointer (the currently selected color) slightly smaller on
    // top.
    canvas.drawCircle(pointerPosition[0], pointerPosition[1], mColorPointerRadius, mPointerColor);

    // Draw the halo of the center colors.
    canvas.drawCircle(0, 0, mColorCenterHaloRadius, mCenterHaloPaint);

    // Draw the old selected color in the center.
    canvas.drawArc(mCenterRectangle, 90, 180, true, mCenterOldPaint);

    // Draw the new selected color in the center.
    canvas.drawArc(mCenterRectangle, 270, 180, true, mCenterNewPaint);
  }
예제 #9
0
파일: Ovalo.java 프로젝트: Ardors/PabloJava
 @Override
 public void dibujar(Canvas c) {
   c.drawOval(
       new RectF(
           (getX() - ancho / 2), (getY() - alto / 2), (getX() + ancho / 2), (getY() + alto / 2)),
       getColor());
 }
예제 #10
0
  private void drawScale(Canvas canvas) {
    canvas.drawOval(scaleRect, scalePaint);

    canvas.rotate(210, 0.5f, 0.5f);

    canvas.save(Canvas.MATRIX_SAVE_FLAG);
    for (int i = 0; i < totalNicks; ++i) {
      float y1 = scaleRect.top;
      float y2 = y1 - 0.075f;

      double tempi = i;
      double tempNicks = totalNicks;

      Double green = (tempi / tempNicks) * 255;
      Double red = (1 - (tempi / tempNicks)) * 255;
      Integer igreen = (int) Math.round(green);
      Integer ired = (int) Math.round(red);

      scalePaint.setColor(Color.rgb(ired, igreen, 0));
      canvas.drawLine(0.5f, y1, 0.5f, y2, scalePaint);

      canvas.rotate(degreesPerNick, 0.5f, 0.5f);
    }
    canvas.restore();
  }
예제 #11
0
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    // Draw the shadow
    canvas.drawOval(mShadowBounds, mShadowPaint);

    // TODO 0 Slices
    String label = "";
    //        if(mData.size() > 0)
    label = mData.get(mCurrentItem).mLabel;
    //        else
    //        	label = NO_DATA_SLICE;

    // Draw the label text
    if (getShowText()) {
      canvas.drawText(label, mTextX, mTextY, mTextPaint);
    }

    // If the API level is less than 11, we can't rely on the view animation system to
    // do the scrolling animation. Need to tick it here and call postInvalidate() until the
    // scrolling is done.
    if (Build.VERSION.SDK_INT < 11) {
      tickScrollAnimation();
      if (!mScroller.isFinished()) {
        postInvalidate();
      }
    }
  }
예제 #12
0
  @Override
  protected void onDraw(Canvas canvas) {
    final int width = getWidth();
    final int height = getHeight();

    // make background blue
    canvas.drawColor(Color.BLUE);

    // draw body
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); // smooth out the edges
    paint.setColor(Color.YELLOW);
    paint.setStyle(Paint.Style.FILL);

    float radius = 0.3f * width; // body radius
    canvas.translate(width / 2.0f, height / 2.0f); // set origin to center of view
    canvas.drawCircle(0, 0, radius, paint);

    // draw eyes
    paint.setColor(Color.BLACK);
    radius = 0.025f * width; // eye radius
    canvas.drawCircle(0.2f * width, 0, radius, paint); // draw right eye
    canvas.drawCircle(-0.2f * width, 0, radius, paint); // draw left eye

    // draw wings
    paint.setColor(Color.YELLOW);
    radius = 0.055f * width; // wing radius
    canvas.drawCircle(0.28f * width, 0.08f * height, radius, paint); // draw right wing
    canvas.drawCircle(-0.28f * width, 0.08f * height, radius, paint); // draw left wing

    // draw beak
    paint.setColor(Color.rgb(255, 165, 0));
    RectF oval = new RectF(-0.18f * width, 0.02f * height, 0.18f * width, 0.07f * height);
    canvas.drawOval(oval, paint);
  }
예제 #13
0
 public void drawEllipse(Canvas c) {
   RectF rect = new RectF(getX(), getY(), getX() + 16, getY() + 16);
   Paint myPaint = new Paint();
   myPaint.setColor(Color.GREEN);
   myPaint.setStrokeWidth(1);
   c.drawOval(rect, myPaint);
 }
예제 #14
0
  @Override
  protected void onDraw(Canvas canvas) {
    int centerX = getRootView().getWidth() / 2 - (int) (mPaint.getStrokeWidth() / 2);
    float r = CENTER_X - mPaint.getStrokeWidth() * 0.5f;

    canvas.translate(centerX, CENTER_Y);

    canvas.drawOval(new RectF(-r, -r, r, r), mPaint);
    canvas.drawCircle(0, 0, CENTER_RADIUS, mCenterPaint);

    if (mTrackingCenter) {
      int c = mCenterPaint.getColor();
      mCenterPaint.setStyle(Paint.Style.STROKE);

      if (mHighlightCenter) {
        mCenterPaint.setAlpha(0xFF);
      } else {
        mCenterPaint.setAlpha(0x80);
      }
      canvas.drawCircle(0, 0, CENTER_RADIUS + mCenterPaint.getStrokeWidth(), mCenterPaint);

      mCenterPaint.setStyle(Paint.Style.FILL);
      mCenterPaint.setColor(c);
    }
  }
예제 #15
0
 /** Draws the widget on the given canvas. */
 @Override
 protected synchronized void onDraw(Canvas canvas) {
   super.onDraw(canvas);
   if (seekBarListener != null) {
     adCuePoints = seekBarListener.getAdsCuePoints();
   }
   if (adCuePoints != null) {
     if (adCuePoints.size() == 0) return;
     if (mTotal != 0) {
       int cuePointCount = 0;
       for (Float ad : adCuePoints) {
         if (!getIsRemotelyPlaying()) {
           pointToDraw = ((ad.intValue() * getWidth()) / mTotal);
           if (!(cuePointCount == adCuePoints.size() - 1)) {
             pointToDraw += convertDpToPx(15.666667f);
           }
           rect.set(
               pointToDraw,
               getTop() - convertDpToPx(.5f),
               pointToDraw + convertDpToPx(3.3333333f),
               getBottom() - convertDpToPx(22f));
           canvas.drawOval(rect, paint);
           cuePointCount++;
         }
       }
     }
   } else {
     return;
   }
 }
    @SuppressLint("DrawAllocation")
    @Override
    protected void onDraw(Canvas canvas) {
      // 移动中心
      canvas.translate(mWidth / 2 - 50, mHeight / 2);
      // 画中心圆
      canvas.drawCircle(0, 0, mCenterRadius, mCenterPaint);
      // 是否显示中心圆外的小圆环
      if (mHighlightCenter || mlittleLightCenter) {
        int c = mCenterPaint.getColor();
        mCenterPaint.setStyle(Paint.Style.STROKE);
        if (mHighlightCenter) {
          mCenterPaint.setAlpha(0xFF);
        } else if (mlittleLightCenter) {
          mCenterPaint.setAlpha(0x90);
        }
        canvas.drawCircle(0, 0, mCenterRadius + mCenterPaint.getStrokeWidth(), mCenterPaint);

        mCenterPaint.setStyle(Paint.Style.FILL);
        mCenterPaint.setColor(c);
      }
      // 画色环
      canvas.drawOval(
          new RectF(-mCircleRadius, -mCircleRadius, mCircleRadius, mCircleRadius), mCirclePaint);
      // 画黑白渐变块
      if (mDownInCircle) {
        mRectColors[1] = mCenterPaint.getColor();
      }
      mRectShader =
          new LinearGradient(
              0, mRectTop, 0, mRectBottom, mRectColors, null, Shader.TileMode.MIRROR);
      mRectPaint.setShader(mRectShader);
      canvas.drawRect(mRectLeft, mRectTop, mRectRight, mRectBottom, mRectPaint);
      float offset = mLinePaint.getStrokeWidth() / 2;
      canvas.drawLine(
          mRectLeft - offset,
          mRectTop - offset * 2,
          mRectLeft - offset,
          mRectBottom + offset * 2,
          mLinePaint); // 左
      canvas.drawLine(
          mRectLeft - offset * 2,
          mRectTop - offset,
          mRectRight + offset * 2,
          mRectTop - offset,
          mLinePaint); // 上
      canvas.drawLine(
          mRectRight + offset,
          mRectTop - offset * 2,
          mRectRight + offset,
          mRectBottom + offset * 2,
          mLinePaint); // 右
      canvas.drawLine(
          mRectLeft - offset * 2,
          mRectBottom + offset,
          mRectRight + offset * 2,
          mRectBottom + offset,
          mLinePaint); // 下
      super.onDraw(canvas);
    }
    @Override
    protected void onDraw(Canvas canvas) {
      float r = CENTER_X - mPaint.getStrokeWidth() * 0.5f;

      canvas.translate(CENTER_X, CENTER_X);
      int c = mCenterPaint.getColor();

      if (mRedrawHSV) {
        mHSVColors[1] = c;
        mHSVPaint.setShader(
            new LinearGradient(-100, 0, 100, 0, mHSVColors, null, Shader.TileMode.CLAMP));
      }

      canvas.drawOval(new RectF(-r, -r, r, r), mPaint);
      canvas.drawCircle(0, 0, CENTER_RADIUS, mCenterPaint);
      canvas.drawRect(new RectF(-100, 130, 100, 110), mHSVPaint);

      if (mTrackingCenter) {
        mCenterPaint.setStyle(Paint.Style.STROKE);

        if (mHighlightCenter) {
          mCenterPaint.setAlpha(0xFF);
        } else {
          mCenterPaint.setAlpha(0x80);
        }
        canvas.drawCircle(0, 0, CENTER_RADIUS + mCenterPaint.getStrokeWidth(), mCenterPaint);

        mCenterPaint.setStyle(Paint.Style.FILL);
        mCenterPaint.setColor(c);
      }

      mRedrawHSV = true;
    }
예제 #18
0
  public Bitmap createMask() {

    int i = getWidth();

    int j = getHeight();

    Bitmap.Config localConfig = Bitmap.Config.ARGB_8888;

    Bitmap localBitmap = Bitmap.createBitmap(i, j, localConfig);

    Canvas localCanvas = new Canvas(localBitmap);

    Paint localPaint = new Paint(1);

    localPaint.setColor(-16777216);

    float f1 = getWidth();

    float f2 = getHeight();

    RectF localRectF = new RectF(0.0F, 0.0F, f1, f2);

    localCanvas.drawOval(localRectF, localPaint);

    return localBitmap;
  }
  /**
   * Gets the cropped circle image based on the current crop selection.
   *
   * @return a new Circular Bitmap representing the cropped image
   */
  public Bitmap getCroppedOvalImage() {
    if (mBitmap != null) {
      Bitmap cropped = getCroppedImage();

      int width = cropped.getWidth();
      int height = cropped.getHeight();
      Bitmap output = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

      Canvas canvas = new Canvas(output);

      final int color = 0xff424242;
      final Paint paint = new Paint();

      paint.setAntiAlias(true);
      canvas.drawARGB(0, 0, 0, 0);
      paint.setColor(color);

      RectF rect = new RectF(0, 0, width, height);
      canvas.drawOval(rect, paint);
      paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
      canvas.drawBitmap(cropped, 0, 0, paint);

      return output;
    } else {
      return null;
    }
  }
예제 #20
0
  Bitmap drawEye() {
    Paint paint_eyebg = new Paint();
    paint_eyebg.setColor(Color.parseColor("#EDEDED"));

    Paint paint_eyerim = new Paint();
    paint_eyerim.setColor(Color.parseColor("#F2E16C"));

    Paint paint_eyeinside = new Paint();
    paint_eyeinside.setColor(Color.parseColor("#FFFFFF"));

    Paint paint_red = new Paint();
    paint_red.setColor(Color.parseColor("#FFE342"));

    Paint paint_black = new Paint();
    paint_black.setColor(Color.parseColor("#000000"));

    Bitmap bg = Bitmap.createBitmap(480, 800, Bitmap.Config.ARGB_8888);
    Canvas canvas_eye = new Canvas(bg);

    Bitmap bg_eyeinside =
        Bitmap.createBitmap(bg.getWidth(), bg.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas_bg_inside = new Canvas(bg_eyeinside);
    canvas_bg_inside.drawOval(new RectF(240, 200, 300, 280), paint_red);
    canvas_bg_inside.drawBitmap(bg_eyeinside, 0, 0, null);

    canvas_eye.drawCircle(230, 200, 60, paint_eyebg);
    canvas_eye.drawCircle(230, 200, 50, paint_eyebg);
    canvas_eye.drawBitmap(bg_eyeinside, -40, -40, null);
    canvas_eye.drawCircle(230, 200, 35, paint_eyeinside);
    canvas_eye.drawCircle(220, 200, 20, paint_black);
    canvas_eye.drawCircle(220, 200, 2, paint_eyebg);

    return bg;
  }
예제 #21
0
  @Override
  protected void onDraw(Canvas canvas) {
    // All of our positions are using our internal coordinate system.
    // Instead of translating
    // them we let Canvas do the work for us.
    canvas.translate(mTranslationOffset, mTranslationOffset);

    // Draw the color wheel.
    canvas.drawOval(mColorWheelRectangle, mColorWheelPaint);

    float[] pointerPosition = calculatePointerPosition(mAngle);

    // Draw the pointer's "halo"
    canvas.drawCircle(
        pointerPosition[0], pointerPosition[1], mColorPointerHaloRadius, mPointerHaloPaint);

    // Draw the pointer (the currently selected color) slightly smaller on
    // top.
    canvas.drawCircle(pointerPosition[0], pointerPosition[1], mColorPointerRadius, mPointerColor);

    // Draw the halo of the center colors.
    canvas.drawCircle(0, 0, mColorCenterHaloRadius, mCenterHaloPaint);

    if (mShowCenterOldColor) {
      // Draw the old selected color in the center.
      canvas.drawArc(mCenterRectangle, 90, 180, true, mCenterOldPaint);

      // Draw the new selected color in the center.
      canvas.drawArc(mCenterRectangle, 270, 180, true, mCenterNewPaint);
    } else {
      // Draw the new selected color in the center.
      canvas.drawArc(mCenterRectangle, 0, 360, true, mCenterNewPaint);
    }

    cusRectF.set(
        mCenterRectangle.left - 6,
        mCenterRectangle.top - 6,
        mCenterRectangle.right + 6,
        mCenterRectangle.bottom + 6);
    cusPaint.setColor(getColor());

    if (isDrawCusView) canvas.drawOval(cusRectF, cusPaint);
    else {
      cusPaint.setColor(getBackgroundColor());
      canvas.drawOval(cusRectF, cusPaint);
    }
  }
예제 #22
0
  private void drawCircle(Canvas canvas) {
    mPaint.setColor(Color.BLUE);

    canvas.drawCircle(200, 200, 100, mPaint);

    RectF rect = new RectF(100, 400, 300, 500);
    canvas.drawOval(rect, mPaint);
  }
예제 #23
0
 @Override
 public void onDraw(Canvas canvas) {
   canvas.drawColor(Color.BLACK);
   for (MyCircle p : _graphics) {
     canvas.drawOval(p.getBoundingBox(), mPaintf);
     canvas.drawOval(p.getBoundingBox(), mPaintb);
   }
 }
예제 #24
0
  private void fillCircle(
      Canvas canvas, float x, float y, float radius, int color, boolean transparent) {
    if (transparent) return;

    mFillPaint.setColor(color);
    mRect.set(x - radius, y - radius, x + radius, y + radius);
    canvas.drawOval(mRect, mFillPaint);
  }
예제 #25
0
    Bitmap createDst(int width, int height) {
      Bitmap bm = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
      Canvas c = new Canvas(bm);
      Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);

      p.setColor(0xFFFFCC44);
      c.drawOval(new RectF(0, 0, width * 3 / 4, height * 3 / 4), p);
      return bm;
    }
  public static Bitmap getBitmap(int width, int height) {
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(Color.BLACK);
    canvas.drawOval(new RectF(0.0f, 0.0f, width, height), paint);

    return bitmap;
  }
예제 #27
0
 @Override
 protected void onDraw(Canvas canvas) {
   super.onDraw(canvas);
   rectF.set(
       DEFAULT_STROKE_WIDTH / 2f,
       DEFAULT_STROKE_WIDTH / 2f,
       canvas.getWidth() - DEFAULT_STROKE_WIDTH / 2f,
       canvas.getHeight() - DEFAULT_STROKE_WIDTH / 2f);
   canvas.drawOval(rectF, paint);
 }
예제 #28
0
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    mInnerRectF.set(0, 0, canvas.getWidth(), canvas.getHeight());
    final int halfBorder = (int) (mStrokePaint.getStrokeWidth() / 2f + 0.5f);
    mInnerRectF.inset(halfBorder, halfBorder);

    canvas.drawArc(mInnerRectF, 0, 360, true, mBackgroundPaint);

    switch (mProgressFillType) {
      case FILL_TYPE_RADIAL:
        float sweepAngle = 360 * mProgress / mMax;
        canvas.drawArc(mInnerRectF, mStartAngle, sweepAngle, true, mProgressPaint);
        break;
      case FILL_TYPE_CENTER:
        float centerX = canvas.getWidth() / 2;
        float centerY = canvas.getHeight() / 2;
        float radius = (canvas.getWidth() / 2) * ((float) mProgress / mMax);
        canvas.drawCircle(
            centerX, centerY, radius + 0.5f - mStrokePaint.getStrokeWidth(), mProgressPaint);
        break;
      default:
        throw new IllegalArgumentException("Invalid Progress Fill = " + mProgressFillType);
    }

    if (!TextUtils.isEmpty(mText) && mShowText) {
      if (!TextUtils.isEmpty(mTypeface)) {
        Typeface typeface = sTypefaceCache.get(mTypeface);
        if (null == typeface && null != getResources()) {
          AssetManager assets = getResources().getAssets();
          if (null != assets) {
            typeface = Typeface.createFromAsset(assets, mTypeface);
            sTypefaceCache.put(mTypeface, typeface);
          }
        }
        mTextPaint.setTypeface(typeface);
      }
      int xPos = canvas.getWidth() / 2;
      int yPos =
          (int) ((canvas.getHeight() / 2) - ((mTextPaint.descent() + mTextPaint.ascent()) / 2));
      canvas.drawText(mText, xPos, yPos, mTextPaint);
    }

    if (null != mImage && mShowImage) {
      int drawableSize = mImage.getIntrinsicWidth();
      mImageRect.set(0, 0, drawableSize, drawableSize);
      mImageRect.offset((getWidth() - drawableSize) / 2, (getHeight() - drawableSize) / 2);
      mImage.setBounds(mImageRect);
      mImage.draw(canvas);
    }

    if (mShowStroke) {
      canvas.drawOval(mInnerRectF, mStrokePaint);
    }
  }
  @Override
  public void draw(Canvas canvas) {

    if (mOval) {
      if (mBorderWidth > 0) {
        canvas.drawOval(mDrawableRect, mBitmapPaint);
        canvas.drawOval(mBorderRect, mBorderPaint);
      } else {
        canvas.drawOval(mDrawableRect, mBitmapPaint);
      }
    } else {
      if (mBorderWidth > 0) {
        canvas.drawRoundRect(
            mDrawableRect, Math.max(mCornerRadius, 0), Math.max(mCornerRadius, 0), mBitmapPaint);
        canvas.drawRoundRect(mBorderRect, mCornerRadius, mCornerRadius, mBorderPaint);
      } else {
        canvas.drawRoundRect(mDrawableRect, mCornerRadius, mCornerRadius, mBitmapPaint);
      }
    }
  }
예제 #30
0
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    // 지우개 포인터를 그린다.
    Paint paint = new Paint();
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(3);

    float r = (float) Math.max(eraserThickness / 2 - 18, 1);
    canvas.drawOval(new RectF(eraserX - r, eraserY - r, eraserX + r, eraserY + r), paint);
  }