/**
   * Updates the scroll bar's value.
   *
   * @param component The scroll bar.
   * @param scrollType Unit or block scrolling.
   * @param scrollAmount The amount of scrolling.
   * @param wheelRotation <tt>-1</tt> or <tt>1</tt> for backward or forward scrolling, respectively.
   * @param x The x-coordinate of the event in the scroll bar's coordinate space.
   * @param y The y-coordinate of the event in the scroll bar's coordinate space.
   */
  @Override
  public boolean mouseWheel(
      Component component,
      Mouse.ScrollType scrollType,
      int scrollAmount,
      int wheelRotation,
      int x,
      int y) {
    boolean consumed = false;

    ScrollBar scrollBar = (ScrollBar) getComponent();

    int previousValue = scrollBar.getValue();
    int newValue = previousValue + (scrollAmount * wheelRotation * scrollBar.getUnitIncrement());

    if (wheelRotation > 0) {
      int maxValue = scrollBar.getEnd() - scrollBar.getExtent();
      newValue = Math.min(newValue, maxValue);

      if (previousValue < maxValue) {
        consumed = true;
      }
    } else {
      newValue = Math.max(newValue, 0);

      if (previousValue > 0) {
        consumed = true;
      }
    }

    scrollBar.setValue(newValue);

    return consumed;
  }
    private void scroll() {
      ScrollBar scrollBar = (ScrollBar) TerraScrollBarSkin.this.getComponent();

      int start = scrollBar.getStart();
      int end = scrollBar.getEnd();
      int extent = scrollBar.getExtent();
      int value = scrollBar.getValue();

      int adjustment;

      if (incrementType == Mouse.ScrollType.UNIT) {
        adjustment = direction * scrollBar.getUnitIncrement();
      } else {
        adjustment = direction * scrollBar.getBlockIncrement();
      }

      if (adjustment < 0) {
        int newValue = Math.max(value + adjustment, start);
        scrollBar.setValue(newValue);

        if (stopValue != -1 && newValue < stopValue) {
          // We've reached the explicit stop value
          stop();
        }

        if (newValue == start) {
          // We implicit stop at the minimum scroll bar value
          stop();
        }
      } else {
        int newValue = Math.min(value + adjustment, end - extent);
        scrollBar.setValue(newValue);

        if (stopValue != -1 && newValue > stopValue) {
          // We've reached the explicit stop value
          stop();
        }

        if (newValue == end - extent) {
          // We implicitly stop at the maximum scroll bar value
          stop();
        }
      }
    }