Example usage for java.lang Math max

List of usage examples for java.lang Math max

Introduction

In this page you can find the example usage for java.lang Math max.

Prototype

@HotSpotIntrinsicCandidate
public static double max(double a, double b) 

Source Link

Document

Returns the greater of two double values.

Usage

From source file:Main.java

public static int lighterColor(int color, int lighter) {
    int r = Math.max(Math.min(Color.red(color) + lighter, 255), 0);
    int g = Math.max(Math.min(Color.green(color) + lighter, 255), 0);
    int b = Math.max(Math.min(Color.blue(color) + lighter, 255), 0);
    return Color.rgb(r, g, b);
}

From source file:Main.java

public static int borderColorForBackground(int color) {
    return Color.rgb(Math.max(0, Color.red(color) - 30), Math.max(0, Color.green(color) - 30),
            Math.max(0, Color.blue(color) - 30));
}

From source file:Main.java

public static final int bringToBounds(final int pMinValue, final int pMaxValue, final int pValue) {
    return Math.max(pMinValue, Math.min(pMaxValue, pValue));
}

From source file:Main.java

public static int checkSampleSize(int widCompare, int widthBitmap, int heightBitmap) {
    if (Math.max(widthBitmap, heightBitmap) > widCompare) {
        int inSampleSize = Math.max(widthBitmap, heightBitmap) / widCompare;

        if (Math.max(widthBitmap, heightBitmap) % widCompare != 0) {
            inSampleSize += 1;//  www  .ja v a  2 s.co m
        }

        return inSampleSize;
    }

    return 1;
}

From source file:Main.java

public static float calculateRadiusOffset(float strokeSize, float dotStrokeSize, float markerStrokeSize) {
    return Math.max(strokeSize, Math.max(dotStrokeSize, markerStrokeSize));
}

From source file:Main.java

public static int colsToInt(int r, int g, int b, int a) {
    return (Math.max(Math.min(a, 255), 0) << 24) + (Math.max(Math.min(r, 255), 0) << 16)
            + (Math.max(Math.min(g, 255), 0) << 8) + Math.max(Math.min(b, 255), 0);
}

From source file:Main.java

private static Rect getCollisionBounds(Rect rect1, Rect rect2) {
    int left = (int) Math.max(rect1.left, rect2.left);
    int top = (int) Math.max(rect1.top, rect2.top);
    int right = (int) Math.min(rect1.right, rect2.right);
    int bottom = (int) Math.min(rect1.bottom, rect2.bottom);
    return new Rect(left, top, right, bottom);
}

From source file:Main.java

static int randomNumber(int first, int second) {
    Random r = new Random();
    int bigger = Math.max(first, second);
    int smaller = Math.min(first, second);
    return r.nextInt(bigger - smaller + 1) + smaller;
}

From source file:Main.java

public static int max(Iterable<Integer> c) {
    int a = Integer.MIN_VALUE;
    for (Integer integer : c) {
        a = Math.max(a, integer);
    }/*from w w w.  jav a  2s  .co m*/
    return a;
}

From source file:Main.java

/**
 * [0, 255]//from ww w .  ja  va  2 s .c  o  m
 *
 * @param alpha
 * @return
 */
static public int validAlpha(int alpha) {
    int result = Math.max(0, Math.min(alpha, 255));
    return result;

}