API Overview API Index Package Overview Direct link to this page
JDK 1.6
  javax.sound.sampled. BooleanControl View Javadoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176

/*
 * @(#)BooleanControl.java	1.16 05/11/17
 *
 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

package javax.sound.sampled;

/**
 * A <code>BooleanControl</code> provides the ability to switch between
 * two possible settings that affect a line's audio.  The settings are boolean
 * values (<code>true</code> and <code>false</code>).  A graphical user interface
 * might represent the control by a two-state button, an on/off switch, two
 * mutually exclusive buttons, or a checkbox (among other possibilities).
 * For example, depressing a button might activate a
 * <code>{@link BooleanControl.Type#MUTE MUTE}</code> control to silence
 * the line's audio.
 * <p>
 * As with other <code>{@link Control}</code> subclasses, a method is
 * provided that returns string labels for the values, suitable for
 * display in the user interface.
 *
 * @author Kara Kytle
 * @version 1.16, 05/11/17
 * @since 1.3
 */
public abstract class BooleanControl extends Control {
    
    
    // INSTANCE VARIABLES
    
    /**
     * The <code>true</code> state label, such as "true" or "on."
     */
    private final String trueStateLabel;
    
    /**
     * The <code>false</code> state label, such as "false" or "off."
     */
    private final String falseStateLabel;
    
    /**
     * The current value.
     */
    private boolean value;
    
    
    // CONSTRUCTORS
    
    
    /**
     * Constructs a new boolean control object with the given parameters.
     *
     * @param type the type of control represented this float control object
     * @param initialValue the initial control value
     * @param trueStateLabel the label for the state represented by <code>true</code>,
     * such as "true" or "on."
     * @param falseStateLabel the label for the state represented by <code>false</code>,
     * such as "false" or "off."
     */
    protected BooleanControl(Type type, boolean initialValue, String trueStateLabel, String falseStateLabel) {
	
	super(type);
	this.value = initialValue;
	this.trueStateLabel = trueStateLabel;
	this.falseStateLabel = falseStateLabel;
    }
    
    
    /**
     * Constructs a new boolean control object with the given parameters.
     * The labels for the <code>true</code> and <code>false</code> states
     * default to "true" and "false."
     *
     * @param type the type of control represented by this float control object
     * @param initialValue the initial control value
     */
    protected BooleanControl(Type type, boolean initialValue) {
	this(type, initialValue, "true", "false");
    }
    
    
    // METHODS
    
    
    /**
     * Sets the current value for the control.  The default
     * implementation simply sets the value as indicated.
     * Some controls require that their line be open before they can be affected
     * by setting a value.
     * @param value desired new value.
     */
    public void setValue(boolean value) {
	this.value = value;
    }
    
    
    
    /**
     * Obtains this control's current value.
     * @return current value.
     */
    public boolean getValue() {
	return value;
    }
    
    
    /**
     * Obtains the label for the specified state.
     * @return the label for the specified state, such as "true" or "on"
     * for <code>true</code>, or "false" or "off" for <code>false</code>.
     */
    public String getStateLabel(boolean state) {
	return ((state == true) ? trueStateLabel : falseStateLabel);
    }
    
    
    
    // ABSTRACT METHOD IMPLEMENTATIONS: CONTROL
    
    
    /**
     * Provides a string representation of the control
     * @return a string description
     */
    public String toString() {
	return new String(super.toString() + " with current value: " + getStateLabel(getValue()));
    }
    
    
    // INNER CLASSES
    
    
    /**
     * An instance of the <code>BooleanControl.Type</code> class identifies one kind of
     * boolean control.  Static instances are provided for the
     * common types.
     *
     * @author Kara Kytle
     * @version 1.16, 05/11/17
     * @since 1.3
     */
    public static class Type extends Control.Type {
	
	
	// TYPE DEFINES
	
	
	/**
	 * Represents a control for the mute status of a line.
	 * Note that mute status does not affect gain.
	 */
	public static final Type MUTE				= new Type("Mute");
	
	/**
	 * Represents a control for whether reverberation is applied
	 * to a line.  Note that the status of this control not affect
	 * the reverberation settings for a line, but does affect whether
	 * these settings are used.
	 */
	public static final Type APPLY_REVERB		= new Type("Apply Reverb");
	
	
	// CONSTRUCTOR
	
	
	/**
	 * Constructs a new boolean control type.
	 * @param name	the name of the new boolean control type
	 */
	protected Type(String name) {
	    super(name);
	}
    } // class Type
}

Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar