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); }
private void generateTimeBitmap(WatchCurrentTime watchcurrenttime) { DisplayHelper.clearCanvas(mTimeBitmapCanvas); String s; String s1; if (DateFormat.is24HourFormat(getContext())) s = TimeHelper.getTwoDigitNumber((int) watchcurrenttime.get24Hour()); else if (watchcurrenttime.get12Hour() == 0.0F) s = TimeHelper.getTwoDigitNumber(12 + (int) watchcurrenttime.get12Hour()); else s = TimeHelper.getTwoDigitNumber((int) watchcurrenttime.get12Hour()); s1 = TimeHelper.getTwoDigitNumber((int) watchcurrenttime.getMinute()); mHourTextPaint.getTextBounds(s, 0, s.length(), mHourTextBounds); mMinuteTextPaint.getTextBounds(s1, 0, s1.length(), mMinuteTextBounds); mTimeBitmapCanvas.drawText( s, getCenterX() - mTimeTextSpacing - (float) (mHourTextBounds.width() / 2), getCenterY() + (float) (mHourTextBounds.height() / 2), mHourTextPaint); mTimeBitmapCanvas.drawText( s1, getCenterX() + mTimeTextSpacing + (float) (mMinuteTextBounds.width() / 2), getCenterY() + (float) (mMinuteTextBounds.height() / 2), mMinuteTextPaint); }
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); } } }
protected void onSizeChanged(int i, int j, int k, int l) { super.onSizeChanged(i, j, k, l); mMinuteRingRadius = DisplayHelper.getPixels(this, R.dimen.rings_minute_ring_radius); mSecondTickCircleRadius = DisplayHelper.getPixels(this, R.dimen.rings_second_tick_circle_radius); mHourRingRadius = DisplayHelper.getPixels(this, R.dimen.rings_hour_ring_radius); mInnerCircleRadius = DisplayHelper.getPixels(this, R.dimen.rings_inner_circle_radius); mOuterCircleWidth = DisplayHelper.getPixels(this, R.dimen.rings_outer_circle_width); mInnerCircleWidth = DisplayHelper.getPixels(this, R.dimen.rings_inner_circle_width); mSecondTickLength = DisplayHelper.getPixels(this, R.dimen.rings_second_tick_length); mCurrentSecondTickLength = DisplayHelper.getPixels(this, R.dimen.rings_current_second_tick_length); mCurrentSecondTickStrokeWidth = DisplayHelper.getPixels(this, R.dimen.rings_current_second_tick_stroke_width); mRingWidth = DisplayHelper.getPixels(this, R.dimen.rings_ring_width); mRingDotRadius = DisplayHelper.getPixels(this, R.dimen.rings_ring_dot_radius); mTimeTextSpacing = DisplayHelper.getPixels(this, R.dimen.rings_time_text_spacing); mTimeTextSize = DisplayHelper.getPixels(this, R.dimen.rings_time_text_size); init(); }