protected int getItem ( int pixel ) { if ( nitems < 2 ) return 0 ; int eff_width = b . width - 2 * arrow_size ; // effective width double fitem = ( ( double ) ( pixel - arrow_size ) * ( nitems - 1 ) ) / eff_width ; int item = ( int ) ( fitem + .5 ) ; item = Math . max ( Math . min ( item , nitems - 1 ) , 0 ) ; return item ; }
return item selected by this pixel position