< prev index next >

src/java.desktop/share/classes/javax/sound/sampled/FloatControl.java

Print this page
rev 57600 : 8236980: toString() cleanup in JavaSound
Reviewed-by: XXX
   1 /*
   2  * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 313      * @param  to final value after the shift
 314      * @param  microseconds maximum duration of the shift in microseconds
 315      * @throws IllegalArgumentException if either {@code from} or {@code to}
 316      *         value does not fall within the allowable range
 317      * @see #getUpdatePeriod
 318      */
 319     public void shift(float from, float to, int microseconds) {
 320         // test "from" value, "to" value will be tested by setValue()
 321         if (from < minimum) {
 322             throw new IllegalArgumentException("Requested value " + from
 323                     + " smaller than allowable minimum value " + minimum + ".");
 324         }
 325         if (from > maximum) {
 326             throw new IllegalArgumentException("Requested value " + from
 327                     + " exceeds allowable maximum value " + maximum + ".");
 328         }
 329         setValue(to);
 330     }
 331 
 332     /**
 333      * Provides a string representation of the control.
 334      *
 335      * @return a string description
 336      */
 337     @Override
 338     public String toString() {
 339         return new String(getType() + " with current value: " + getValue() + " " + units +
 340                           " (range: " + minimum + " - " + maximum + ")");

 341     }
 342 
 343     /**
 344      * An instance of the {@code FloatControl.Type} inner class identifies one
 345      * kind of float control. Static instances are provided for the common
 346      * types.
 347      *
 348      * @author Kara Kytle
 349      * @since 1.3
 350      */
 351     public static class Type extends Control.Type {
 352 
 353         /**
 354          * Represents a control for the overall gain on a line.
 355          * <p>
 356          * Gain is a quantity in decibels (dB) that is added to the intrinsic
 357          * decibel level of the audio signal--that is, the level of the signal
 358          * before it is altered by the gain control. A positive gain amplifies
 359          * (boosts) the signal's volume, and a negative gain attenuates(cuts)it.
 360          * The gain setting defaults to a value of 0.0 dB, meaning the signal's


   1 /*
   2  * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 313      * @param  to final value after the shift
 314      * @param  microseconds maximum duration of the shift in microseconds
 315      * @throws IllegalArgumentException if either {@code from} or {@code to}
 316      *         value does not fall within the allowable range
 317      * @see #getUpdatePeriod
 318      */
 319     public void shift(float from, float to, int microseconds) {
 320         // test "from" value, "to" value will be tested by setValue()
 321         if (from < minimum) {
 322             throw new IllegalArgumentException("Requested value " + from
 323                     + " smaller than allowable minimum value " + minimum + ".");
 324         }
 325         if (from > maximum) {
 326             throw new IllegalArgumentException("Requested value " + from
 327                     + " exceeds allowable maximum value " + maximum + ".");
 328         }
 329         setValue(to);
 330     }
 331 
 332     /**
 333      * Returns a string representation of the float control.
 334      *
 335      * @return a string representation of the float control
 336      */
 337     @Override
 338     public String toString() {
 339         return String.format("%s with current value: %s %s (range: %s - %s)",
 340                              super.toString(), getValue(), getUnits(),
 341                              getMinimum(), getMaximum());
 342     }
 343 
 344     /**
 345      * An instance of the {@code FloatControl.Type} inner class identifies one
 346      * kind of float control. Static instances are provided for the common
 347      * types.
 348      *
 349      * @author Kara Kytle
 350      * @since 1.3
 351      */
 352     public static class Type extends Control.Type {
 353 
 354         /**
 355          * Represents a control for the overall gain on a line.
 356          * <p>
 357          * Gain is a quantity in decibels (dB) that is added to the intrinsic
 358          * decibel level of the audio signal--that is, the level of the signal
 359          * before it is altered by the gain control. A positive gain amplifies
 360          * (boosts) the signal's volume, and a negative gain attenuates(cuts)it.
 361          * The gain setting defaults to a value of 0.0 dB, meaning the signal's


< prev index next >