JSampler
v0.8a

org.jsampler
Class DefaultOrchestraModel

java.lang.Object
  extended by org.jsampler.DefaultOrchestraModel
All Implemented Interfaces:
OrchestraModel

public class DefaultOrchestraModel
extends java.lang.Object
implements OrchestraModel

This class provides default implementation of the OrchestraModel interface.


Constructor Summary
DefaultOrchestraModel()
          Creates a new instance of DefaultOrchestraModel.
 
Method Summary
 void addInstrument(OrchestraInstrument instr)
          Adds the specified instrument to this orchestra.
 void addOrchestraListener(OrchestraListener l)
          Registers the specified listener for receiving event messages.
 java.lang.String getDescription()
          Gets a brief description about this orchestra.
 OrchestraInstrument getInstrument(int idx)
          Gets the instrument at the specified position.
 int getInstrumentCount()
          Gets the current number of instruments in this orchestra.
 int getInstrumentIndex(OrchestraInstrument instr)
          Gets the position of the specified instrument in this orchestra.
 java.lang.String getName()
          Gets the name of this orchestra.
 void insertInstrument(OrchestraInstrument instr, int idx)
          Inserts the specified instrument at the specified position.
 void moveInstrumentAtBottom(OrchestraInstrument instr)
          Moves the specified instrument at the bottom of the instrument list.
 void moveInstrumentDown(OrchestraInstrument instr)
          Moves the specified instrument one position down in the instrument list.
 void moveInstrumentOnTop(OrchestraInstrument instr)
          Moves the specified instrument one the top of the instrument list.
 void moveInstrumentUp(OrchestraInstrument instr)
          Moves the specified instrument one position up in the instrument list.
 void readObject(org.w3c.dom.Node node)
          Reads and sets the content of this orchestra provided by node.
 void removeInstrument(int idx)
          Removes the specified instrument from this orchestra.
 boolean removeInstrument(OrchestraInstrument instr)
          Removes the specified instrument from this orchestra.
 void removeOrchestraListener(OrchestraListener l)
          Removes the specified listener.
 void setDescription(java.lang.String desc)
          Sets a description about this orchestra.
 void setName(java.lang.String name)
          Sets the name of this orchestra.
 java.lang.String toString()
          Returns the name of this orchestra.
 void writeObject(org.w3c.dom.Document doc, org.w3c.dom.Node node)
          Writes the content of this orchestra to the specified node of document doc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultOrchestraModel

public DefaultOrchestraModel()
Creates a new instance of DefaultOrchestraModel.

Method Detail

addOrchestraListener

public void addOrchestraListener(OrchestraListener l)
Registers the specified listener for receiving event messages.

Specified by:
addOrchestraListener in interface OrchestraModel
Parameters:
l - The OrchestraListener to register.

removeOrchestraListener

public void removeOrchestraListener(OrchestraListener l)
Removes the specified listener.

Specified by:
removeOrchestraListener in interface OrchestraModel
Parameters:
l - The OrchestraListener to remove.

getName

public java.lang.String getName()
Gets the name of this orchestra.

Specified by:
getName in interface OrchestraModel
Returns:
The name of this orchestra.

setName

public void setName(java.lang.String name)
Sets the name of this orchestra.

Specified by:
setName in interface OrchestraModel
Parameters:
name - The new name of this orchestra.

toString

public java.lang.String toString()
Returns the name of this orchestra.

Overrides:
toString in class java.lang.Object
Returns:
The name of this orchestra.

getDescription

public java.lang.String getDescription()
Gets a brief description about this orchestra.

Specified by:
getDescription in interface OrchestraModel
Returns:
A brief description about this orchestra.

setDescription

public void setDescription(java.lang.String desc)
Sets a description about this orchestra.

Specified by:
setDescription in interface OrchestraModel
Parameters:
desc - A brief description about this orchestra.

getInstrumentCount

public int getInstrumentCount()
Gets the current number of instruments in this orchestra.

Specified by:
getInstrumentCount in interface OrchestraModel
Returns:
The current number of instruments in this orchestra.

getInstrument

public OrchestraInstrument getInstrument(int idx)
Gets the instrument at the specified position.

Specified by:
getInstrument in interface OrchestraModel
Parameters:
idx - The index of the instrument to be returned.
Returns:
The instrument at the specified position.

addInstrument

public void addInstrument(OrchestraInstrument instr)
Adds the specified instrument to this orchestra.

Specified by:
addInstrument in interface OrchestraModel
Parameters:
instr - The instrument to be added.
Throws:
java.lang.IllegalArgumentException - If instr is null.

insertInstrument

public void insertInstrument(OrchestraInstrument instr,
                             int idx)
Inserts the specified instrument at the specified position.

Specified by:
insertInstrument in interface OrchestraModel
Parameters:
instr - The instrument to be inserted.
idx - The position of the instrument.
Throws:
java.lang.IllegalArgumentException - If instr is null.
java.lang.ArrayIndexOutOfBoundsException - If the specified index is invalid.

removeInstrument

public void removeInstrument(int idx)
Removes the specified instrument from this orchestra.

Specified by:
removeInstrument in interface OrchestraModel
Parameters:
idx - The index of the instrument to remove.

removeInstrument

public boolean removeInstrument(OrchestraInstrument instr)
Removes the specified instrument from this orchestra.

Specified by:
removeInstrument in interface OrchestraModel
Parameters:
instr - The instrument to remove.
Returns:
true if the specified instrument was in this orchestra, false otherwise.

getInstrumentIndex

public int getInstrumentIndex(OrchestraInstrument instr)
Gets the position of the specified instrument in this orchestra.

Specified by:
getInstrumentIndex in interface OrchestraModel
Parameters:
instr - The instrument whose index should be returned.
Returns:
The position of the specified instrument in this orchestra, and -1 if instr is null or the orchestra does not contain the specified instrument.

moveInstrumentOnTop

public void moveInstrumentOnTop(OrchestraInstrument instr)
Moves the specified instrument one the top of the instrument list. This method does nothing if instr is null, the orchestra does not contain the specified instrument, or if the instrument is already on the top.

Specified by:
moveInstrumentOnTop in interface OrchestraModel
Parameters:
instr - The instrument to move on top.

moveInstrumentUp

public void moveInstrumentUp(OrchestraInstrument instr)
Moves the specified instrument one position up in the instrument list. This method does nothing if instr is null, the orchestra does not contain the specified instrument, or if the instrument is already on the top.

Specified by:
moveInstrumentUp in interface OrchestraModel
Parameters:
instr - The instrument to move up.

moveInstrumentDown

public void moveInstrumentDown(OrchestraInstrument instr)
Moves the specified instrument one position down in the instrument list. This method does nothing if instr is null, the orchestra does not contain the specified instrument, or if the instrument is already at the bottom.

Specified by:
moveInstrumentDown in interface OrchestraModel
Parameters:
instr - The instrument to move down.

moveInstrumentAtBottom

public void moveInstrumentAtBottom(OrchestraInstrument instr)
Moves the specified instrument at the bottom of the instrument list. This method does nothing if instr is null, the orchestra does not contain the specified instrument, or if the instrument is already at the bottom.

Specified by:
moveInstrumentAtBottom in interface OrchestraModel
Parameters:
instr - The instrument to move at bottom.

readObject

public void readObject(org.w3c.dom.Node node)
Reads and sets the content of this orchestra provided by node.

Specified by:
readObject in interface OrchestraModel
Parameters:
node - The node providing the content of this orchestra.
Throws:
java.lang.IllegalArgumentException - If an error occurs while reading the content of this orchestra.

writeObject

public void writeObject(org.w3c.dom.Document doc,
                        org.w3c.dom.Node node)
Writes the content of this orchestra to the specified node of document doc.

Specified by:
writeObject in interface OrchestraModel
Parameters:
doc - The document containing node.
node - Specifies the node where the content of this orchestra should be written.

JSampler
v0.8a

Copyright © 2007 Grigor Iliev. All rights reserved.