KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > sound > sampled > Control


1 /*
2  * @(#)Control.java 1.25 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.sound.sampled;
9
10 /**
11  * {@link Line Lines} often have a set of controls, such as gain and pan, that affect
12  * the audio signal passing through the line. Java Sound's <code>Line</code> objects
13  * let you obtain a particular control object by passing its class as the
14  * argument to a {@link Line#getControl(Control.Type) getControl} method.
15  * <p>
16  * Because the various types of controls have different purposes and features,
17  * all of their functionality is accessed from the subclasses that define
18  * each kind of control.
19  *
20  * @author Kara Kytle
21  * @version 1.25, 03/12/19
22  *
23  * @see Line#getControls
24  * @see Line#isControlSupported
25  * @since 1.3
26  */

27 public abstract class Control {
28     
29     
30     // INSTANCE VARIABLES
31

32     /**
33      * The control type.
34      */

35     private final Type type;
36     
37     
38     
39     // CONSTRUCTORS
40

41     /**
42      * Constructs a Control with the specified type.
43      * @param type the kind of control desired
44      */

45     protected Control(Type type) {
46     this.type = type;
47     }
48     
49     
50     // METHODS
51

52     /**
53      * Obtains the control's type.
54      * @return the control's type.
55      */

56     public Type getType() {
57     return type;
58     }
59     
60     
61     // ABSTRACT METHODS
62

63     /**
64      * Obtains a String describing the control type and its current state.
65      * @return a String representation of the Control.
66      */

67     public String JavaDoc toString() {
68     return new String JavaDoc(getType() + " Control");
69     }
70     
71     
72     /**
73      * An instance of the <code>Type</code> class represents the type of
74      * the control. Static instances are provided for the
75      * common types.
76      */

77     public static class Type {
78     
79     // CONTROL TYPE DEFINES
80

81     // INSTANCE VARIABLES
82

83     /**
84      * Type name.
85      */

86     private String JavaDoc name;
87     
88     
89     // CONSTRUCTOR
90

91     /**
92      * Constructs a new control type with the name specified.
93      * The name should be a descriptive string appropriate for
94      * labelling the control in an application, such as "Gain" or "Balance."
95      * @param name the name of the new control type.
96      */

97     protected Type(String JavaDoc name) {
98         this.name = name;
99     }
100     
101     
102     // METHODS
103

104     /**
105      * Finalizes the equals method
106      */

107     public final boolean equals(Object JavaDoc obj) {
108         return super.equals(obj);
109     }
110     
111     /**
112      * Finalizes the hashCode method
113      */

114     public final int hashCode() {
115         return super.hashCode();
116     }
117     
118     /**
119      * Provides the <code>String</code> representation of the control type. This <code>String</code> is
120      * the same name that was passed to the constructor.
121      *
122      * @return the control type name
123      */

124     public final String JavaDoc toString() {
125         return name;
126     }
127     } // class Type
128

129 } // class Control
130
Popular Tags