package net.sf.ij.vtk;

import ij.IJ;
import vtk.vtkProcessObject;

/**
 * Created by IntelliJ IDEA.
 * User: jarek
 * Date: Feb 5, 2003
 * Time: 10:13:00 PM
 * To change this template use Options | File Templates.
 * FIX: Use vtkObject.AddObserver for ProcessEvent instead of depreciated SetProgressMethod.
 * FIX: Javadoc comments
 */
public class VtkProgressObserver {
  vtkProcessObject processObject;

  public VtkProgressObserver(vtkProcessObject processObject) {
    this.processObject = processObject;
    // FIX: Enable  SetProgressMethod or equivalent
//    processObject.SetProgressMethod(this, "progressMethod");
  }

  public void progressMethod() {
    double progress = processObject.GetProgress();
    String processObjectName = processObject.GetClassName();
    IJ.showStatus(processObjectName + " " + (int) (progress * 100) + "%");
    IJ.showProgress(progress);
//    System.out.println("Process object  : "+processObjectName);
//    System.out.println("Progress        : "+progress);
//    System.out.println("ProgressMaxValue: "+processObject.GetProgressMaxValue());
//    System.out.println("ProgressMinValue: "+processObject.GetProgressMinValue());
//    System.out.println("ProgressText    : "+processObject.GetProgressText());
  }
}

/***
 * Image/J Plugins
 * Copyright (C) 2002-2004 Jarek Sacha
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Latest release available at http://sourceforge.net/projects/ij-plugins/
 */
package net.sf.ij.vtk;

import ij.IJ;
import vtk.vtkProcessObject;

/**
 * Can monitor progress event generated by a vtkProcessObject.
 */
public class VtkProgressObserver {
    vtkProcessObject processObject;

    public VtkProgressObserver(vtkProcessObject processObject) {
        this.processObject = processObject;
        processObject.AddObserver("ProgressEvent", this, "progressMethod");
    }

    public void progressMethod() {
        double progress = processObject.GetProgress();
        String processObjectName = processObject.GetClassName();
        IJ.showStatus(processObjectName + " " + (int) (progress * 100) + "%");
        IJ.showProgress(progress);
//    System.out.println("Process object  : "+processObjectName);
//    System.out.println("Progress        : "+progress);
//    System.out.println("ProgressMaxValue: "+processObject.GetProgressMaxValue());
//    System.out.println("ProgressMinValue: "+processObject.GetProgressMinValue());
//    System.out.println("ProgressText    : "+processObject.GetProgressText());
    }
}

Remove obsolete use of SetProgressMethod.