private int getPadForLabel ( int i ) { Dictionary dictionary = slider . getLabelTable ( ) ; int pad = 0 ; Object o = dictionary . get ( i ) ; if ( o != null ) { Component c = ( Component ) o ; int centerX = xPositionForValue ( i ) ; int cHalfWidth = c . getPreferredSize ( ) . width / 2 ; if ( centerX - cHalfWidth < insetCache . left ) { pad = Math . max ( pad , insetCache . left - ( centerX - cHalfWidth ) ) ; } if ( centerX + cHalfWidth > slider . getWidth ( ) - insetCache . right ) { pad = Math . max ( pad , ( centerX + cHalfWidth ) - ( slider . getWidth ( ) - insetCache . right ) ) ; } } return pad ; }
Calculates the pad for the label at the specified index .