class RangeTimeScrollBar extends JBScrollBar {

  private void rangeChanged() {
    myUpdating = true;
    // We convert the given time ranges to milliseconds to prevent from integer overflow,
    // because JScrollBar API based on ints.
    int globalLengthMs = unitToMs(myGlobalRange.getLength());

    Range intersection = myGlobalRange.getIntersection(myViewRange);
    if (!intersection.isEmpty()) {
      int viewLengthMs = unitToMs(intersection.getLength());
      int viewRelativeMinMs = unitToMs(intersection.getMin() - myGlobalRange.getMin());
      setValues(viewRelativeMinMs, viewLengthMs, 0, globalLengthMs);
    } else {
      setValues(myViewRange.getMax() < myGlobalRange.getMin() ? 0 : globalLengthMs, 0, 0, globalLengthMs);
    }

    myUpdating = false;
  }

  public  RangeTimeScrollBar(@NotNull Range globalRange, @NotNull Range viewRange, @NotNull TimeUnit unit);

}