public void adjustmentValueChanged(AdjustmentEvent e) {
    if (updating) return;
    updating = true;
    double start, end;
    if (orientation == VERTICAL) {
      end = displayMax - (getValue() / ratio);
      start = end - viewLength;
    } else {
      start = getValue() / ratio + displayMin;
      end = start + viewLength;
    }

    if (end > start) {
      ValueAxis va = getValueAxis();
      if (va instanceof DateAxis) {
        Timeline tl = ((DateAxis) va).getTimeline();
        start = tl.toMillisecond((long) start);
        end = tl.toMillisecond((long) end);
        // System.out.println("********** converting start=" + new java.util.Date((long)start) + "
        // end=" + new java.util.Date((long)end) + " **********");
      }
      getValueAxis().setRange(start, end);
    }
    updating = false;
  }
  public void axisUpdate() {
    ValueAxis va = getValueAxis();
    if (va.isAutoRange()) {
      if (oldColor == null) oldColor = getBackground();
      setBackground(oldColor.brighter());
    } else if (oldColor != null) {
      setBackground(oldColor);
      oldColor = null;
    }
    if (updating) return;
    updating = true;
    displayMin = 0;
    displayMax = 0;
    viewLength = 0;
    double viewMin = 0;
    double viewMax = 0;
    ratio = 1;
    Range dataRange = getDataRange();
    if (dataRange != null) {
      displayMin = getDisplayMinimum();
      displayMax = getDisplayMaximum();
      viewMin = getViewMinimum();
      viewMax = getViewMaximum();
      // ValueAxis va = getValueAxis();
      if (va instanceof DateAxis) {
        Timeline tl = ((DateAxis) va).getTimeline();
        displayMin = tl.toTimelineValue((long) displayMin);
        displayMax = tl.toTimelineValue((long) displayMax);
        viewMin = tl.toTimelineValue((long) viewMin);
        viewMax = tl.toTimelineValue((long) viewMax);
      }
      viewLength = viewMax - viewMin;
      ratio = STEPS / (displayMax - displayMin);
    }

    int newMin = 0;
    int newMax = STEPS;
    int newExtent = (int) (viewLength * ratio);
    int newValue;
    if (orientation == VERTICAL) newValue = (int) ((displayMax - viewMax) * ratio);
    else newValue = (int) ((viewMin - displayMin) * ratio);
    // System.out.println("ChartScrollBar.axisUpdate(): newValue: " + newValue + " newExtent: " +
    // newExtent + " newMin: " + newMin + " newMax: " + newMax);
    setValues(newValue, newExtent, newMin, newMax);
    updating = false;
  }