001    /* BoundedRangeModel.java --
002       Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
003    
004    This file is part of GNU Classpath.
005    
006    GNU Classpath is free software; you can redistribute it and/or modify
007    it under the terms of the GNU General Public License as published by
008    the Free Software Foundation; either version 2, or (at your option)
009    any later version.
010    
011    GNU Classpath is distributed in the hope that it will be useful, but
012    WITHOUT ANY WARRANTY; without even the implied warranty of
013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014    General Public License for more details.
015    
016    You should have received a copy of the GNU General Public License
017    along with GNU Classpath; see the file COPYING.  If not, write to the
018    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
019    02110-1301 USA.
020    
021    Linking this library statically or dynamically with other modules is
022    making a combined work based on this library.  Thus, the terms and
023    conditions of the GNU General Public License cover the whole
024    combination.
025    
026    As a special exception, the copyright holders of this library give you
027    permission to link this library with independent modules to produce an
028    executable, regardless of the license terms of these independent
029    modules, and to copy and distribute the resulting executable under
030    terms of your choice, provided that you also meet, for each linked
031    independent module, the terms and conditions of the license of that
032    module.  An independent module is a module which is not derived from
033    or based on this library.  If you modify this library, you may extend
034    this exception to your version of the library, but you are not
035    obligated to do so.  If you do not wish to do so, delete this
036    exception statement from your version. */
037    
038    
039    package javax.swing;
040    
041    import javax.swing.event.ChangeEvent;
042    import javax.swing.event.ChangeListener;
043    
044    /**
045     * The data model that represents a <i>range</i> that is constrained to fit 
046     * within specified <i>bounds</i>.  The range is defined as <code>value</code> 
047     * to <code>value + extent</code>, where both <code>value</code> and 
048     * <code>extent</code> are integers, and <code>extent >= 0</code>.   The bounds
049     * are defined by integers <code>minimum</code> and <code>maximum</code>.  
050     * <p>
051     * This type of model is used in components that display a range of values,
052     * like {@link JProgressBar} and {@link JSlider}.
053     *
054     * @author Andrew Selkirk
055     */
056    public interface BoundedRangeModel
057    {
058      /**
059       * Returns the current value for the model.
060       * 
061       * @return The current value for the model.
062       *
063       * @see #setValue(int)
064       */
065      int getValue();
066    
067      /**
068       * Sets the value for the model and sends a {@link ChangeEvent} to
069       * all registered listeners.  The new value must satisfy the constraint
070       * <code>min <= value <= value + extent <= max</code>.
071       * 
072       * @param value the value
073       *
074       * @see #getValue()
075       */
076      void setValue(int value);
077    
078      /**
079       * Returns the lower bound for the model.  The start of the model's range 
080       * (see {@link #getValue()}) cannot be less than this lower bound.
081       * 
082       * @return The lower bound for the model.
083       *
084       * @see #setMinimum(int)
085       * @see #getMaximum()
086       */
087      int getMinimum();
088    
089      /**
090       * Sets the lower bound for the model and sends a {@link ChangeEvent} to all
091       * registered listeners.  The new minimum must be less than or equal to the
092       * start value of the model's range (as returned by {@link #getValue()}).
093       * 
094       * @param minimum the minimum value
095       *
096       * @see #getMinimum()
097       */
098      void setMinimum(int minimum);
099    
100      /**
101       * Returns the upper bound for the model.  This sets an upper limit for the
102       * end value of the model's range ({@link #getValue()} + 
103       * {@link #getExtent()}).
104       * 
105       * @return The upper bound for the model.
106       *
107       * @see #setMaximum(int)
108       * @see #getMinimum()
109       */
110      int getMaximum();
111    
112      /**
113       * Sets the upper bound for the model and sends a {@link ChangeEvent} to all
114       * registered listeners.  The new maximum must be greater than or equal to the
115       * end value of the model's range (as returned by {@link #getValue()} + 
116       * {@link #getExtent()}).
117       * 
118       * @param maximum the maximum value
119       *
120       * @see #getMaximum()
121       */
122      void setMaximum(int maximum);
123    
124      /**
125       * Returns the value of the <code>valueIsAdjusting</code> property.
126       * 
127       * @return <code>true</code> if value is adjusting,
128       * otherwise <code>false</code>
129       *
130       * @see #setValueIsAdjusting(boolean)
131       */
132      boolean getValueIsAdjusting();
133    
134      /**
135       * Sets the <code>valueIsAdjusting</code> property.
136       * 
137       * @param adjusting <code>true</code> if adjusting,
138       * <code>false</code> otherwise
139       *
140       * @see #getValueIsAdjusting()
141       */
142      void setValueIsAdjusting(boolean adjusting);
143    
144      /**
145       * Returns the current extent.
146       *
147       * @return the extent
148       *
149       * @see #setExtent(int)
150       */
151      int getExtent();
152    
153      /**
154       * Sets the extent, which is the length of the model's range, and sends a
155       * {@link ChangeEvent} to all registered listeners.
156       * 
157       * @param extent the extent
158       *
159       * @see #getExtent()
160       */
161      void setExtent(int extent);
162    
163      /**
164       * Sets all the properties for the model in a single call.
165       * 
166       * @param value the value
167       * @param extent the extent
168       * @param minimum the minimum value
169       * @param maximum the maximum value
170       * @param adjusting a flag that indicates the model is being adjusted 
171       *                  continuously.
172       */
173      void setRangeProperties(int value, int extent, int minimum, int maximum,
174                              boolean adjusting);
175    
176      /**
177       * Adds a <code>ChangeListener</code> to this object.
178       * 
179       * @param listener the listener to add
180       * 
181       * @see #removeChangeListener(ChangeListener)
182       */
183      void addChangeListener(ChangeListener listener);
184    
185      /**
186       * Removes a <code>ChangeListener</code> from this object.
187       * 
188       * @param listener the listener to remove
189       *
190       * @see #addChangeListener(ChangeListener)
191       */
192      void removeChangeListener(ChangeListener listener);
193    }