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