Example usage for android.graphics Paint setStrokeWidth

List of usage examples for android.graphics Paint setStrokeWidth

Introduction

In this page you can find the example usage for android.graphics Paint setStrokeWidth.

Prototype

public void setStrokeWidth(float width) 

Source Link

Document

Set the width for stroking.

Usage

From source file:Main.java

public static Bitmap setupFrame(Bitmap bitmap, int width, int color) {
    if (bitmap.getWidth() <= width * 2 || bitmap.getHeight() <= width * 2) {
        return bitmap;
    }/*  w w w  .  ja  va2  s.c  o m*/

    Bitmap bp = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);

    Canvas canvas = new Canvas(bp);
    canvas.drawBitmap(bitmap, 0, 0, new Paint());
    Paint paint = new Paint();
    paint.setColor(color);
    paint.setStrokeWidth(width);
    paint.setStyle(Style.STROKE);
    canvas.drawRect(0, 0, canvas.getWidth() - width, canvas.getHeight() - width, paint);

    bitmap.recycle();
    return bp;
}

From source file:Main.java

/**
 * Creates the Paint object for drawing the crop window guidelines.
 * // w w w  .  j a va  2s. c o m
 * @return the new Paint object
 */
public static Paint newRotateBottomImagePaint() {

    final Paint paint = new Paint();
    paint.setColor(Color.WHITE);
    paint.setStrokeWidth(3);

    return paint;
}

From source file:Main.java

static void mutatePaint(Paint paint, int color, float strokeWidth, Paint.Style style) {
    paint.setColor(color);/*from w w w.  java 2 s  .c om*/
    paint.setStrokeWidth(strokeWidth);
    paint.setStyle(style);
}

From source file:Main.java

public static void drawKnots(Canvas canvas, List<PointF> knots, int color) {
    Log.d("GammaGraph", "function drawKnots");
    Paint paint = new Paint();
    paint.setAntiAlias(true);/*from ww w  .  ja v a  2 s  .c  o  m*/
    paint.setColor(color);
    paint.setStrokeWidth(7);
    for (PointF knot : knots) {
        canvas.drawPoint(knot.x, knot.y, paint);
    }
}

From source file:Main.java

public static void drawCropRect(Canvas canvas, RectF bounds) {
    Paint p = new Paint();
    p.setStyle(Paint.Style.STROKE);
    p.setColor(Color.WHITE);/*from  w  w w . j  a v  a  2  s. com*/
    p.setStrokeWidth(3);
    canvas.drawRect(bounds, p);
}

From source file:Main.java

/**
 * Creates the Paint object for drawing the crop window guidelines.
 * //  w w  w.  j a v  a 2  s . co  m
 * @return the new Paint object
 */
public static Paint newGuidelinePaint() {

    final Paint paint = new Paint();
    paint.setColor(Color.parseColor(SEMI_TRANSPARENT));
    paint.setStrokeWidth(DEFAULT_GUIDELINE_THICKNESS_PX);

    return paint;
}

From source file:Main.java

/**
 * Creates the Paint object for drawing the corners of the border
 * //  w  w w.j  ava  2 s  . c om
 * @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;
}

From source file:Main.java

/**
 * Creates the Paint object for drawing the crop window border.
 * //from  w ww . j  av a2  s.com
 * @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;
}

From source file:Main.java

public static Paint getUIPainter() {
    Paint uiPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    uiPaint.setColor(Color.argb(128, 255, 255, 255));
    uiPaint.setStyle(Style.STROKE);
    uiPaint.setStrokeWidth((float) 3.0);
    return uiPaint;
}

From source file:Main.java

public static void drawRuleOfThird(Canvas canvas, RectF bounds) {
    Paint p = new Paint();
    p.setStyle(Paint.Style.STROKE);
    p.setColor(Color.argb(128, 255, 255, 255));
    p.setStrokeWidth(2);
    float stepX = bounds.width() / 3.0f;
    float stepY = bounds.height() / 3.0f;
    float x = bounds.left + stepX;
    float y = bounds.top + stepY;
    for (int i = 0; i < 2; i++) {
        canvas.drawLine(x, bounds.top, x, bounds.bottom, p);
        x += stepX;//from w  w w .jav a  2  s  . c o  m
    }
    for (int j = 0; j < 2; j++) {
        canvas.drawLine(bounds.left, y, bounds.right, y, p);
        y += stepY;
    }
}