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

private static void initializeThumbnailSizes(DisplayMetrics metrics, Resources r) {
    int maxPixels = Math.max(metrics.heightPixels, metrics.widthPixels);
}

From source file:Main.java

private static String getBucketedTime(long paramLong) {
    if (paramLong < 1000L)
        return String.valueOf(100L * (paramLong / 100L)) + "ms";
    return String.valueOf(Math.max(500L * (paramLong / 500L) / 1000.0D, 1.0D) + "s");
}

From source file:Main.java

public static int getDarkColor(int color) {
    int darkColor = 0;

    int r = Math.max(Color.red(color) - 25, 0);
    int g = Math.max(Color.green(color) - 25, 0);
    int b = Math.max(Color.blue(color) - 25, 0);

    darkColor = Color.rgb(r, g, b);

    return darkColor;
}

From source file:Main.java

/**
 * If value &gt;= max returns max. If value &lt;= min returns min. Otherwise returns value.
 *//*  w  w  w.j a  v a2  s . c  o m*/
public static int clamp(int value, int min, int max) {
    return Math.max(Math.min(value, max), min);
}

From source file:Main.java

public static <T> List<T> takeLast(List<T> list, int length) {
    if (list.size() > length) {
        int fromIndex = Math.max(0, list.size() - length);
        int toIndex = list.size();
        List<T> newList = new ArrayList<T>();
        newList.addAll(list.subList(fromIndex, toIndex));
        return newList;
    }/*from   w  ww .j a v  a 2 s  . com*/
    return list;
}

From source file:Main.java

public static int getLargestDigitOccurrence(int[] table) {
    int max = 1;/*from  w ww.jav a2 s . c  o m*/
    for (int i = 0; i < table.length; i++) {
        max = Math.max(max, table[i]);
    }

    return max;
}

From source file:Main.java

public static int darker(int color, float amount) {
    float diff = 255 * amount;
    int r = (int) Math.max(0, (Color.red(color) - diff));
    int b = (int) Math.max(0, (Color.blue(color) - diff));
    int g = (int) Math.max(0, (Color.green(color) - diff));
    return Color.argb(Color.alpha(color), r, g, b);
}

From source file:Main.java

public static int scalePow2(int height, int width) {
    int scale = 1;
    int size = Math.max(height, width);
    if (size > IMAGE_MAX_SIZE) {
        scale = (int) Math.pow(2, (int) Math.round(Math.log(IMAGE_MAX_SIZE / (double) size) / Math.log(0.5)));
    }/* w w w  .j a  va 2s  . co m*/
    return scale;
}

From source file:Main.java

private static int computeImageSampleSize(Options options, int targetWidth, int targetHeight) {
    return Math.max(options.outWidth / targetWidth, options.outHeight / targetHeight);

}

From source file:Main.java

public static float fmax(final float... values) {
    float max = Float.MIN_VALUE;
    for (final float v : values) {
        max = Math.max(v, max);
    }//from  w w  w .j a  v a  2 s .  c  om
    return max;
}