Showing the changes to java/pkg/javax/sound/sampled/Control.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,146 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1999, 2002, Oracle and/or its affiliates. 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. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| 22 | * or visit www.oracle.com if you need additional information or have any | ||
| 23 | * questions. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package javax.sound.sampled; | ||
| 27 | |||
| 28 | /** | ||
| 29 | * {@link Line Lines} often have a set of controls, such as gain and pan, that affect | ||
| 30 | * the audio signal passing through the line. Java Sound's <code>Line</code> objects | ||
| 31 | * let you obtain a particular control object by passing its class as the | ||
| 32 | * argument to a {@link Line#getControl(Control.Type) getControl} method. | ||
| 33 | * <p> | ||
| 34 | * Because the various types of controls have different purposes and features, | ||
| 35 | * all of their functionality is accessed from the subclasses that define | ||
| 36 | * each kind of control. | ||
| 37 | * | ||
| 38 | * @author Kara Kytle | ||
| 39 | * | ||
| 40 | * @see Line#getControls | ||
| 41 | * @see Line#isControlSupported | ||
| 42 | * @since 1.3 | ||
| 43 | */ | ||
| 44 | public abstract class Control { | ||
| 45 | |||
| 46 | |||
| 47 | // INSTANCE VARIABLES | ||
| 48 | |||
| 49 | /** | ||
| 50 | * The control type. | ||
| 51 | */ | ||
| 52 | private final Type type; | ||
| 53 | |||
| 54 | |||
| 55 | |||
| 56 | // CONSTRUCTORS | ||
| 57 | |||
| 58 | /** | ||
| 59 | * Constructs a Control with the specified type. | ||
| 60 | * @param type the kind of control desired | ||
| 61 | */ | ||
| 62 | protected Control(Type type) { | ||
| 63 | this.type = type; | ||
| 64 | } | ||
| 65 | |||
| 66 | |||
| 67 | // METHODS | ||
| 68 | |||
| 69 | /** | ||
| 70 | * Obtains the control's type. | ||
| 71 | * @return the control's type. | ||
| 72 | */ | ||
| 73 | public Type getType() { | ||
| 74 | return type; | ||
| 75 | } | ||
| 76 | |||
| 77 | |||
| 78 | // ABSTRACT METHODS | ||
| 79 | |||
| 80 | /** | ||
| 81 | * Obtains a String describing the control type and its current state. | ||
| 82 | * @return a String representation of the Control. | ||
| 83 | */ | ||
| 84 | public String toString() { | ||
| 85 | return new String(getType() + " Control"); | ||
| 86 | } | ||
| 87 | |||
| 88 | |||
| 89 | /** | ||
| 90 | * An instance of the <code>Type</code> class represents the type of | ||
| 91 | * the control. Static instances are provided for the | ||
| 92 | * common types. | ||
| 93 | */ | ||
| 94 | public static class Type { | ||
| 95 | |||
| 96 | // CONTROL TYPE DEFINES | ||
| 97 | |||
| 98 | // INSTANCE VARIABLES | ||
| 99 | |||
| 100 | /** | ||
| 101 | * Type name. | ||
| 102 | */ | ||
| 103 | private String name; | ||
| 104 | |||
| 105 | |||
| 106 | // CONSTRUCTOR | ||
| 107 | |||
| 108 | /** | ||
| 109 | * Constructs a new control type with the name specified. | ||
| 110 | * The name should be a descriptive string appropriate for | ||
| 111 | * labelling the control in an application, such as "Gain" or "Balance." | ||
| 112 | * @param name the name of the new control type. | ||
| 113 | */ | ||
| 114 | protected Type(String name) { | ||
| 115 | this.name = name; | ||
| 116 | } | ||
| 117 | |||
| 118 | |||
| 119 | // METHODS | ||
| 120 | |||
| 121 | /** | ||
| 122 | * Finalizes the equals method | ||
| 123 | */ | ||
| 124 | public final boolean equals(Object obj) { | ||
| 125 | return super.equals(obj); | ||
| 126 | } | ||
| 127 | |||
| 128 | /** | ||
| 129 | * Finalizes the hashCode method | ||
| 130 | */ | ||
| 131 | public final int hashCode() { | ||
| 132 | return super.hashCode(); | ||
| 133 | } | ||
| 134 | |||
| 135 | /** | ||
| 136 | * Provides the <code>String</code> representation of the control type. This <code>String</code> is | ||
| 137 | * the same name that was passed to the constructor. | ||
| 138 | * | ||
| 139 | * @return the control type name | ||
| 140 | */ | ||
| 141 | public final String toString() { | ||
| 142 | return name; | ||
| 143 | } | ||
| 144 | } // class Type | ||
| 145 | |||
| 146 | } // class Control | ||