/** Updates the locations for both thumbs. */
  @Override
  protected void calculateThumbLocation() {
    // Call superclass method for lower thumb location.
    super.calculateThumbLocation();

    // Adjust upper value to snap to ticks if necessary.
    if (slider.getSnapToTicks()) {
      int upperValue = slider.getValue() + slider.getExtent();
      int snappedValue = upperValue;
      int majorTickSpacing = slider.getMajorTickSpacing();
      int minorTickSpacing = slider.getMinorTickSpacing();
      int tickSpacing = 0;

      if (minorTickSpacing > 0) {
        tickSpacing = minorTickSpacing;
      } else if (majorTickSpacing > 0) {
        tickSpacing = majorTickSpacing;
      }

      if (tickSpacing != 0) {
        // If it's not on a tick, change the value
        if ((upperValue - slider.getMinimum()) % tickSpacing != 0) {
          float temp = (float) (upperValue - slider.getMinimum()) / (float) tickSpacing;
          int whichTick = Math.round(temp);
          snappedValue = slider.getMinimum() + (whichTick * tickSpacing);
        }

        if (snappedValue != upperValue) {
          slider.setExtent(snappedValue - slider.getValue());
        }
      }
    }

    // Calculate upper thumb location.  The thumb is centered over its
    // value on the track.
    if (slider.getOrientation() == JSlider.HORIZONTAL) {
      int upperPosition = xPositionForValue(slider.getValue() + slider.getExtent());
      upperThumbRect.x = upperPosition - (upperThumbRect.width / 2);
      upperThumbRect.y = trackRect.y;

    } else {
      int upperPosition = yPositionForValue(slider.getValue() + slider.getExtent());
      upperThumbRect.x = trackRect.x;
      upperThumbRect.y = upperPosition - (upperThumbRect.height / 2);
    }
  }