code: 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;
      }
docs: Calculates the pad for the label at the specified index.
  
  @param index
  index of the label to calculate pad for.
  @return padding required to keep label visible.