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); }
public RingsClockView(Context context, AttributeSet attributeset, int i) { super(context, attributeset, i); mCurrentTime = WatchCurrentTime.getCurrent(); mSecondTickStrokeWidth = 1.0F; mFaceColorAmbient = 0xff000000; mFaceColorInteractive = -1; mFacePieColorAmbient = Color.argb(255, 26, 26, 26); mFacePieColorInteractive = Color.argb(255, 248, 248, 248); mSecondTickColorAmbient = Color.argb(255, 102, 102, 102); mSecondTickColorInteractive = Color.argb(255, 179, 179, 179); mCurrentSecondTickColor = Color.argb(255, 0, 151, 94); mHourRingColorAmbient = -1; mHourRingColorInteractive = Color.argb(255, 0, 151, 94); mHourRingArrowColorAmbient = -1; mHourRingArrowColorInteractive = Color.argb(255, 0, 151, 94); mMinuteRingColorAmbient = Color.argb(255, 179, 179, 179); mMinuteRingColorInteractive = Color.argb(255, 102, 102, 102); mMinuteRingArrowColorAmbient = Color.argb(255, 179, 179, 179); mMinuteRingArrowColorInteractive = Color.argb(255, 102, 102, 102); mHourTextColorAmbient = -1; mHourTextColorInteractive = Color.argb(255, 0, 151, 94); mMinuteTextColorAmbient = Color.argb(255, 179, 179, 179); mMinuteTextColorInteractive = Color.argb(255, 102, 102, 102); mFacePaint = new WatchFaceFillPaint(); mFacePiePaint = new WatchFaceFillPaint(); mCirclePaint = new WatchFaceStrokePaint(); mSecondTickPaint = new WatchFaceStrokePaint(); mCurrentSecondTickPaint = new WatchFaceStrokePaint(); mHourRingPaint = new WatchFaceStrokePaint(); mHourRingArrowPaint = new WatchFaceFillPaint(); mMinuteRingPaint = new WatchFaceStrokePaint(); mMinuteRingArrowPaint = new WatchFaceFillPaint(); mHourTextPaint = new WatchFaceTextPaint("sans-serif", 0, android.graphics.Paint.Align.CENTER); mMinuteTextPaint = new WatchFaceTextPaint("sans-serif", 0, android.graphics.Paint.Align.CENTER); mFacePiePath = new Path(); mHourRingRect = new RectF(); mMinuteRingRect = new RectF(); mRingPath = new Path(); mHourTextBounds = new Rect(); mColonTextBounds = new Rect(); mMinuteTextBounds = new Rect(); mTickStartPoint = new PointF(); mTickEndPoint = new PointF(); mHourDotPoint = new PointF(); mMinuteDotPoint = new PointF(); mBackgroundBitmapCanvas = new Canvas(); mTimeBitmapCanvas = new Canvas(); mHourRingBitmapCanvas = new Canvas(); mMinuteRingBitmapCanvas = new Canvas(); init(); }
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); }
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); }