Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.graphics.Path;

public class Main {
    private static void arcQuadTo(Path pathForTurn, double angle, float radius, double angle2, float radius2,
            float proc, float cx, float cy) {
        float X = getProjX(angle, cx, cy, radius);
        float Y = getProjY(angle, cx, cy, radius);
        float X2 = getProjX(angle2, cx, cy, radius2);
        float Y2 = getProjY(angle2, cx, cy, radius2);
        pathForTurn.quadTo(X, Y, X2 * proc + X * (1 - proc), Y2 * proc + Y * (1 - proc));
    }

    private static void arcQuadTo(Path pathForTurn, double angle0, float radius0, double angle, float radius,
            double angle2, float radius2, float dl, float cx, float cy) {
        float X0 = getProjX(angle0, cx, cy, radius0);
        float Y0 = getProjY(angle0, cx, cy, radius0);
        float X = getProjX(angle, cx, cy, radius);
        float Y = getProjY(angle, cx, cy, radius);
        float X2 = getProjX(angle2, cx, cy, radius2);
        float Y2 = getProjY(angle2, cx, cy, radius2);
        float l2 = (float) Math.sqrt((X - X2) * (X - X2) + (Y - Y2) * (Y - Y2));
        float l0 = (float) Math.sqrt((X - X0) * (X - X0) + (Y - Y0) * (Y - Y0));
        float proc2 = (float) (dl / l2);
        float proc = (float) (dl / l0);
        pathForTurn.lineTo(X0 * proc + X * (1 - proc), Y0 * proc + Y * (1 - proc));
        pathForTurn.quadTo(X, Y, X2 * proc2 + X * (1 - proc2), Y2 * proc2 + Y * (1 - proc2));
    }

    private static float getProjX(double angle, float cx, float cy, double radius) {
        return getX(angle, radius) + cx;
    }

    private static float getProjY(double angle, float cx, float cy, double radius) {
        return getY(angle, radius) + cy;
    }

    private static float getX(double angle, double radius) {
        return (float) (Math.cos(angle + Math.PI / 2) * radius);
    }

    private static float getY(double angle, double radius) {
        return (float) (Math.sin(angle + Math.PI / 2) * radius);
    }
}