Example usage for java.lang Math min

List of usage examples for java.lang Math min

Introduction

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

Prototype

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

Source Link

Document

Returns the smaller of two double values.

Usage

From source file:Main.java

public static float getFloat(float value, float minValue, float maxValue) {
    return Math.min(maxValue, Math.max(minValue, value));
}

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 Bitmap scaleDown(Bitmap bmp, float maxImgSize, boolean filter) {
    float ratio = Math.min((float) maxImgSize / bmp.getWidth(), (float) maxImgSize / bmp.getHeight());
    int width = Math.round((float) ratio * bmp.getWidth());
    int height = Math.round((float) ratio * bmp.getHeight());

    return Bitmap.createScaledBitmap(bmp, width, height, filter);
}

From source file:Main.java

/**
 * Get top value of the bounding rectangle of the given points.
 *///from   w  ww  .j  av a 2  s  .co m
public static float getRectTop(float[] points) {
    return Math.min(Math.min(Math.min(points[1], points[3]), points[5]), points[7]);
}

From source file:Main.java

public static Rectangle getRectangle(Point p1, Point p2) {
    return new Rectangle(Math.min(p1.x, p2.x), Math.min(p1.y, p2.y), Math.abs(p1.x - p2.x),
            Math.abs(p1.y - p2.y));
}

From source file:Main.java

/**
 * Get start value of the bounding rectangle of the given points.
 *///from   w  w w. ja v a  2s .c om
public static float getRectLeft(float[] points) {
    return Math.min(Math.min(Math.min(points[0], points[2]), points[4]), points[6]);
}

From source file:Main.java

public static String getDifficultyName(int val) {
    val = Math.min(val / 5, difficultyStrings.length - 1);
    val = Math.max(val, 0);
    return difficultyStrings[val];
}

From source file:Main.java

/**
 * [0, 255]//ww w  . j a  v a2s.  c  om
 *
 * @param alpha
 * @return
 */
static public int validAlpha(int alpha) {
    int result = Math.max(0, Math.min(alpha, 255));
    return result;

}

From source file:Main.java

private static Bitmap getSquareBitmap(Bitmap srcBitmap) {
    int size = Math.min(srcBitmap.getWidth(), srcBitmap.getHeight());
    int paddingX = (srcBitmap.getWidth() - size) / 2;
    int paddingY = (srcBitmap.getHeight() - size) / 2;

    return Bitmap.createBitmap(srcBitmap, paddingX, paddingY, size, size);
}

From source file:Main.java

public static String convertStackTraceToString(StackTraceElement[] stackTraceElements) {
    StringBuilder message = new StringBuilder();
    int min = Math.min(stackTraceElements.length, 4);
    for (int i = 2; i < min; i++) {
        StackTraceElement element = stackTraceElements[i];
        message.append(element.getClassName()).append(": ").append(element.getMethodName()).append("\n");
    }/*www .j a  va 2s .  c  o m*/
    return message.toString();
}