author | darcy |
Thu, 05 Jun 2014 23:17:05 -0700 | |
changeset 25131 | 49006bd0e69d |
parent 25128 | 2dfdfa369071 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
25128
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
2 |
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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 |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package javax.sound.sampled; |
|
27 |
||
28 |
/** |
|
25128
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
29 |
* A {@code BooleanControl} provides the ability to switch between two possible |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
30 |
* settings that affect a line's audio. The settings are boolean values |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
31 |
* ({@code true} and {@code false}). A graphical user interface might represent |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
32 |
* the control by a two-state button, an on/off switch, two mutually exclusive |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
33 |
* buttons, or a checkbox (among other possibilities). For example, depressing a |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
34 |
* button might activate a {@link BooleanControl.Type#MUTE MUTE} control to |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
35 |
* silence the line's audio. |
2 | 36 |
* <p> |
25128
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
37 |
* As with other {@code Control} subclasses, a method is provided that returns |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
38 |
* string labels for the values, suitable for display in the user interface. |
2 | 39 |
* |
40 |
* @author Kara Kytle |
|
41 |
* @since 1.3 |
|
42 |
*/ |
|
43 |
public abstract class BooleanControl extends Control { |
|
44 |
||
45 |
/** |
|
25128
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
46 |
* The {@code true} state label, such as "true" or "on". |
2 | 47 |
*/ |
48 |
private final String trueStateLabel; |
|
49 |
||
50 |
/** |
|
25128
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
51 |
* The {@code false} state label, such as "false" or "off". |
2 | 52 |
*/ |
53 |
private final String falseStateLabel; |
|
54 |
||
55 |
/** |
|
56 |
* The current value. |
|
57 |
*/ |
|
58 |
private boolean value; |
|
59 |
||
60 |
/** |
|
61 |
* Constructs a new boolean control object with the given parameters. |
|
62 |
* |
|
25128
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
63 |
* @param type the type of control represented this float control object |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
64 |
* @param initialValue the initial control value |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
65 |
* @param trueStateLabel the label for the state represented by |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
66 |
* {@code true}, such as "true" or "on" |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
67 |
* @param falseStateLabel the label for the state represented by |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
68 |
* {@code false}, such as "false" or "off" |
2 | 69 |
*/ |
70 |
protected BooleanControl(Type type, boolean initialValue, String trueStateLabel, String falseStateLabel) { |
|
71 |
||
72 |
super(type); |
|
73 |
this.value = initialValue; |
|
74 |
this.trueStateLabel = trueStateLabel; |
|
75 |
this.falseStateLabel = falseStateLabel; |
|
76 |
} |
|
77 |
||
78 |
/** |
|
25128
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
79 |
* Constructs a new boolean control object with the given parameters. The |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
80 |
* labels for the {@code true} and {@code false} states default to "true" |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
81 |
* and "false". |
2 | 82 |
* |
25128
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
83 |
* @param type the type of control represented by this float control object |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
84 |
* @param initialValue the initial control value |
2 | 85 |
*/ |
86 |
protected BooleanControl(Type type, boolean initialValue) { |
|
87 |
this(type, initialValue, "true", "false"); |
|
88 |
} |
|
89 |
||
90 |
/** |
|
25128
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
91 |
* Sets the current value for the control. The default implementation simply |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
92 |
* sets the value as indicated. Some controls require that their line be |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
93 |
* open before they can be affected by setting a value. |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
94 |
* |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
95 |
* @param value desired new value |
2 | 96 |
*/ |
97 |
public void setValue(boolean value) { |
|
98 |
this.value = value; |
|
99 |
} |
|
100 |
||
101 |
/** |
|
102 |
* Obtains this control's current value. |
|
25128
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
103 |
* |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
104 |
* @return current value |
2 | 105 |
*/ |
106 |
public boolean getValue() { |
|
107 |
return value; |
|
108 |
} |
|
109 |
||
110 |
/** |
|
111 |
* Obtains the label for the specified state. |
|
25128
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
112 |
* |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
113 |
* @param state the state whose label will be returned |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
114 |
* @return the label for the specified state, such as "true" or "on" for |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
115 |
* {@code true}, or "false" or "off" for {@code false} |
2 | 116 |
*/ |
117 |
public String getStateLabel(boolean state) { |
|
118 |
return ((state == true) ? trueStateLabel : falseStateLabel); |
|
119 |
} |
|
120 |
||
121 |
/** |
|
25128
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
122 |
* Provides a string representation of the control. |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
123 |
* |
2 | 124 |
* @return a string description |
125 |
*/ |
|
25128
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
126 |
@Override |
2 | 127 |
public String toString() { |
128 |
return new String(super.toString() + " with current value: " + getStateLabel(getValue())); |
|
129 |
} |
|
130 |
||
131 |
/** |
|
25128
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
132 |
* An instance of the {@code BooleanControl.Type} class identifies one kind |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
133 |
* of boolean control. Static instances are provided for the common types. |
2 | 134 |
* |
135 |
* @author Kara Kytle |
|
136 |
* @since 1.3 |
|
137 |
*/ |
|
138 |
public static class Type extends Control.Type { |
|
139 |
||
140 |
/** |
|
25128
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
141 |
* Represents a control for the mute status of a line. Note that mute |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
142 |
* status does not affect gain. |
2 | 143 |
*/ |
144 |
public static final Type MUTE = new Type("Mute"); |
|
145 |
||
146 |
/** |
|
25128
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
147 |
* Represents a control for whether reverberation is applied to a line. |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
148 |
* Note that the status of this control not affect the reverberation |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
149 |
* settings for a line, but does affect whether these settings are used. |
2 | 150 |
*/ |
151 |
public static final Type APPLY_REVERB = new Type("Apply Reverb"); |
|
152 |
||
153 |
/** |
|
154 |
* Constructs a new boolean control type. |
|
25128
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
155 |
* |
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
156 |
* @param name the name of the new boolean control type |
2 | 157 |
*/ |
25128
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
158 |
protected Type(final String name) { |
2 | 159 |
super(name); |
160 |
} |
|
25128
2dfdfa369071
8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents:
19207
diff
changeset
|
161 |
} |
2 | 162 |
} |