Search in sources :

Example 1 with BlurMaskFilter

use of android.graphics.BlurMaskFilter in project Launcher3 by chislon.

the class Utilities method initStatics.

private static void initStatics(Context context) {
    final Resources resources = context.getResources();
    final DisplayMetrics metrics = resources.getDisplayMetrics();
    final float density = metrics.density;
    sIconWidth = sIconHeight = (int) resources.getDimension(R.dimen.app_icon_size);
    sIconTextureWidth = sIconTextureHeight = sIconWidth;
    sBlurPaint.setMaskFilter(new BlurMaskFilter(5 * density, BlurMaskFilter.Blur.NORMAL));
    sGlowColorPressedPaint.setColor(0xffffc300);
    sGlowColorFocusedPaint.setColor(0xffff8e00);
    ColorMatrix cm = new ColorMatrix();
    cm.setSaturation(0.2f);
    sDisabledPaint.setColorFilter(new ColorMatrixColorFilter(cm));
    sDisabledPaint.setAlpha(0x88);
}
Also used : ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) ColorMatrix(android.graphics.ColorMatrix) BlurMaskFilter(android.graphics.BlurMaskFilter) Resources(android.content.res.Resources) DisplayMetrics(android.util.DisplayMetrics)

Example 2 with BlurMaskFilter

use of android.graphics.BlurMaskFilter in project Fairphone by Kwamecorp.

the class Utilities method initStatics.

private static void initStatics(Context context) {
    final Resources resources = context.getResources();
    final DisplayMetrics metrics = resources.getDisplayMetrics();
    final float density = metrics.density;
    sIconWidth = sIconHeight = (int) resources.getDimension(R.dimen.app_icon_size);
    sIconTextureWidth = sIconTextureHeight = sIconWidth;
    sBlurPaint.setMaskFilter(new BlurMaskFilter(5 * density, BlurMaskFilter.Blur.NORMAL));
    sGlowColorPressedPaint.setColor(0xffffc300);
    sGlowColorFocusedPaint.setColor(0xffff8e00);
    ColorMatrix cm = new ColorMatrix();
    cm.setSaturation(0.2f);
    sDisabledPaint.setColorFilter(new ColorMatrixColorFilter(cm));
    sDisabledPaint.setAlpha(0x88);
}
Also used : ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) ColorMatrix(android.graphics.ColorMatrix) BlurMaskFilter(android.graphics.BlurMaskFilter) Resources(android.content.res.Resources) DisplayMetrics(android.util.DisplayMetrics)

Example 3 with BlurMaskFilter

use of android.graphics.BlurMaskFilter in project c-geo by just-radovan.

the class cgOverlayScale method draw.

@Override
public void draw(Canvas canvas, MapViewImpl mapView, boolean shadow) {
    //super.draw(canvas, mapView, shadow);
    final double span = mapView.getLongitudeSpan() / 1e6;
    final GeoPointImpl center = mapView.getMapViewCenter();
    // pixels related to following latitude span
    pixels = mapView.getWidth() / 2;
    // pixels from bottom side of screen
    bottom = mapView.getHeight() - 14;
    distance = cgBase.getDistance((center.getLatitudeE6() / 1e6), ((center.getLongitudeE6() / 1e6) - (span / 2)), (center.getLatitudeE6() / 1e6), ((center.getLongitudeE6() / 1e6) + (span / 2)));
    distance = distance / 2;
    distanceRound = 0d;
    if (settings.units == cgSettings.unitsImperial) {
        distance *= cgBase.kmInMiles;
        if (distance > 100) {
            // 100+ mi > 1xx mi
            distanceRound = Math.floor(distance / 100) * 100;
            units = "mi";
        } else if (distance > 10) {
            // 10 - 100 mi > 1x mi
            distanceRound = Math.floor(distance / 10) * 10;
            units = "mi";
        } else if (distance > 1) {
            // 1 - 10 mi > 1.x mi
            distanceRound = Math.floor(distance);
            units = "mi";
        } else if (distance > 0.1) {
            // 0.1 mi - 1.0 mi > 1xx ft
            distance *= 5280;
            distanceRound = Math.floor(distance / 100) * 100;
            units = "ft";
        } else {
            // 1 - 100 ft > 1x ft
            distance *= 5280;
            distanceRound = Math.round(distance / 10) * 10;
            units = "ft";
        }
    } else {
        if (distance > 100) {
            // 100+ km > 1xx km
            distanceRound = Math.floor(distance / 100) * 100;
            units = "km";
        } else if (distance > 10) {
            // 10 - 100 km > 1x km
            distanceRound = Math.floor(distance / 10) * 10;
            units = "km";
        } else if (distance > 1) {
            // 1 - 10 km > 1.x km
            distanceRound = Math.floor(distance);
            units = "km";
        } else if (distance > 0.1) {
            // 100 m - 1 km > 1xx m
            distance *= 1000;
            distanceRound = Math.floor(distance / 100) * 100;
            units = "m";
        } else {
            // 1 - 100 m > 1x m
            distance *= 1000;
            distanceRound = Math.round(distance / 10) * 10;
            units = "m";
        }
    }
    pixels = Math.round((pixels / distance) * distanceRound);
    if (blur == null) {
        blur = new BlurMaskFilter(3, BlurMaskFilter.Blur.NORMAL);
    }
    if (scaleShadow == null) {
        scaleShadow = new Paint();
        scaleShadow.setAntiAlias(true);
        scaleShadow.setStrokeWidth(4 * pixelDensity);
        scaleShadow.setMaskFilter(blur);
        scaleShadow.setTextSize(14 * pixelDensity);
        scaleShadow.setTypeface(Typeface.DEFAULT_BOLD);
    }
    if (scale == null) {
        scale = new Paint();
        scale.setAntiAlias(true);
        scale.setStrokeWidth(2 * pixelDensity);
        scale.setTextSize(14 * pixelDensity);
        scale.setTypeface(Typeface.DEFAULT_BOLD);
    }
    if (mapView.isSatellite()) {
        scaleShadow.setColor(0xFF000000);
        scale.setColor(0xFFFFFFFF);
    } else {
        scaleShadow.setColor(0xFFFFFFFF);
        scale.setColor(0xFF000000);
    }
    canvas.drawLine(10, bottom, 10, (bottom - (8 * pixelDensity)), scaleShadow);
    canvas.drawLine((int) (pixels + 10), bottom, (int) (pixels + 10), (bottom - (8 * pixelDensity)), scaleShadow);
    canvas.drawLine(8, bottom, (int) (pixels + 12), bottom, scaleShadow);
    canvas.drawText(String.format("%.0f", distanceRound) + " " + units, (float) (pixels - (10 * pixelDensity)), (bottom - (10 * pixelDensity)), scaleShadow);
    canvas.drawLine(11, bottom, 11, (bottom - (6 * pixelDensity)), scale);
    canvas.drawLine((int) (pixels + 9), bottom, (int) (pixels + 9), (bottom - (6 * pixelDensity)), scale);
    canvas.drawLine(10, bottom, (int) (pixels + 10), bottom, scale);
    canvas.drawText(String.format("%.0f", distanceRound) + " " + units, (float) (pixels - (10 * pixelDensity)), (bottom - (10 * pixelDensity)), scale);
}
Also used : GeoPointImpl(carnero.cgeo.mapinterfaces.GeoPointImpl) BlurMaskFilter(android.graphics.BlurMaskFilter) Paint(android.graphics.Paint)

Example 4 with BlurMaskFilter

use of android.graphics.BlurMaskFilter in project Timber by naman14.

the class CircularSeekBar method initPaints.

/**
     * Initializes the {@code Paint} objects with the appropriate styles.
     */
private void initPaints() {
    mCirclePaint = new Paint();
    mCirclePaint.setAntiAlias(true);
    mCirclePaint.setDither(true);
    mCirclePaint.setColor(mCircleColor);
    mCirclePaint.setStrokeWidth(mCircleStrokeWidth);
    mCirclePaint.setStyle(Paint.Style.STROKE);
    mCirclePaint.setStrokeJoin(Paint.Join.ROUND);
    mCirclePaint.setStrokeCap(Paint.Cap.ROUND);
    mCircleFillPaint = new Paint();
    mCircleFillPaint.setAntiAlias(true);
    mCircleFillPaint.setDither(true);
    mCircleFillPaint.setColor(mCircleFillColor);
    mCircleFillPaint.setStyle(Paint.Style.FILL);
    mCircleProgressPaint = new Paint();
    mCircleProgressPaint.setAntiAlias(true);
    mCircleProgressPaint.setDither(true);
    mCircleProgressPaint.setColor(mCircleProgressColor);
    mCircleProgressPaint.setStrokeWidth(mCircleStrokeWidth);
    mCircleProgressPaint.setStyle(Paint.Style.STROKE);
    mCircleProgressPaint.setStrokeJoin(Paint.Join.ROUND);
    mCircleProgressPaint.setStrokeCap(Paint.Cap.ROUND);
    mCircleProgressGlowPaint = new Paint();
    mCircleProgressGlowPaint.set(mCircleProgressPaint);
    mCircleProgressGlowPaint.setMaskFilter(new BlurMaskFilter((5f * DPTOPX_SCALE), BlurMaskFilter.Blur.NORMAL));
    mPointerPaint = new Paint();
    mPointerPaint.setAntiAlias(true);
    mPointerPaint.setDither(true);
    mPointerPaint.setStyle(Paint.Style.FILL);
    mPointerPaint.setColor(mPointerColor);
    mPointerPaint.setStrokeWidth(mPointerRadius);
    mPointerHaloPaint = new Paint();
    mPointerHaloPaint.set(mPointerPaint);
    mPointerHaloPaint.setColor(mPointerHaloColor);
    mPointerHaloPaint.setAlpha(mPointerAlpha);
    mPointerHaloPaint.setStrokeWidth(mPointerRadius + mPointerHaloWidth);
    mPointerHaloBorderPaint = new Paint();
    mPointerHaloBorderPaint.set(mPointerPaint);
    mPointerHaloBorderPaint.setStrokeWidth(mPointerHaloBorderWidth);
    mPointerHaloBorderPaint.setStyle(Paint.Style.STROKE);
}
Also used : BlurMaskFilter(android.graphics.BlurMaskFilter) Paint(android.graphics.Paint)

Example 5 with BlurMaskFilter

use of android.graphics.BlurMaskFilter in project mobile-android by photo.

the class AdjustImageViewFreeRotation method initImageView.

/**
	 * Inits the image view.
	 */
private void initImageView() {
    mMatrix = new Matrix();
    mScaleType = ScaleType.FIT_CENTER;
    Context context = getContext();
    int highlight_color = context.getResources().getColor(R.color.feather_rotate_highlight_stroke_color);
    int highlight_stroke_internal_color = context.getResources().getColor(R.color.feather_rotate_highlight_grid_stroke_color);
    int highlight_stroke_internal_width = context.getResources().getInteger(R.integer.feather_rotate_highlight_grid_stroke_width);
    int highlight_outside_color = context.getResources().getColor(R.color.feather_rotate_highlight_outside);
    int highlight_stroke_width = context.getResources().getInteger(R.integer.feather_rotate_highlight_stroke_width);
    mOutlinePaint.setStrokeWidth(highlight_stroke_width);
    mOutlinePaint.setStyle(Paint.Style.STROKE);
    mOutlinePaint.setAntiAlias(true);
    mOutlinePaint.setColor(highlight_color);
    mOutlineFill.setStyle(Paint.Style.FILL);
    mOutlineFill.setAntiAlias(false);
    mOutlineFill.setColor(highlight_outside_color);
    mOutlineFill.setDither(false);
    try {
        ReflectionUtils.invokeMethod(mOutlineFill, "setHinting", new Class<?>[] { int.class }, 0);
    } catch (ReflectionException e) {
    }
    mLinesPaint.setStrokeWidth(highlight_stroke_internal_width);
    mLinesPaint.setAntiAlias(false);
    mLinesPaint.setDither(false);
    mLinesPaint.setStyle(Paint.Style.STROKE);
    mLinesPaint.setColor(highlight_stroke_internal_color);
    try {
        ReflectionUtils.invokeMethod(mLinesPaint, "setHinting", new Class<?>[] { int.class }, 0);
    } catch (ReflectionException e) {
    }
    mLinesPaintShadow.setStrokeWidth(highlight_stroke_internal_width);
    mLinesPaintShadow.setAntiAlias(true);
    mLinesPaintShadow.setColor(Color.BLACK);
    mLinesPaintShadow.setStyle(Paint.Style.STROKE);
    mLinesPaintShadow.setMaskFilter(new BlurMaskFilter(2, Blur.NORMAL));
    mOutlineFillAlpha = mOutlineFill.getAlpha();
    mOutlinePaintAlpha = mOutlinePaint.getAlpha();
    mLinesAlpha = mLinesPaint.getAlpha();
    mLinesShadowAlpha = mLinesPaintShadow.getAlpha();
    mOutlinePaint.setAlpha(0);
    mOutlineFill.setAlpha(0);
    mLinesPaint.setAlpha(0);
    mLinesPaintShadow.setAlpha(0);
    android.content.res.Resources resources = getContext().getResources();
    mResizeDrawable = resources.getDrawable(R.drawable.feather_highlight_crop_handle);
    double w = mResizeDrawable.getIntrinsicWidth();
    double h = mResizeDrawable.getIntrinsicHeight();
    handleWidth = (int) Math.ceil(w / 2.0);
    handleHeight = (int) Math.ceil(h / 2.0);
}
Also used : Context(android.content.Context) ReflectionException(com.aviary.android.feather.library.utils.ReflectionUtils.ReflectionException) Matrix(android.graphics.Matrix) BlurMaskFilter(android.graphics.BlurMaskFilter) Paint(android.graphics.Paint) Resources(android.content.res.Resources)

Aggregations

BlurMaskFilter (android.graphics.BlurMaskFilter)18 Paint (android.graphics.Paint)13 Resources (android.content.res.Resources)6 Bitmap (android.graphics.Bitmap)4 ColorMatrix (android.graphics.ColorMatrix)4 ColorMatrixColorFilter (android.graphics.ColorMatrixColorFilter)4 DisplayMetrics (android.util.DisplayMetrics)4 Canvas (android.graphics.Canvas)3 Matrix (android.graphics.Matrix)3 RectF (android.graphics.RectF)3 ReflectionException (com.aviary.android.feather.library.utils.ReflectionUtils.ReflectionException)3 Context (android.content.Context)2 SuppressLint (android.annotation.SuppressLint)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 ImageView (android.widget.ImageView)1 GeoPointImpl (carnero.cgeo.mapinterfaces.GeoPointImpl)1 AdapterView (com.aviary.android.feather.widget.AdapterView)1 OnItemsScrollListener (com.aviary.android.feather.widget.Gallery.OnItemsScrollListener)1 ImageViewTouchAndDraw (com.aviary.android.feather.widget.ImageViewTouchAndDraw)1