   /**
    * Called to set the value of a parameter.
    * The index passed in is the index of the function in the getParameterNames()
    * method.
    */
   public void setParameter(int index, double value)
   {
      if      (index == 0) offset = value;
      else if (index == 1) amplitude = value;
      else if (index == 2) period = value;
      else throw new IllegalArgumentException("index="+index);
      
      clearFit(); // Invalidate any fits using this function
      setChanged(); // Tell the GUIO the function has changed (so it can be redrawn)
   }
   // Methods for Fittable1DFunction
   /**
    * Caculate the value of the function at X, if the parameters were set to p.
    * This function should NOT modify the actual values of the parameters
    */
   public double valueAt(double x, double[] p)
   {
      return p[1]*Math.sin(2*Math.PI*(x-p[0])/p[2]);
   }
   /**
    * Called at the end of a fit, set the parameters to the given values.
    */
   public void setFit(Fitter fit, double[] p)
   {
      offset = p[0];
      amplitude = p[1];
      period = p[2];

      setFit(fit); // Mark the function as being associated with the fit
      setChanged(); // Tell the GUI the function has changed (so it can be redrawn)
   }
