Creates the Paint object for drawing the corners of the border - Android Graphics

Android examples for Graphics:Paint

Description

Creates the Paint object for drawing the corners of the 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 int DEFAULT_CORNER_COLOR = Color.YELLOW;
    private static final float DEFAULT_CORNER_THICKNESS_DP = 5;

    /**/*  www.  j a va  2 s  .c o  m*/
     * Creates the Paint object for drawing the corners of the border
     * 
     * @param context the Context
     * @return the new Paint object
     */
    public static Paint newCornerPaint(Context context) {

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

        final Paint cornerPaint = new Paint();
        cornerPaint.setColor(DEFAULT_CORNER_COLOR);
        cornerPaint.setStrokeWidth(lineThicknessPx);
        cornerPaint.setStyle(Paint.Style.STROKE);

        return cornerPaint;
    }
}

Related Tutorials