Creates the Paint object for drawing the crop window border. - Android Graphics

Android examples for Graphics:Paint

Description

Creates the Paint object for drawing the crop window border.

Demo Code


//package com.java2s;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.TypedValue;

public class Main {
    private static final String SEMI_TRANSPARENT = "#00FFFF00";
    private static final float DEFAULT_LINE_THICKNESS_DP = 3;

    /**//from w ww  .j  a va  2s .c  om
     * Creates the Paint object for drawing the crop window border.
     * 
     * @param context the Context
     * @return new Paint object
     */
    public static Paint newBorderPaint(Context context) {

        // Set the line thickness for the crop window border.
        final float lineThicknessPx = TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, DEFAULT_LINE_THICKNESS_DP,
                context.getResources().getDisplayMetrics());

        final Paint borderPaint = new Paint();
        borderPaint.setColor(Color.parseColor(SEMI_TRANSPARENT));
        borderPaint.setStrokeWidth(lineThicknessPx);
        borderPaint.setStyle(Paint.Style.STROKE);

        return borderPaint;
    }
}

Related Tutorials