KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)CompoundControl.java 1.10 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  * A <code>CompoundControl</code>, such as a graphic equalizer, provides control
12  * over two or more related properties, each of which is itself represented as
13  * a <code>Control</code>.
14  *
15  * @author Kara Kytle
16  * @version 1.10, 03/12/19
17  * @since 1.3
18  */

19 public abstract class CompoundControl extends Control JavaDoc {
20     
21     
22     // TYPE DEFINES
23

24     
25     // INSTANCE VARIABLES
26

27     
28     /**
29      * The set of member controls.
30      */

31     private Control JavaDoc[] controls;
32     
33     
34     
35     // CONSTRUCTORS
36

37     
38     /**
39      * Constructs a new compound control object with the given parameters.
40      *
41      * @param type the type of control represented this compound control object
42      * @param memberControls the set of member controls
43      */

44     protected CompoundControl(Type type, Control JavaDoc[] memberControls) {
45     
46     super(type);
47     this.controls = memberControls;
48     }
49     
50     
51     
52     // METHODS
53

54     
55     /**
56      * Returns the set of member controls that comprise the compound control.
57      * @return the set of member controls.
58      */

59     public Control JavaDoc[] getMemberControls() {
60     
61     Control JavaDoc[] localArray = new Control JavaDoc[controls.length];
62     
63     for (int i = 0; i < controls.length; i++) {
64         localArray[i] = controls[i];
65     }
66     
67     return localArray;
68     }
69     
70     
71     // ABSTRACT METHOD IMPLEMENTATIONS: CONTROL
72

73     
74     /**
75      * Provides a string representation of the control
76      * @return a string description
77      */

78     public String JavaDoc toString() {
79     
80     StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
81     for (int i = 0; i < controls.length; i++) {
82         if (i != 0) {
83         buf.append(", ");
84         if ((i + 1) == controls.length) {
85             buf.append("and ");
86         }
87         }
88         buf.append(controls[i].getType());
89     }
90     
91     return new String JavaDoc(getType() + " Control containing " + buf + " Controls.");
92     }
93     
94     
95     // INNER CLASSES
96

97     
98     /**
99      * An instance of the <code>CompoundControl.Type</code> inner class identifies one kind of
100      * compound control. Static instances are provided for the
101      * common types.
102      *
103      * @author Kara Kytle
104      * @version 1.10, 03/12/19
105      * @since 1.3
106      */

107     public static class Type extends Control.Type JavaDoc {
108     
109     
110     // TYPE DEFINES
111

112     // CONSTRUCTOR
113

114     
115     /**
116      * Constructs a new compound control type.
117      * @param name the name of the new compound control type
118      */

119     protected Type(String JavaDoc name) {
120         super(name);
121     }
122     } // class Type
123

124 } // class CompoundControl
125
Popular Tags