J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 1999-2003 Sun Microsystems, Inc. All Rights Reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun in the LICENSE file that accompanied this code. |
| 10 | * |
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | * version 2 for more details (a copy is included in the LICENSE file that |
| 15 | * accompanied this code). |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License version |
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any questions. |
| 24 | */ |
| 25 | |
| 26 | package javax.sound.sampled; |
| 27 | |
| 28 | /** |
| 29 | * A <code>CompoundControl</code>, such as a graphic equalizer, provides control |
| 30 | * over two or more related properties, each of which is itself represented as |
| 31 | * a <code>Control</code>. |
| 32 | * |
| 33 | * @author Kara Kytle |
| 34 | * @since 1.3 |
| 35 | */ |
| 36 | public abstract class CompoundControl extends Control { |
| 37 | |
| 38 | |
| 39 | // TYPE DEFINES |
| 40 | |
| 41 | |
| 42 | // INSTANCE VARIABLES |
| 43 | |
| 44 | |
| 45 | /** |
| 46 | * The set of member controls. |
| 47 | */ |
| 48 | private Control[] controls; |
| 49 | |
| 50 | |
| 51 | |
| 52 | // CONSTRUCTORS |
| 53 | |
| 54 | |
| 55 | /** |
| 56 | * Constructs a new compound control object with the given parameters. |
| 57 | * |
| 58 | * @param type the type of control represented this compound control object |
| 59 | * @param memberControls the set of member controls |
| 60 | */ |
| 61 | protected CompoundControl(Type type, Control[] memberControls) { |
| 62 | |
| 63 | super(type); |
| 64 | this.controls = memberControls; |
| 65 | } |
| 66 | |
| 67 | |
| 68 | |
| 69 | // METHODS |
| 70 | |
| 71 | |
| 72 | /** |
| 73 | * Returns the set of member controls that comprise the compound control. |
| 74 | * @return the set of member controls. |
| 75 | */ |
| 76 | public Control[] getMemberControls() { |
| 77 | |
| 78 | Control[] localArray = new Control[controls.length]; |
| 79 | |
| 80 | for (int i = 0; i < controls.length; i++) { |
| 81 | localArray[i] = controls[i]; |
| 82 | } |
| 83 | |
| 84 | return localArray; |
| 85 | } |
| 86 | |
| 87 | |
| 88 | // ABSTRACT METHOD IMPLEMENTATIONS: CONTROL |
| 89 | |
| 90 | |
| 91 | /** |
| 92 | * Provides a string representation of the control |
| 93 | * @return a string description |
| 94 | */ |
| 95 | public String toString() { |
| 96 | |
| 97 | StringBuffer buf = new StringBuffer(); |
| 98 | for (int i = 0; i < controls.length; i++) { |
| 99 | if (i != 0) { |
| 100 | buf.append(", "); |
| 101 | if ((i + 1) == controls.length) { |
| 102 | buf.append("and "); |
| 103 | } |
| 104 | } |
| 105 | buf.append(controls[i].getType()); |
| 106 | } |
| 107 | |
| 108 | return new String(getType() + " Control containing " + buf + " Controls."); |
| 109 | } |
| 110 | |
| 111 | |
| 112 | // INNER CLASSES |
| 113 | |
| 114 | |
| 115 | /** |
| 116 | * An instance of the <code>CompoundControl.Type</code> inner class identifies one kind of |
| 117 | * compound control. Static instances are provided for the |
| 118 | * common types. |
| 119 | * |
| 120 | * @author Kara Kytle |
| 121 | * @since 1.3 |
| 122 | */ |
| 123 | public static class Type extends Control.Type { |
| 124 | |
| 125 | |
| 126 | // TYPE DEFINES |
| 127 | |
| 128 | // CONSTRUCTOR |
| 129 | |
| 130 | |
| 131 | /** |
| 132 | * Constructs a new compound control type. |
| 133 | * @param name the name of the new compound control type |
| 134 | */ |
| 135 | protected Type(String name) { |
| 136 | super(name); |
| 137 | } |
| 138 | } // class Type |
| 139 | |
| 140 | } // class CompoundControl |