Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.graphics.Canvas;

import android.graphics.Paint;

import android.graphics.Path;
import android.graphics.Path.Direction;

import android.graphics.RectF;

public class Main {
    private static void drawRoundRect(Canvas canvas, RectF rect, Paint paint, int radius, boolean leftTop,
            boolean rightTop, boolean leftBottom, boolean rightBottom) {
        float roundRadius[] = new float[8];
        roundRadius[0] = leftTop ? 0 : radius;
        roundRadius[1] = leftTop ? 0 : radius;
        roundRadius[2] = rightTop ? 0 : radius;
        roundRadius[3] = rightTop ? 0 : radius;
        roundRadius[4] = rightBottom ? 0 : radius;
        roundRadius[5] = rightBottom ? 0 : radius;
        roundRadius[6] = leftBottom ? 0 : radius;
        roundRadius[7] = leftBottom ? 0 : radius;

        Path path = new Path();
        path.addRoundRect(rect, roundRadius, Direction.CCW);
        canvas.drawPath(path, paint);
    }
}