Here you can find the source of clampInt(final int min, final int value, final int max)
Parameter | Description |
---|---|
min | The minimum bound. |
value | The value to clamp. |
max | The maximum bound. |
public static int clampInt(final int min, final int value, final int max)
//package com.java2s; //License from project: Creative Commons License public class Main { /**//from w w w . j av a 2 s . c o m * Clamps an integer within the bounds [min, max] by setting it the the closest bound if it not within the range. * * @param min * The minimum bound. * @param value * The value to clamp. * @param max * The maximum bound. * @return The clamped integer. */ public static int clampInt(final int min, final int value, final int max) { return Math.min(max, Math.max(min, value)); } }