Пример #1
0
 private void updateMinute(WatchCurrentTime watchcurrenttime) {
   DisplayHelper.clearCanvas(mMinuteRingBitmapCanvas);
   float f = watchcurrenttime.getMinuteDegreesContinuous();
   float f1 = (float) Math.toRadians(f);
   mRingPath.reset();
   mRingPath.arcTo(mMinuteRingRect, -90F, 90F + f);
   mMinuteRingBitmapCanvas.drawPath(mRingPath, mMinuteRingPaint);
   TrigHelper.getPointOnCircle(mMinuteDotPoint, mMinuteRingRadius, f1, getCenter());
   mMinuteRingBitmapCanvas.drawCircle(
       mMinuteDotPoint.x, mMinuteDotPoint.y, mRingDotRadius, mMinuteRingArrowPaint);
 }
Пример #2
0
 protected void onDraw(Canvas canvas) {
   WatchCurrentTime.getCurrent(mCurrentTime);
   canvas.drawBitmap(mBackgroundBitmap, 0.0F, 0.0F, null);
   canvas.drawBitmap(mMinuteRingBitmap, 0.0F, 0.0F, null);
   canvas.drawBitmap(mHourRingBitmap, 0.0F, 0.0F, null);
   canvas.drawBitmap(mTimeBitmap, 0.0F, 0.0F, null);
   if (!isAmbient()) {
     float f = (float) Math.toRadians(mCurrentTime.getSecondDegrees());
     TrigHelper.getPointOnCircle(
         mTickStartPoint,
         mSecondTickCircleRadius - mCurrentSecondTickLength / 2.0F,
         f,
         getCenter());
     TrigHelper.getPointOnCircle(
         mTickEndPoint, mSecondTickCircleRadius + mCurrentSecondTickLength / 2.0F, f, getCenter());
     canvas.drawLine(
         mTickStartPoint.x,
         mTickStartPoint.y,
         mTickEndPoint.x,
         mTickEndPoint.y,
         mCurrentSecondTickPaint);
   }
   super.onDraw(canvas);
 }
Пример #3
0
  private void generateBackgroundBitmap(WatchCurrentTime watchcurrenttime) {
    DisplayHelper.clearCanvas(mBackgroundBitmapCanvas);
    mBackgroundBitmapCanvas.drawRect(getFaceRect(), mFacePaint);
    WatchFace watchface = (WatchFace) getContext();
    if (!isAmbient()) {
      if (watchface.isRound()) {
        mFacePiePath.reset();
        mFacePiePath.moveTo(getCenterX(), getCenterY());
        mFacePiePath.lineTo(getCenterX(), 0.0F);
        mFacePiePath.arcTo(getFaceRect(), 270F, 90F);
        mFacePiePath.lineTo(getCenterX(), getCenterY());
        mBackgroundBitmapCanvas.drawPath(mFacePiePath, mFacePiePaint);
      } else {
        mFacePiePath.reset();
        mFacePiePath.moveTo(getCenterX(), getCenterY());
        mFacePiePath.lineTo(getCenterX(), 0.0F);
        mFacePiePath.lineTo(getFaceWidth(), 0.0F);
        mFacePiePath.lineTo(getFaceWidth(), getCenterY());
        mFacePiePath.lineTo(getCenterX(), getCenterY());
        mBackgroundBitmapCanvas.drawPath(mFacePiePath, mFacePiePaint);
      }
      if (watchface.isRound()) {
        mFacePiePath.reset();
        mFacePiePath.moveTo(getCenterX(), getCenterY());
        mFacePiePath.lineTo(getCenterX(), getFaceHeight());
        mFacePiePath.arcTo(getFaceRect(), 90F, 90F);
        mFacePiePath.lineTo(getCenterX(), getCenterY());
        mBackgroundBitmapCanvas.drawPath(mFacePiePath, mFacePiePaint);
      } else {
        mFacePiePath.reset();
        mFacePiePath.moveTo(getCenterX(), getCenterY());
        mFacePiePath.lineTo(getCenterX(), getFaceHeight());
        mFacePiePath.lineTo(0.0F, getFaceHeight());
        mFacePiePath.lineTo(0.0F, getCenterY());
        mFacePiePath.lineTo(getCenterX(), getCenterY());
        mBackgroundBitmapCanvas.drawPath(mFacePiePath, mFacePiePaint);
      }

      mCirclePaint.setStrokeWidth(mOuterCircleWidth);
      if (watchface.isRound())
        mBackgroundBitmapCanvas.drawCircle(
            getCenterX(), getCenterY(), getFaceRadius() - mOuterCircleWidth, mCirclePaint);
      else mBackgroundBitmapCanvas.drawRect(getFaceRect(), mCirclePaint);
      mCirclePaint.setStrokeWidth(mInnerCircleWidth);
      mBackgroundBitmapCanvas.drawCircle(
          getCenterX(), getCenterY(), mInnerCircleRadius, mFacePaint);
      float f;
      for (int i = 0; i < 60; i++) {
        f = (float) Math.toRadians(TimeHelper.getDegreesFromSecond(i));
        TrigHelper.getPointOnCircle(
            mTickStartPoint, mSecondTickCircleRadius - mSecondTickLength / 2.0F, f, getCenter());
        TrigHelper.getPointOnCircle(
            mTickEndPoint, mSecondTickCircleRadius + mSecondTickLength / 2.0F, f, getCenter());
        mBackgroundBitmapCanvas.drawLine(
            mTickStartPoint.x,
            mTickStartPoint.y,
            mTickEndPoint.x,
            mTickEndPoint.y,
            mSecondTickPaint);
      }
    }
  }