private void updateWatchHandStyle() { if (mAmbient) { mHourPaint.setColor(Color.WHITE); mMinutePaint.setColor(Color.WHITE); mSecondPaint.setColor(Color.WHITE); mTickAndCirclePaint.setColor(Color.WHITE); mHourPaint.setAntiAlias(false); mMinutePaint.setAntiAlias(false); mSecondPaint.setAntiAlias(false); mTickAndCirclePaint.setAntiAlias(false); mHourPaint.clearShadowLayer(); mMinutePaint.clearShadowLayer(); mSecondPaint.clearShadowLayer(); mTickAndCirclePaint.clearShadowLayer(); } else { mHourPaint.setColor(mWatchHandColor); mMinutePaint.setColor(mWatchHandColor); mSecondPaint.setColor(mWatchHandHighlightColor); mTickAndCirclePaint.setColor(mWatchHandColor); mHourPaint.setAntiAlias(true); mMinutePaint.setAntiAlias(true); mSecondPaint.setAntiAlias(true); mTickAndCirclePaint.setAntiAlias(true); mHourPaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor); mMinutePaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor); mSecondPaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor); mTickAndCirclePaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor); } }
public void setPointerShadowRadius(float pointerShadowRadius) { this.mPointerShadowRadius = pointerShadowRadius; if (mPointerShadowRadius == 0) { isHasPointerShadow = false; mPointerPaint.clearShadowLayer(); } else { mPointerPaint.setShadowLayer( pointerShadowRadius, mDefShadowOffset, mDefShadowOffset, Color.DKGRAY); setSoftwareLayer(); } invalidate(); }
public void setWheelShadow(float wheelShadow) { this.mWheelShadowRadius = wheelShadow; if (wheelShadow == 0) { isHasWheelShadow = false; mWheelPaint.clearShadowLayer(); mCacheCanvas = null; mCacheBitmap.recycle(); mCacheBitmap = null; } else { mWheelPaint.setShadowLayer( mWheelShadowRadius, mDefShadowOffset, mDefShadowOffset, Color.DKGRAY); setSoftwareLayer(); } invalidate(); }
private void drawPolylineShadow( Canvas canvas, RenderingContext rc, Path path, int shadowColor, int shadowRadius) { // blurred shadows if (rc.shadowRenderingMode == 2 && shadowRadius > 0) { // simply draw shadow? difference from option 3 ? // paint.setColor(shadowRadius); // paint.setColor(0xffffffff); paint.setShadowLayer(shadowRadius, 0, 0, shadowColor); canvas.drawPath(path, paint); } // option shadow = 3 with solid border if (rc.shadowRenderingMode == 3 && shadowRadius > 0) { paint.clearShadowLayer(); paint.setStrokeWidth(paint.getStrokeWidth() + shadowRadius * 2); ColorFilter cf = new PorterDuffColorFilter(shadowColor, Mode.SRC_IN); paint.setColorFilter(cf); // paint.setColor(0xffbababa); // paint.setColor(shadowColor); canvas.drawPath(path, paint); } }
private boolean updatePaint( RenderingRuleSearchRequest req, Paint p, int ind, boolean area, RenderingContext rc) { RenderingRuleProperty rColor; RenderingRuleProperty rStrokeW; RenderingRuleProperty rCap; RenderingRuleProperty rPathEff; if (ind == 0) { rColor = req.ALL.R_COLOR; rStrokeW = req.ALL.R_STROKE_WIDTH; rCap = req.ALL.R_CAP; rPathEff = req.ALL.R_PATH_EFFECT; } else if (ind == 1) { rColor = req.ALL.R_COLOR_2; rStrokeW = req.ALL.R_STROKE_WIDTH_2; rCap = req.ALL.R_CAP_2; rPathEff = req.ALL.R_PATH_EFFECT_2; } else if (ind == -1) { rColor = req.ALL.R_COLOR_0; rStrokeW = req.ALL.R_STROKE_WIDTH_0; rCap = req.ALL.R_CAP_0; rPathEff = req.ALL.R_PATH_EFFECT_0; } else if (ind == -2) { rColor = req.ALL.R_COLOR__1; rStrokeW = req.ALL.R_STROKE_WIDTH__1; rCap = req.ALL.R_CAP__1; rPathEff = req.ALL.R_PATH_EFFECT__1; } else { rColor = req.ALL.R_COLOR_3; rStrokeW = req.ALL.R_STROKE_WIDTH_3; rCap = req.ALL.R_CAP_3; rPathEff = req.ALL.R_PATH_EFFECT_3; } if (area) { if (!req.isSpecified(rColor) && !req.isSpecified(req.ALL.R_SHADER)) { return false; } p.setShader(null); p.setColorFilter(null); p.clearShadowLayer(); p.setStyle(Style.FILL_AND_STROKE); p.setStrokeWidth(0); } else { if (!req.isSpecified(rStrokeW)) { return false; } p.setShader(null); p.setColorFilter(null); p.clearShadowLayer(); p.setStyle(Style.STROKE); p.setStrokeWidth(req.getFloatPropertyValue(rStrokeW)); String cap = req.getStringPropertyValue(rCap); if (!Algoritms.isEmpty(cap)) { p.setStrokeCap(Cap.valueOf(cap.toUpperCase())); } else { p.setStrokeCap(Cap.BUTT); } String pathEffect = req.getStringPropertyValue(rPathEff); if (!Algoritms.isEmpty(pathEffect)) { p.setPathEffect(getDashEffect(pathEffect)); } else { p.setPathEffect(null); } } p.setColor(req.getIntPropertyValue(rColor)); if (ind == 0) { String resId = req.getStringPropertyValue(req.ALL.R_SHADER); if (resId != null) { p.setShader(getShader(resId)); } // do not check shadow color here if (rc.shadowRenderingMode == 1) { int shadowColor = req.getIntPropertyValue(req.ALL.R_SHADOW_COLOR); if (shadowColor == 0) { shadowColor = rc.shadowRenderingColor; } int shadowLayer = req.getIntPropertyValue(req.ALL.R_SHADOW_RADIUS); if (shadowColor == 0) { shadowLayer = 0; } p.setShadowLayer(shadowLayer, 0, 0, shadowColor); } } return true; }