List of usage examples for java.lang Math max
@HotSpotIntrinsicCandidate public static double max(double a, double b)
From source file:Main.java
public static boolean sleep(long value, TimeUnit timeUnit) { try {/* ww w . j a v a2 s .c o m*/ Thread.sleep(Math.max(TimeUnit.MILLISECONDS.convert(value, timeUnit), 0)); } catch (InterruptedException e) { return false; } return true; }
From source file:Main.java
public static float limitValue(float a, float b) { float valve = 0; final float min = Math.min(a, b); final float max = Math.max(a, b); valve = valve > min ? valve : min; valve = valve < max ? valve : max; return valve; }
From source file:Main.java
/** * Get end value of the bounding rectangle of the given points. *//*from w w w . j a va 2 s. c o m*/ public static float getRectRight(float[] points) { return Math.max(Math.max(Math.max(points[0], points[2]), points[4]), points[6]); }
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
private static int getClosestResampleSize(int cx, int cy, int maxDim) { int max = Math.max(cx, cy); int resample = 1; for (resample = 1; resample < Integer.MAX_VALUE; resample++) { if (resample * maxDim > max) { resample--;/* w w w . j a v a 2 s. co m*/ break; } } if (resample > 0) { return resample; } return 1; }
From source file:Main.java
/** * Get bottom value of the bounding rectangle of the given points. *//*w w w. j a v a2 s .c om*/ public static float getRectBottom(float[] points) { return Math.max(Math.max(Math.max(points[1], points[3]), points[5]), points[7]); }
From source file:Main.java
public static List<Integer> range(int from, int to) { List<Integer> result = new ArrayList<Integer>(Math.max(from, to) - Math.min(from, to) + 1); if (to > from) { for (int i = from; i <= to; i++) result.add(i);// ww w. j a v a 2 s . c o m } else { for (int i = from; i >= to; i--) result.add(i); } return result; }
From source file:Main.java
public static int darker(int color, float factor) { return Color.argb(Color.alpha(color), Math.max((int) (Color.red(color) * factor), 0), Math.max((int) (Color.green(color) * factor), 0), Math.max((int) (Color.blue(color) * factor), 0)); }
From source file:Main.java
public static int lighten(int color, float amount) { float hsv[] = new float[3]; Color.colorToHSV(color, hsv); hsv[1] = Math.max(0f, Math.min(1f, hsv[1] - amount)); // saturation hsv[2] = Math.max(0f, Math.min(1f, hsv[2] + amount)); // brightness return Color.HSVToColor(hsv); }
From source file:Main.java
public static Bitmap scale(Bitmap bitmap, float scale) { if (bitmap == null) { return null; }// w w w. j a v a 2 s . c o m int width = Math.max(1, (int) (bitmap.getWidth() * scale)); int height = Math.max(1, (int) (bitmap.getHeight() * scale)); return Bitmap.createScaledBitmap(bitmap, width, height, false); }