LinearDataProvider = function(startValue, endValue, duration) {
  this.startValue = startValue;
  this.endValue = endValue;
  this.lastValue = startValue;
  this.duration = duration;
  this.startTime = null;
  this.endTime = null;
  
  this.changeProviderData = function(startValue, endValue, duration) {
    this.startValue = startValue * 1;
    this.endValue = endValue * 1;
    this.lastValue = startValue;
    this.duration = duration * 1;
    this.startTime = null;
    this.endTime = null;
    
    this.reset();
  }
  
  this.reset = function() {
    this.startTime = null;
    this.endTime = null;
    this.lastValue = this.startValue;
  }
  
  this.hasNext = function() {
    if (this.duration <= 0) {
      return false;
    }
    
    if (this.startTime == null) {
      return true;
    } else if (new Date().getTime() < this.endTime) {
      return true;
    } else if (this.remainingRange() > 0) {
      return true;
    }

    return false;
  }
  
  this.remainingRange = function() {
    return Math.abs(this.lastValue - this.endValue);
  }
  
  this.initDataProvider = function() {
    this.startTime = new Date().getTime();
    this.endTime = this.startTime + duration;
    this.lastValue = this.startValue;
  }
  
  this.getNext = function() {
    if (this.startTime == null) {
      this.initDataProvider();
      return this.lastValue;
    }
    
    var currentTime = new Date().getTime();
    var rate = (currentTime - this.startTime) / this.duration;
    if (rate > 1) {
      rate = 1;
    }

    this.lastValue = this.startValue + (this.endValue - this.startValue) * rate;
    //LinearDataProvider.logger.warn("getNext() return: " + this.lastValue );
    return this.lastValue;

  }
  //LinearDataProvider.logger = Logger.getLogger("LinearDataProvider");
}
