/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 1.3.31
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package hep.aida.swig;
 
import hep.aida.jni.AIDAJNIUtil;

public class IHistogram1D extends IHistogram implements hep.aida.IHistogram1D {
  private long swigCPtr;

  public IHistogram1D(long cPtr, boolean cMemoryOwn) {
    super(AIDAJNI.SWIGIHistogram1DUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  protected static long getCPtr(hep.aida.IHistogram1D obj) {
    if (obj instanceof IHistogram1D) {
      return (obj == null) ? 0 : ((IHistogram1D)obj).swigCPtr;
    } else {
      long cPtr = AIDAJNI.new_IHistogram1D();
      // FIXME, memory leak if Java class gets finalized, since C++ director is not freed.
      AIDAJNI.IHistogram1D_director_connect(obj, cPtr, true, true);
      return cPtr;
    }
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if(swigCPtr != 0 && swigCMemOwn) {
      swigCMemOwn = false;
      AIDAJNI.delete_IHistogram1D(swigCPtr);
    }
    swigCPtr = 0;
    super.delete();
  }

  protected void swigDirectorDisconnect() {
    swigCMemOwn = false;
    delete();
  }

  public void swigReleaseOwnership() {
    swigCMemOwn = false;
    AIDAJNI.IHistogram1D_change_ownership(this, swigCPtr, false);
  }

  public void swigTakeOwnership() {
    swigCMemOwn = true;
    AIDAJNI.IHistogram1D_change_ownership(this, swigCPtr, true);
  }

  public void fill(double x, double weight) {
    AIDAJNI.IHistogram1D_fill__SWIG_0(swigCPtr, this, x, weight);
  }

  public void fill(double x) {
    AIDAJNI.IHistogram1D_fill__SWIG_1(swigCPtr, this, x);
  }

  public double binMean(int index) {
    return AIDAJNI.IHistogram1D_binMean(swigCPtr, this, index);
  }

  public int binEntries(int index) {
    return AIDAJNI.IHistogram1D_binEntries(swigCPtr, this, index);
  }

  public double binHeight(int index) {
    return AIDAJNI.IHistogram1D_binHeight(swigCPtr, this, index);
  }

  public double binError(int index) {
    return AIDAJNI.IHistogram1D_binError(swigCPtr, this, index);
  }

  public double mean() {
    return AIDAJNI.IHistogram1D_mean(swigCPtr, this);
  }

  public double rms() {
    return AIDAJNI.IHistogram1D_rms(swigCPtr, this);
  }

  public hep.aida.IAxis axis() {
    return new IAxis(AIDAJNI.IHistogram1D_axis(swigCPtr, this), false);
  }

  public int coordToIndex(double coord) {
    return AIDAJNI.IHistogram1D_coordToIndex(swigCPtr, this, coord);
  }

  public void add(hep.aida.IHistogram1D hist) {
    AIDAJNI.IHistogram1D_add(swigCPtr, this, IHistogram1D.getCPtr(hist), (hep.aida.IHistogram1D)hist);
  }

  public IHistogram1D() {
    this(AIDAJNI.new_IHistogram1D(), true);
    AIDAJNI.IHistogram1D_director_connect(this, swigCPtr, swigCMemOwn, true);
  }

}
