jcaas.midi
Class GeneralizedStaff

java.lang.Object
  extended by jcaas.midi.GeneralizedStaff
All Implemented Interfaces:
Staff

public class GeneralizedStaff
extends java.lang.Object
implements Staff

Version:
created: Jan 17, 2005 last updated: 4/17/05 GeneralizedStaff creates a Staff based on supplied input.
Author:
Conrad M. Hutcheson

Constructor Summary
GeneralizedStaff(java.lang.String[] propertyList, java.lang.Object[] properties)
           
 
Method Summary
 StaffProperty getCurrentProperty(java.lang.String propertyName)
          Returns the current value for a given property in a Staff.
 StaffProperty getDefaultProperty(java.lang.String propertyName)
          Returns the default value for a given property in a Staff.
 NoteVector getNextNote()
          getNextNote returns the next NoteVector in the sqeuence of the Staff.
 void replaceAllNotes(NoteVector[] newNotes)
          Replaces all the notes in the Staff.
 void replaceNote(int location, NoteVector newNote)
          Replaces a single note in the Staff
 void reset()
          Resets all current values for Staff properties to their default values and resets the note-position to the first note.
 void resetProperty(java.lang.String propertyName)
          Resets the current value for a given property in a Staff to its default value.
 void setProperty(java.lang.String propertyName, StaffProperty p)
          Sets the current value for a given property in a Staff.
 java.lang.String toString()
          Overwrites Object's toString method to return the Staff's Title.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GeneralizedStaff

public GeneralizedStaff(java.lang.String[] propertyList,
                        java.lang.Object[] properties)
                 throws java.lang.Exception
Parameters:
propertyList - a string array holding the list of the names of properties defined for this Staff. Notes and Tempo are the only required properties.
properties - an object array holding the properities of this Staff in the order provided by propertyList.
Throws:
java.lang.Exception - indicating failed constructor.
Method Detail

getNextNote

public NoteVector getNextNote()
getNextNote returns the next NoteVector in the sqeuence of the Staff. The behavior is such that when the end of the Staff is reached, the Staff will loop.

Specified by:
getNextNote in interface Staff
Returns:
the next NoteVector to be played.

getDefaultProperty

public StaffProperty getDefaultProperty(java.lang.String propertyName)
Returns the default value for a given property in a Staff. Valid properties are names of classes that extend StaffProperty.

Specified by:
getDefaultProperty in interface Staff
Parameters:
propertyName - - a String holding the name of the property, which is the name of the class that extends StaffProperty that represents this property.
Returns:
the StaffProperty, which will be a class of type propertyName that is defualt for this Staff. null if this property is not implemented.

getCurrentProperty

public StaffProperty getCurrentProperty(java.lang.String propertyName)
Returns the current value for a given property in a Staff. Valid properties are names of classes that extend StaffProperty.

Specified by:
getCurrentProperty in interface Staff
Parameters:
propertyName - - a String holding the name of the property, which is the name of the class that extends StaffProperty that represents this property.
Returns:
the StaffProperty, which will be a class of type propertyName that is current for this Staff. null if this property is not implemented.

setProperty

public void setProperty(java.lang.String propertyName,
                        StaffProperty p)
Sets the current value for a given property in a Staff. Valid properties are names of classes that extend StaffProperty.

Specified by:
setProperty in interface Staff
Parameters:
propertyName - - a String holding the name of the property, which is the name of the class that extends StaffProperty that represents this property.
p - - the StaffProperty, which must be a class of type propertyName that is current for this Staff. null if this property is not implemented.

resetProperty

public void resetProperty(java.lang.String propertyName)
Resets the current value for a given property in a Staff to its default value. Valid properties are names of classes that extend StaffProperty.

Specified by:
resetProperty in interface Staff
Parameters:
propertyName - - a String holding the name of the property, which is the name of the class that extends StaffProperty that represents this property.

reset

public void reset()
Resets all current values for Staff properties to their default values and resets the note-position to the first note. Valid properties are names of classes that extend StaffProperty.

Specified by:
reset in interface Staff

toString

public java.lang.String toString()
Overwrites Object's toString method to return the Staff's Title.

Overrides:
toString in class java.lang.Object
Returns:
the String name of the Staff.

replaceNote

public void replaceNote(int location,
                        NoteVector newNote)
Replaces a single note in the Staff

Parameters:
location - the int position of the note in the note array to change
newNote - the new note to replace the old one with

replaceAllNotes

public void replaceAllNotes(NoteVector[] newNotes)
Replaces all the notes in the Staff.

Parameters:
newNotes - the new NoteVector Array to play