ProgressEvent.java
上传用户:zhengdagz
上传日期:2014-03-06
资源大小:1956k
文件大小:3k
源码类别:

xml/soap/webservice

开发平台:

Java

  1. /*
  2.  * $Id: ProgressEvent.java,v 1.2 2005/10/10 18:03:07 rbair Exp $
  3.  *
  4.  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
  5.  * Santa Clara, California 95054, U.S.A. All rights reserved.
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  * 
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  * 
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  20.  */
  21. package org.jdesktop.swingx.event;
  22. /**
  23.  * A MessageEvent that represents the cycle of a long running operation.
  24.  * Use the constructors to indicate the stage of the operation.
  25.  *
  26.  * @author Mark Davidson
  27.  */
  28. public class ProgressEvent extends MessageEvent  {
  29.     private int minimum;
  30.     private int maximum;
  31.     private int progress;
  32.     private boolean indeterminate = true;
  33.     /**
  34.      * Constructs an indeterminate  progress event.
  35.      */
  36.     public ProgressEvent(Object source) {
  37. super(source);
  38.     }
  39.     /**
  40.      * Constructs a progress event used to indicate an increment of progress.
  41.      *
  42.      * @param source the object which orignated the event
  43.      * @param progress the value between min and max which indicates 
  44.      *        the progression of the operation.
  45.      */
  46.     public ProgressEvent(Object source, int progress) {
  47. super(source);
  48. this.progress = progress;
  49. setIndeterminate(false);
  50.     }
  51.     /**
  52.      * Constructs a ProgressEvent which indicates the beginning of a long operation.
  53.      * For a determinite progress operation, the minimum value should be less than
  54.      * the maximum value. For indterminate operations, set minimum equal to maximum.
  55.      *
  56.      * @param source the object which orignated the event
  57.      * @param min the minimum value of the progress operation
  58.      * @param max the maximum value of the progress operation
  59.      */
  60.     public ProgressEvent(Object source, int min, int max) {
  61. super(source);
  62. setMaximum(max);
  63. setMinimum(min);
  64. setIndeterminate(max == min);
  65.     }
  66.     private void setMaximum(int max) {
  67. this.maximum = max;
  68.     }
  69.     public int getMaximum() {
  70. return maximum;
  71.     }
  72.     private void setMinimum(int min) {
  73. this.minimum = min;
  74.     }
  75.     public int getMinimum() {
  76. return minimum;
  77.     }
  78.     private void setIndeterminate(boolean indeterminate) {
  79. this.indeterminate = indeterminate;
  80.     }
  81.     public boolean isIndeterminate() {
  82. return indeterminate;
  83.     }
  84.     public int getProgress() {
  85. return progress;
  86.     }
  87. }