001 /* 002 * ProgressListener 003 * 004 * Copyright (c) 2000, 2001, 2002, 2003 Marco Schmidt. 005 * All rights reserved. 006 */ 007 008 package net.sourceforge.jiu.ops; 009 010 /** 011 * This interface must be implemented by classes that want to be notified 012 * about progress of an image operation. 013 * 014 * @author Marco Schmidt 015 */ 016 public interface ProgressListener 017 { 018 /** 019 * Set the progress level to a new value, which must be between 0.0f and 1.0f 020 * (including both of these values). 021 * You should not call this method with a value lower than any value you've set 022 * before. 023 * However, this is not checked. 024 * @param progress the degree of progress as a value between 0.0f and 1.0f 025 * @throws IllegalArgumentException if the float argument is not in the mentioned interval 026 */ 027 void setProgress(float progress); 028 029 /** 030 * Sets a new progress level. 031 * If an operation consists of totalItems steps, which are numbered from 0 to 032 * totalItems - 1, this method can be called after the completion of each step. 033 * <p> 034 * Example: if there are three steps and the first one is done, the parameters 035 * must be 0 and 3, which will indicated 33% completion. 036 * Parameters 1 and 3 mean 66%, 2 and 3 100%. 037 * If you use 3 and 3, an IllegalArgumentException will be thrown. 038 * <p> 039 * Computes <code>(float)(zeroBasedIndex + 1) / (float)totalItems</code> and calls 040 * {@link #setProgress(float)} with that value. 041 * 042 * @param zeroBasedIndex the index of the step that was just completed 043 * @param totalItems the number of steps in this operation 044 * @throws IllegalArgumentException if the parameters don't match the above criteria 045 */ 046 void setProgress(int zeroBasedIndex, int totalItems); 047 }