org.niffty
Class Staff

java.lang.Object
  |
  +--org.niffty.HeirarchyNode
        |
        +--org.niffty.Staff
All Implemented Interfaces:
Anchored

public class Staff
extends HeirarchyNode
implements Anchored

A Staff encapsulates the staff information of a StaffSystem. A Staff has a StaffHeader, and any number of MeasureStartTimeSlice objects. All event time slices and music symbols in the Staff are within their respective MeasureStartTimeSlice. Strictly speaking, this is slightly different than the NIFF spec where all the time slice and music symbol chunks are on the same "level", but formally dividing up music symbols into their EVENT time slice, and the EVENT time slices into their MEASURE_START time slice makes the data easier to process.


Constructor Summary
Staff(StaffHeader staffHeader)
          Creates a new Staff with the given StaffHeader and an empty MeasureStartTimeSlice list.
 
Method Summary
 void addMeasureStart(MeasureStartTimeSlice measureStart)
          Add the given measure start timeslice to the MeasureStartTimeSlice list.
 void draw(java.awt.Graphics graphics)
           
 int getIndex()
          Return the index of this Staff in the parent's staff list.
 MeasureStartTimeSlice getMeasureStart(int index)
          Return the MeasureStartTimeSlice in the measure start time slice list at the given index.
 int getMeasureStartCount()
          Return the number of measure start time slices in the measure start time slice list.
 Score getParentScore()
          Return the ultimate Score object of which this is a child.
 StaffSystem getParentSystem()
          Return the parent StaffSystem.
 FinalPoint getScreenHotspot()
          Get the hotspot for this object in screen coordinates.
 StaffHeader getStaffHeader()
           
 void invalidate()
          This is automatically called after the object is modified to force this and all child objects to recompute their values when the "get" method is called for the value.
 void print(java.lang.String indent, java.io.PrintStream output)
          This prints the staff including all time slices.
 
Methods inherited from class org.niffty.HeirarchyNode
addChild, getChild, getChildCount, getParentNode, nextInHeirarchy, previousInHeirarchy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Staff

public Staff(StaffHeader staffHeader)
Creates a new Staff with the given StaffHeader and an empty MeasureStartTimeSlice list. The parent pointer will be set when this is added to a StaffSystem.

Parameters:
staffHeader - the header for this Staff
Method Detail

addMeasureStart

public void addMeasureStart(MeasureStartTimeSlice measureStart)
Add the given measure start timeslice to the MeasureStartTimeSlice list. This does not call invalidate(), but you may need to before displaying.

Parameters:
measureStart - the MeasureStartTimeSlice to add. It is an error if this is already the child of an object.
Throws:
HeirarchyException - if the measureStart has already been added as a child to another object.
See Also:
invalidate()

getParentSystem

public StaffSystem getParentSystem()
Return the parent StaffSystem.


getStaffHeader

public StaffHeader getStaffHeader()

getMeasureStartCount

public int getMeasureStartCount()
Return the number of measure start time slices in the measure start time slice list. All event time slices and music symbols in this Staff are contained within their respective MeasureStartTimeSlice object.


getMeasureStart

public MeasureStartTimeSlice getMeasureStart(int index)
Return the MeasureStartTimeSlice in the measure start time slice list at the given index. All event time slices and music symbols in this Staff are contained within their respective MeasureStartTimeSlice object.

Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index is negative or not less than the number of nodes in the child node list.

getIndex

public int getIndex()
Return the index of this Staff in the parent's staff list.

Overrides:
getIndex in class HeirarchyNode
Throws:
HeirarchyException - if this does not have a parent.

invalidate

public void invalidate()
This is automatically called after the object is modified to force this and all child objects to recompute their values when the "get" method is called for the value.


getScreenHotspot

public FinalPoint getScreenHotspot()
Description copied from interface: Anchored
Get the hotspot for this object in screen coordinates.

Specified by:
getScreenHotspot in interface Anchored
Returns:
The position of the hotspot in screen coordinates from top-left of screen (not relative to an anchor). This is a FinalPoint and not a Point so that the class can give access to its screen hotspot object knowing that the caller will not modify it. This is more efficient that returning a new Point every time getScreenHotspot() is called.
See Also:
FinalPoint.newPoint()

getParentScore

public Score getParentScore()
Return the ultimate Score object of which this is a child.


draw

public void draw(java.awt.Graphics graphics)

print

public void print(java.lang.String indent,
                  java.io.PrintStream output)
This prints the staff including all time slices.

Parameters:
indent - A string such as " " to print at the beginning of the line
output - the PrintStream to print to, such as System.out