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.RectF;

public class Main {
    private static void drawAntiRoundRect(Canvas canvas, Paint paint, int radius, RectF rect, int direction) {
        if (direction == 1) {
            Path path = new Path();
            path.moveTo(rect.left, rect.top);
            path.lineTo(rect.left, rect.top + radius);
            path.addArc(new RectF(rect.left, rect.top, rect.left + radius * 2, rect.top + radius * 2), 180, 90);
            path.lineTo(rect.left, rect.top);
            path.close();
            canvas.drawPath(path, paint);
        } else if (direction == 2) {
            Path path = new Path();
            path.moveTo(rect.right, rect.top);
            path.lineTo(rect.right - radius, rect.top);
            path.addArc(new RectF(rect.right - 2 * radius, rect.top, rect.right, rect.top + radius * 2), 270, 90);
            path.lineTo(rect.right, rect.top);
            path.close();
            canvas.drawPath(path, paint);
        } else if (direction == 3) {
            Path path = new Path();
            path.moveTo(rect.right, rect.bottom);
            path.lineTo(rect.right, rect.bottom - radius);
            path.addArc(new RectF(rect.right - 2 * radius, rect.bottom - 2 * radius, rect.right, rect.bottom), 0,
                    90);
            path.lineTo(rect.right, rect.bottom);
            path.close();
            canvas.drawPath(path, paint);
        } else if (direction == 4) {
            Path path = new Path();
            path.moveTo(rect.left, rect.bottom);
            path.lineTo(rect.left + radius, rect.bottom);
            path.addArc(new RectF(rect.left, rect.bottom - 2 * radius, rect.left + 2 * radius, rect.bottom), 90,
                    90);
            path.lineTo(rect.left, rect.bottom);
            path.close();
            canvas.drawPath(path, paint);
        }
    }
}