FileDocCategorySizeDatePackage
GainControlAdapter.javaAPI DocJMF 2.1.1e2586Mon May 12 12:20:56 BST 2003com.sun.media.controls

GainControlAdapter

public class GainControlAdapter extends Object implements GainControl

Fields Summary
private Vector
listeners
private boolean
muteState
private Component
component
private float
DefLevel
private float
dB
private float
level
Constructors Summary
public GainControlAdapter()


      
    
public GainControlAdapter(float defLevel)

	DefLevel = defLevel;
	level = defLevel;
    
public GainControlAdapter(boolean mute)

	this.muteState = mute;
	setLevel(DefLevel);
    
Methods Summary
public synchronized voidaddGainChangeListener(javax.media.GainChangeListener listener)

	if (listener != null) {
	    if (listeners == null)
		listeners = new Vector();
	    listeners.addElement(listener);
	}
    
public java.awt.ComponentgetControlComponent()

	return null;
    
public floatgetDB()

	return dB;
    
public floatgetLevel()

	return level;
    
public booleangetMute()

	return muteState;
    
protected synchronized voidinformListeners()

	if (listeners != null) {
	    GainChangeEvent gce = new GainChangeEvent(this, muteState, dB, level);
	    for (int i = 0; i < listeners.size(); i++) {
		GainChangeListener gcl = (GainChangeListener) listeners.elementAt(i);
		gcl.gainChange(gce);
	    }
	}
    
public synchronized voidremoveGainChangeListener(javax.media.GainChangeListener listener)

	if (listener != null && listeners != null)
	    listeners.removeElement(listener);
    
public floatsetDB(float gain)

	if (dB != gain) {
	    dB = gain;
	    float mult = (float) Math.pow(10.0, dB/20.0);
	    level = mult * DefLevel;
	    if (level < 0.0)
		setLevel(0.0f);
	    else if (level > 1.0)
		setLevel(1.0f);
	    else {  
		setLevel(level);
		informListeners();
	    }
	}
	return dB;
    
public floatsetLevel(float level)

	if (level < 0.0)
	    level = 0.0f;
	if (level > 1.0)
	    level = 1.0f;
	if (this.level != level) {
	    this.level = level;
	    float mult = level/DefLevel;
	    dB = (float) (Math.log((double)((mult==0.0)?0.0001:mult))/Math.log(10.0) * 20.0);
	    informListeners();
	}
	return this.level;
    
public voidsetMute(boolean mute)

	if (muteState != mute) {
	    muteState = mute;
	    informListeners();
	}