Source Code Cross Referenced for BooleanControl.java in  » 6.0-JDK-Core » sound » javax » sound » sampled » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » sound » javax.sound.sampled 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 1999-2003 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package javax.sound.sampled;
027
028        /**
029         * A <code>BooleanControl</code> provides the ability to switch between
030         * two possible settings that affect a line's audio.  The settings are boolean
031         * values (<code>true</code> and <code>false</code>).  A graphical user interface
032         * might represent the control by a two-state button, an on/off switch, two
033         * mutually exclusive buttons, or a checkbox (among other possibilities).
034         * For example, depressing a button might activate a
035         * <code>{@link BooleanControl.Type#MUTE MUTE}</code> control to silence
036         * the line's audio.
037         * <p>
038         * As with other <code>{@link Control}</code> subclasses, a method is
039         * provided that returns string labels for the values, suitable for
040         * display in the user interface.
041         *
042         * @author Kara Kytle
043         * @version 1.22, 07/05/05
044         * @since 1.3
045         */
046        public abstract class BooleanControl extends Control {
047
048            // INSTANCE VARIABLES
049
050            /**
051             * The <code>true</code> state label, such as "true" or "on."
052             */
053            private final String trueStateLabel;
054
055            /**
056             * The <code>false</code> state label, such as "false" or "off."
057             */
058            private final String falseStateLabel;
059
060            /**
061             * The current value.
062             */
063            private boolean value;
064
065            // CONSTRUCTORS
066
067            /**
068             * Constructs a new boolean control object with the given parameters.
069             *
070             * @param type the type of control represented this float control object
071             * @param initialValue the initial control value
072             * @param trueStateLabel the label for the state represented by <code>true</code>,
073             * such as "true" or "on."
074             * @param falseStateLabel the label for the state represented by <code>false</code>,
075             * such as "false" or "off."
076             */
077            protected BooleanControl(Type type, boolean initialValue,
078                    String trueStateLabel, String falseStateLabel) {
079
080                super (type);
081                this .value = initialValue;
082                this .trueStateLabel = trueStateLabel;
083                this .falseStateLabel = falseStateLabel;
084            }
085
086            /**
087             * Constructs a new boolean control object with the given parameters.
088             * The labels for the <code>true</code> and <code>false</code> states
089             * default to "true" and "false."
090             *
091             * @param type the type of control represented by this float control object
092             * @param initialValue the initial control value
093             */
094            protected BooleanControl(Type type, boolean initialValue) {
095                this (type, initialValue, "true", "false");
096            }
097
098            // METHODS
099
100            /**
101             * Sets the current value for the control.  The default
102             * implementation simply sets the value as indicated.
103             * Some controls require that their line be open before they can be affected
104             * by setting a value.
105             * @param value desired new value.
106             */
107            public void setValue(boolean value) {
108                this .value = value;
109            }
110
111            /**
112             * Obtains this control's current value.
113             * @return current value.
114             */
115            public boolean getValue() {
116                return value;
117            }
118
119            /**
120             * Obtains the label for the specified state.
121             * @return the label for the specified state, such as "true" or "on"
122             * for <code>true</code>, or "false" or "off" for <code>false</code>.
123             */
124            public String getStateLabel(boolean state) {
125                return ((state == true) ? trueStateLabel : falseStateLabel);
126            }
127
128            // ABSTRACT METHOD IMPLEMENTATIONS: CONTROL
129
130            /**
131             * Provides a string representation of the control
132             * @return a string description
133             */
134            public String toString() {
135                return new String(super .toString() + " with current value: "
136                        + getStateLabel(getValue()));
137            }
138
139            // INNER CLASSES
140
141            /**
142             * An instance of the <code>BooleanControl.Type</code> class identifies one kind of
143             * boolean control.  Static instances are provided for the
144             * common types.
145             *
146             * @author Kara Kytle
147             * @version 1.22, 07/05/05
148             * @since 1.3
149             */
150            public static class Type extends Control.Type {
151
152                // TYPE DEFINES
153
154                /**
155                 * Represents a control for the mute status of a line.
156                 * Note that mute status does not affect gain.
157                 */
158                public static final Type MUTE = new Type("Mute");
159
160                /**
161                 * Represents a control for whether reverberation is applied
162                 * to a line.  Note that the status of this control not affect
163                 * the reverberation settings for a line, but does affect whether
164                 * these settings are used.
165                 */
166                public static final Type APPLY_REVERB = new Type("Apply Reverb");
167
168                // CONSTRUCTOR
169
170                /**
171                 * Constructs a new boolean control type.
172                 * @param name	the name of the new boolean control type
173                 */
174                protected Type(String name) {
175                    super (name);
176                }
177            } // class Type
178        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.