net.charlesames.music.musicxml
Class Measure

java.lang.Object
  extended by net.charlesames.utility.common.Disposable
      extended by net.charlesames.music.musicxml.MusicXmlEntity
          extended by net.charlesames.music.musicxml.Measure
Direct Known Subclasses:
MeasureInPart

public abstract class Measure
extends MusicXmlEntity

The abstract Measure class implements shared functionality for MusicXML measure elements.

Author:
Charles Ames

Method Summary
 void addEvent(TimedEvent event)
          Add a specified TimedEvent instance to the collection.
 void advanceTime()
          Advance Time by NoteDuration.
 Barline createBarline(BarStyle barStyle)
          Create a Barline instance with the indicated style.
 KeySignature createKeySignature(int fifths, Mode mode)
          Create a KeySignature instance with the indicated parameters.
 TimeSignature createTimeSignature(int beats, int beatType)
          Create a TimeSignature instance with the indicated parameters.
 void dispose()
          Release resources engaged by this object, thus rendering it amenable to garbage collection.
 int divisionsFromRatio(Ratio time)
          Convert the specified ratio from quarter notes to divisions.
 boolean equals(MusicXmlEntity other)
          Test if this MusicXML entity has the same content as another object.
 Attributes getAttributes(int time)
          Look for an Attributes instance at the indicated time; if one exists, return it; otherwise create a new instance.
 int getDivisions()
          Setter for the Divisions property.
 java.util.List<TimedEvent> getEvents()
          Get all events in the measure.
 YesNo getImplicit()
          Getter for the Implicit property.
 int getMeasureDuration()
          Getter for the MeasureDuration property.
 MeasurePrint getMeasurePrint()
          Getter for the MeasurePrint property.
 int getNoteDuration()
          Getter for the NoteDuration property.
 int getNumber()
          Getter for the Number property.
 int getTime()
          Getter for the Time property
 int getWidth()
          Getter for the Width property
 void putXmlData(org.w3c.dom.Element element)
           
 void setDivisions(int divisions)
          Getter for the Divisions property.
 void setImplicit(YesNo implicit)
          Setter for the Implicit property.
 void setMeasureDuration(int measureDuration)
          Setter for the MeasureDuration property.
 void setMeasurePrint(MeasurePrint measurePrint)
          Setter for the MeasurePrint property.
 void setNoteDuration(int noteDuration)
          Setter for the NoteDuration property.
 void setNumber(int number)
          Setter for the Number property.
 void setStaves(int staves)
          Setter for the Staves property.
 void setTime(int time)
          Setter for the Time property.
 void setWidth(int width)
          Setter for the Width property.
 
Methods inherited from class net.charlesames.music.musicxml.MusicXmlEntity
getContainer, makeDirty, toXmlNode
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

dispose

public void dispose()
Description copied from class: Disposable
Release resources engaged by this object, thus rendering it amenable to garbage collection.

Specified by:
dispose in class Disposable

getNumber

public int getNumber()
Getter for the Number property.

Returns:
The current Number value.

setNumber

public void setNumber(int number)
Setter for the Number property.

Parameters:
number - The intended Number value.

getImplicit

public YesNo getImplicit()
Getter for the Implicit property.

Returns:
The current Implicit value.

setImplicit

public void setImplicit(YesNo implicit)
Setter for the Implicit property.

Parameters:
implicit - The intended Implicit value.

getWidth

public int getWidth()
Getter for the Width property

Returns:
The current Width value.

setWidth

public void setWidth(int width)
Setter for the Width property.

Parameters:
width - The intended Width value.

getTime

public int getTime()
Getter for the Time property

Returns:
The current Time value.

setTime

public void setTime(int time)
Setter for the Time property.

Parameters:
time - The intended Time value.

advanceTime

public void advanceTime()
Advance Time by NoteDuration. Throws an IllegalArgumentException if the resulting Time exceeds MeaureDuration.


getAttributes

public Attributes getAttributes(int time)
Look for an Attributes instance at the indicated time; if one exists, return it; otherwise create a new instance.

Parameters:
time - The indicated time.
Returns:
An Attributes instance at the indicated time.

setStaves

public void setStaves(int staves)
Setter for the Staves property.

Parameters:
staves - The indented Staves value.

createTimeSignature

public TimeSignature createTimeSignature(int beats,
                                         int beatType)
Create a TimeSignature instance with the indicated parameters.

Parameters:
beats - The number of beats in a measure.
beatType - 1=whole, 2=half, 3=quarter, 4=eighth, and so forth.
Returns:
A TimeSignature instance with the indicated parameters.

getDivisions

public int getDivisions()
Setter for the Divisions property. The Divisions property holds the number of divisions per quarter note.

Returns:
The current Divisions value.

setDivisions

public void setDivisions(int divisions)
Getter for the Divisions property. The Divisions property holds the number of divisions per quarter note.

Parameters:
divisions - The intended Divisions value.

divisionsFromRatio

public int divisionsFromRatio(Ratio time)
Convert the specified ratio from quarter notes to divisions.

Parameters:
time - The specified ratio relative to the quarter note.
Returns:
The converted value in divisions.

createKeySignature

public KeySignature createKeySignature(int fifths,
                                       Mode mode)
Create a KeySignature instance with the indicated parameters.

Parameters:
fifths - Number of sharps (positive) or flats (negative).
mode - major or minor.
Returns:
A KeySignature instance with the indicated parameters.

createBarline

public Barline createBarline(BarStyle barStyle)
Create a Barline instance with the indicated style.

Parameters:
barStyle - the indicated style.
Returns:
A Barline instance with the indicated style.

getMeasureDuration

public int getMeasureDuration()
Getter for the MeasureDuration property.

Returns:
The current MeasureDuration value in divisions.

setMeasureDuration

public void setMeasureDuration(int measureDuration)
Setter for the MeasureDuration property.

Parameters:
measureDuration - The intended MeasureDuration value in divisions.

getNoteDuration

public int getNoteDuration()
Getter for the NoteDuration property.

Returns:
The current NoteDuration value.

setNoteDuration

public void setNoteDuration(int noteDuration)
Setter for the NoteDuration property.

Parameters:
noteDuration - The intended NoteDuration value.

getMeasurePrint

public MeasurePrint getMeasurePrint()
Getter for the MeasurePrint property.

Returns:
The current MeasurePrint value.

setMeasurePrint

public void setMeasurePrint(MeasurePrint measurePrint)
Setter for the MeasurePrint property.

Parameters:
measurePrint - The intended MeasurePrint value.

getEvents

public java.util.List<TimedEvent> getEvents()
Get all events in the measure.

Returns:
A collection of TimedEvent instances.

addEvent

public void addEvent(TimedEvent event)
Add a specified TimedEvent instance to the collection.

Parameters:
event - The specified TimedEvent instance.

putXmlData

public void putXmlData(org.w3c.dom.Element element)

equals

public boolean equals(MusicXmlEntity other)
Description copied from class: MusicXmlEntity
Test if this MusicXML entity has the same content as another object.

Overrides:
equals in class MusicXmlEntity
Parameters:
other - The other object.
Returns:
True if both objects have the same content; false otherwise.