private int adaptToStepSize ( final int number ) { if ( getStepSize ( ) > 0 ) { int offset = number - getMinNumber ( ) ; int mod = offset % getStepSize ( ) ; float halfStepSize = ( float ) getStepSize ( ) / 2.0f ; int result = ( ( mod > halfStepSize ) ? offset + getStepSize ( ) - mod : offset - mod ) + getMinNumber ( ) ; return Math . min ( result , getMaxNumber ( ) ) ; } return number ; }
Adapts a specific number to the step size which is currently set . The number will be decreased or increased to the numerically closest value which matches the step size .