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

import android.graphics.Paint;

public class Main {
    private static Paint paintBlack = new Paint();
    /**
     * Coordinates of the Star
        
          A
         / \
        /   \
     C-----B     J-----I
       \             /
     D         H
    /     F     \
       /   /     \   \
      E               G
        
     * */
    //coord_POINT [coordOut_X, coordOut_Y, coordIn_X, coordIn_Y]
    private static float[] coord_A = new float[4];
    private static float[] coord_B = new float[4];
    private static float[] coord_C = new float[4];
    private static float[] coord_D = new float[4];
    private static float[] coord_E = new float[4];
    private static float[] coord_F = new float[4];
    private static float[] coord_G = new float[4];
    private static float[] coord_H = new float[4];
    private static float[] coord_I = new float[4];
    private static float[] coord_J = new float[4];

    private static void drawLine(Canvas canvas, int coordX, int coordY) {
        //Draw the line
        canvas.drawLine(coord_A[coordX], coord_A[coordY], coord_B[coordX], coord_B[coordY], paintBlack); /*A-B*/
        canvas.drawLine(coord_B[coordX], coord_B[coordY], coord_C[coordX], coord_C[coordY], paintBlack); /*B-C*/
        canvas.drawLine(coord_C[coordX], coord_C[coordY], coord_D[coordX], coord_D[coordY], paintBlack); /*C-D*/
        canvas.drawLine(coord_D[coordX], coord_D[coordY], coord_E[coordX], coord_E[coordY], paintBlack); /*D-E*/
        canvas.drawLine(coord_E[coordX], coord_E[coordY], coord_F[coordX], coord_F[coordY], paintBlack); /*E-F*/
        canvas.drawLine(coord_F[coordX], coord_F[coordY], coord_G[coordX], coord_G[coordY], paintBlack); /*F-G*/
        canvas.drawLine(coord_G[coordX], coord_G[coordY], coord_H[coordX], coord_H[coordY], paintBlack); /*G-H*/
        canvas.drawLine(coord_H[coordX], coord_H[coordY], coord_I[coordX], coord_I[coordY], paintBlack); /*H-I*/
        canvas.drawLine(coord_I[coordX], coord_I[coordY], coord_J[coordX], coord_J[coordY], paintBlack); /*I-J*/
        canvas.drawLine(coord_J[coordX], coord_J[coordY], coord_A[coordX], coord_A[coordY], paintBlack); /*J-A*/
    }
}