BoundedRangeModel.java 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /* BoundedRangeModel.java --
  2. Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package javax.swing;
  32. import javax.swing.event.ChangeEvent;
  33. import javax.swing.event.ChangeListener;
  34. /**
  35. * The data model that represents a <i>range</i> that is constrained to fit
  36. * within specified <i>bounds</i>. The range is defined as <code>value</code>
  37. * to <code>value + extent</code>, where both <code>value</code> and
  38. * <code>extent</code> are integers, and <code>extent >= 0</code>. The bounds
  39. * are defined by integers <code>minimum</code> and <code>maximum</code>.
  40. * <p>
  41. * This type of model is used in components that display a range of values,
  42. * like {@link JProgressBar} and {@link JSlider}.
  43. *
  44. * @author Andrew Selkirk
  45. */
  46. public interface BoundedRangeModel
  47. {
  48. /**
  49. * Returns the current value for the model.
  50. *
  51. * @return The current value for the model.
  52. *
  53. * @see #setValue(int)
  54. */
  55. int getValue();
  56. /**
  57. * Sets the value for the model and sends a {@link ChangeEvent} to
  58. * all registered listeners. The new value must satisfy the constraint
  59. * <code>min <= value <= value + extent <= max</code>.
  60. *
  61. * @param value the value
  62. *
  63. * @see #getValue()
  64. */
  65. void setValue(int value);
  66. /**
  67. * Returns the lower bound for the model. The start of the model's range
  68. * (see {@link #getValue()}) cannot be less than this lower bound.
  69. *
  70. * @return The lower bound for the model.
  71. *
  72. * @see #setMinimum(int)
  73. * @see #getMaximum()
  74. */
  75. int getMinimum();
  76. /**
  77. * Sets the lower bound for the model and sends a {@link ChangeEvent} to all
  78. * registered listeners. The new minimum must be less than or equal to the
  79. * start value of the model's range (as returned by {@link #getValue()}).
  80. *
  81. * @param minimum the minimum value
  82. *
  83. * @see #getMinimum()
  84. */
  85. void setMinimum(int minimum);
  86. /**
  87. * Returns the upper bound for the model. This sets an upper limit for the
  88. * end value of the model's range ({@link #getValue()} +
  89. * {@link #getExtent()}).
  90. *
  91. * @return The upper bound for the model.
  92. *
  93. * @see #setMaximum(int)
  94. * @see #getMinimum()
  95. */
  96. int getMaximum();
  97. /**
  98. * Sets the upper bound for the model and sends a {@link ChangeEvent} to all
  99. * registered listeners. The new maximum must be greater than or equal to the
  100. * end value of the model's range (as returned by {@link #getValue()} +
  101. * {@link #getExtent()}).
  102. *
  103. * @param maximum the maximum value
  104. *
  105. * @see #getMaximum()
  106. */
  107. void setMaximum(int maximum);
  108. /**
  109. * Returns the value of the <code>valueIsAdjusting</code> property.
  110. *
  111. * @return <code>true</code> if value is adjusting,
  112. * otherwise <code>false</code>
  113. *
  114. * @see #setValueIsAdjusting(boolean)
  115. */
  116. boolean getValueIsAdjusting();
  117. /**
  118. * Sets the <code>valueIsAdjusting</code> property.
  119. *
  120. * @param adjusting <code>true</code> if adjusting,
  121. * <code>false</code> otherwise
  122. *
  123. * @see #getValueIsAdjusting()
  124. */
  125. void setValueIsAdjusting(boolean adjusting);
  126. /**
  127. * Returns the current extent.
  128. *
  129. * @return the extent
  130. *
  131. * @see #setExtent(int)
  132. */
  133. int getExtent();
  134. /**
  135. * Sets the extent, which is the length of the model's range, and sends a
  136. * {@link ChangeEvent} to all registered listeners.
  137. *
  138. * @param extent the extent
  139. *
  140. * @see #getExtent()
  141. */
  142. void setExtent(int extent);
  143. /**
  144. * Sets all the properties for the model in a single call.
  145. *
  146. * @param value the value
  147. * @param extent the extent
  148. * @param minimum the minimum value
  149. * @param maximum the maximum value
  150. * @param adjusting a flag that indicates the model is being adjusted
  151. * continuously.
  152. */
  153. void setRangeProperties(int value, int extent, int minimum, int maximum,
  154. boolean adjusting);
  155. /**
  156. * Adds a <code>ChangeListener</code> to this object.
  157. *
  158. * @param listener the listener to add
  159. *
  160. * @see #removeChangeListener(ChangeListener)
  161. */
  162. void addChangeListener(ChangeListener listener);
  163. /**
  164. * Removes a <code>ChangeListener</code> from this object.
  165. *
  166. * @param listener the listener to remove
  167. *
  168. * @see #addChangeListener(ChangeListener)
  169. */
  170. void removeChangeListener(ChangeListener listener);
  171. }