//  ***************************************************************************
function functionCalculator (caller) {
  this.id = 'functionCalculator';
  this.caller = caller;
  this.x = [];
  this.y = [];
  var xAct = 0.0;
  var xInc = 0.0;

  //  ----------------------------------------------------------------------------
  this.calcPoint = function (xi, i) {
    alert("### err: Function not defined");
    return 0;
  };

  //  ----------------------------------------------------------------------------
  this.calc = function (min, max, n) {
    xInc = (parseFloat(max, 10) - parseFloat(min, 10)) / parseFloat(n, 10);
    var xi = parseFloat(min, 10);
    for (var i = 0; i < parseInt(n, 10); i++) {
      this.x[i] = xi;
      this.y[i] = this.calcPoint(xi, i);
      xi += xInc;
    }
    return this;
  };

  //  ----------------------------------------------------------------------------
  this.getX = function () {
    return this.x;
  };

  //  ----------------------------------------------------------------------------
  this.getY = function () {
    return this.y;
  };

  //  ----------------------------------------------------------------------------
  this.setX = function (x) {
    this.x = x;
    return this;
  };

  //  ----------------------------------------------------------------------------
  this.setY = function (y) {
    this.y = y;
    return this;
  };
  //  ----------------------------------------------------------------------------
  this.saveX = function () {
    this.savedX = this.x;
    return this;
  };

  //  ----------------------------------------------------------------------------
  this.saveY = function () {
    this.savedY = this.y;
    return this;
  };
}
