Package com.tagtraum.audiokern.player
Class PlayerVolumeModel
- java.lang.Object
-
- com.tagtraum.audiokern.player.PlayerVolumeModel
-
- All Implemented Interfaces:
PropertyChangeListener
,EventListener
,BoundedRangeModel
public class PlayerVolumeModel extends Object implements BoundedRangeModel, PropertyChangeListener
Wraps anAudioPlayer
into aBoundedRangeModel
, so that its volume can be easily manipulated.- Author:
- Hendrik Schreiber
-
-
Constructor Summary
Constructors Constructor Description PlayerVolumeModel()
PlayerVolumeModel(AudioPlayer player)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChangeListener(ChangeListener l)
Adds aChangeListener
.protected void
fireStateChanged()
Runs eachChangeListener
'sstateChanged
method.ChangeListener[]
getChangeListeners()
Returns an array of all the change listeners registered on thisDefaultBoundedRangeModel
.int
getExtent()
<T extends EventListener>
T[]getListeners(Class<T> listenerType)
Returns an array of all the objects currently registered asFooListener
s upon this model.int
getMaximum()
int
getMinimum()
AudioPlayer
getPlayer()
int
getValue()
boolean
getValueIsAdjusting()
void
propertyChange(PropertyChangeEvent evt)
void
removeChangeListener(ChangeListener l)
Removes aChangeListener
.void
setExtent(int newExtent)
void
setMaximum(int newMaximum)
void
setMinimum(int newMinimum)
void
setPlayer(AudioPlayer player)
void
setRangeProperties(int newValue, int newExtent, int newMin, int newMax, boolean newAdjusting)
void
setValue(int newValue)
void
setValueIsAdjusting(boolean newAdjusting)
String
toString()
Returns a string that displays all of theBoundedRangeModel
properties.
-
-
-
Constructor Detail
-
PlayerVolumeModel
public PlayerVolumeModel(AudioPlayer player)
-
PlayerVolumeModel
public PlayerVolumeModel()
-
-
Method Detail
-
getPlayer
public AudioPlayer getPlayer()
-
setPlayer
public void setPlayer(AudioPlayer player)
-
getMinimum
public int getMinimum()
- Specified by:
getMinimum
in interfaceBoundedRangeModel
-
setMinimum
public void setMinimum(int newMinimum)
- Specified by:
setMinimum
in interfaceBoundedRangeModel
-
getMaximum
public int getMaximum()
- Specified by:
getMaximum
in interfaceBoundedRangeModel
-
setMaximum
public void setMaximum(int newMaximum)
- Specified by:
setMaximum
in interfaceBoundedRangeModel
-
getValue
public int getValue()
- Specified by:
getValue
in interfaceBoundedRangeModel
-
setValue
public void setValue(int newValue)
- Specified by:
setValue
in interfaceBoundedRangeModel
-
setValueIsAdjusting
public void setValueIsAdjusting(boolean newAdjusting)
- Specified by:
setValueIsAdjusting
in interfaceBoundedRangeModel
-
getValueIsAdjusting
public boolean getValueIsAdjusting()
- Specified by:
getValueIsAdjusting
in interfaceBoundedRangeModel
-
getExtent
public int getExtent()
- Specified by:
getExtent
in interfaceBoundedRangeModel
-
setExtent
public void setExtent(int newExtent)
- Specified by:
setExtent
in interfaceBoundedRangeModel
-
setRangeProperties
public void setRangeProperties(int newValue, int newExtent, int newMin, int newMax, boolean newAdjusting)
- Specified by:
setRangeProperties
in interfaceBoundedRangeModel
-
propertyChange
public void propertyChange(PropertyChangeEvent evt)
- Specified by:
propertyChange
in interfacePropertyChangeListener
-
addChangeListener
public void addChangeListener(ChangeListener l)
Adds aChangeListener
. The change listeners are run each time any one of the Bounded Range model properties changes.- Specified by:
addChangeListener
in interfaceBoundedRangeModel
- Parameters:
l
- the ChangeListener to add- See Also:
removeChangeListener(javax.swing.event.ChangeListener)
,BoundedRangeModel.addChangeListener(javax.swing.event.ChangeListener)
-
removeChangeListener
public void removeChangeListener(ChangeListener l)
Removes aChangeListener
.- Specified by:
removeChangeListener
in interfaceBoundedRangeModel
- Parameters:
l
- theChangeListener
to remove- See Also:
addChangeListener(javax.swing.event.ChangeListener)
,BoundedRangeModel.removeChangeListener(javax.swing.event.ChangeListener)
-
getChangeListeners
public ChangeListener[] getChangeListeners()
Returns an array of all the change listeners registered on thisDefaultBoundedRangeModel
.- Returns:
- all of this model's
ChangeListener
s or an empty array if no change listeners are currently registered - Since:
- 1.4
- See Also:
addChangeListener(javax.swing.event.ChangeListener)
,removeChangeListener(javax.swing.event.ChangeListener)
-
fireStateChanged
protected void fireStateChanged()
Runs eachChangeListener
'sstateChanged
method.
-
toString
public String toString()
Returns a string that displays all of theBoundedRangeModel
properties.
-
getListeners
public <T extends EventListener> T[] getListeners(Class<T> listenerType)
Returns an array of all the objects currently registered as
FooListener
s upon this model.FooListener
s are registered using theaddFooListener
method.You can specify the
listenerType
argument with a class literal, such asFooListener.class
. For example, you can query aDefaultBoundedRangeModel
instancem
for its change listeners with the following code:ChangeListener[] cls = (ChangeListener[])(m.getListeners(ChangeListener.class));
If no such listeners exist, this method returns an empty array.
- Parameters:
listenerType
- the type of listeners requested; this parameter should specify an interface that descends fromjava.util.EventListener
- Returns:
- an array of all objects registered as
FooListener
s on this model, or an empty array if no such listeners have been added - Throws:
ClassCastException
- iflistenerType
doesn't specify a class or interface that implementsjava.util.EventListener
- Since:
- 1.3
- See Also:
getChangeListeners()
-
-