01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package javax.sound.sampled;
19:
20: public abstract class BooleanControl extends Control {
21:
22: public static class Type extends Control.Type {
23: public static final Type APPLY_REVERB = new Type("Apply Reverb"); //$NON-NLS-1$
24:
25: public static final Type MUTE = new Type("Mute"); //$NON-NLS-1$
26:
27: protected Type(String name) {
28: super (name);
29: }
30: }
31:
32: private boolean value;
33:
34: private String trueStateLabel;
35:
36: private String falseStateLabel;
37:
38: protected BooleanControl(BooleanControl.Type type,
39: boolean initialValue, String trueStateLabel,
40: String falseStateLabel) {
41: super (type);
42: this .value = initialValue;
43: this .trueStateLabel = trueStateLabel;
44: this .falseStateLabel = falseStateLabel;
45: }
46:
47: protected BooleanControl(BooleanControl.Type type,
48: boolean initialValue) {
49: this (type, initialValue, "true", "false"); //$NON-NLS-1$ //$NON-NLS-2$
50: }
51:
52: public void setValue(boolean value) {
53: this .value = value;
54: }
55:
56: public boolean getValue() {
57: return this .value;
58: }
59:
60: public String getStateLabel(boolean state) {
61: if (state) {
62: return this .trueStateLabel;
63: } else {
64: return this .falseStateLabel;
65: }
66: }
67:
68: public String toString() {
69: return getType()
70: + " Control with current value: " + getStateLabel(value); //$NON-NLS-1$
71: }
72: }
|