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

public class Main {
    public static float round(final float value, final float share) {
        return (float) Math.floor(value * share) / share;
    }

    public static RectF round(final RectF rect, final float share) {
        rect.left = (float) Math.floor(rect.left * share) / share;
        rect.top = (float) Math.floor(rect.top * share) / share;
        rect.right = (float) Math.floor(rect.right * share) / share;
        rect.bottom = (float) Math.floor(rect.bottom * share) / share;
        return rect;
    }

    public static RectF round(final RectF rect) {
        rect.left = (float) Math.floor(rect.left);
        rect.top = (float) Math.floor(rect.top);
        rect.right = (float) Math.ceil(rect.right);
        rect.bottom = (float) Math.ceil(rect.bottom);
        return rect;
    }

    public static RectF floor(final RectF rect) {
        rect.left = (float) Math.floor(rect.left);
        rect.top = (float) Math.floor(rect.top);
        rect.right = (float) Math.floor(rect.right);
        rect.bottom = (float) Math.floor(rect.bottom);
        return rect;
    }

    public static RectF ceil(final RectF rect) {
        rect.left = (float) Math.ceil(rect.left);
        rect.top = (float) Math.ceil(rect.top);
        rect.right = (float) Math.ceil(rect.right);
        rect.bottom = (float) Math.ceil(rect.bottom);
        return rect;
    }
}