org.niffty
Class StaffSystem

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

public class StaffSystem
extends HeirarchyNode
implements Anchored

A StaffSystem encapsulates the system information of a Page. A StaffSystem has a StaffSystemHeader, and optional NIFFStaffGrouping, and any number of Staff, NIFFFontSymbol, NIFFCustomGraphicSymbol, NIFFText, or NIFFLine.


Constructor Summary
StaffSystem(StaffSystemHeader systemHeader)
          Creates a new StaffSystem with the given StaffSystemHeader and an empty Staff list.
 
Method Summary
 void addStaff(Staff staff)
          Add the given staff to the Staff list.
 void draw(java.awt.Graphics graphics)
           
 Rational getDuration()
          Return the duration of this staff system.
 int getIndex()
          Return the index of this StaffSystem in the parent's staff system list.
 Page getParentPage()
          Return the parent Page.
 Score getParentScore()
          Return the ultimate Score object of which this is a child.
 FinalPoint getScreenHotspot()
          Get the hotspot for this object in screen coordinates.
 Staff getStaff(int index)
          Return the Staff in the staff list at the given index.
 int getStaffCount()
          Return the number of staves in the staff list.
 Rational getStartTime()
          Return the global start time of this staff system.
 StaffSystemHeader getSystemHeader()
           
 int getWidth()
          Return the width of this staff system.
 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 system including all staves.
 
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

StaffSystem

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

Parameters:
systemHeader - the header for this StaffSystem
Method Detail

addStaff

public void addStaff(Staff staff)
Add the given staff to the Staff list. This does not call invalidate(), but you may need to before displaying.

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

getParentPage

public Page getParentPage()
Return the parent Page.


getSystemHeader

public StaffSystemHeader getSystemHeader()

getStaffCount

public int getStaffCount()
Return the number of staves in the staff list.


getStaff

public Staff getStaff(int index)
Return the Staff in the staff list at the given index.

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 StaffSystem in the parent's staff system 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()

getStartTime

public Rational getStartTime()
Return the global start time of this staff system. This is the start time of the first measure start time slice in the first staff.


getDuration

public Rational getDuration()
Return the duration of this staff system. This is the start time difference between the first and last measure start time slices in the first staff plus the duration of the last measure. (It is assumed that all staves in the staff system have the same duration.) This is used to compute the screen hotspots of the measure starts.


getWidth

public int getWidth()
Return the width of this staff system. Due to staff indentation, this may be different than getParentScore().getStavesWidth().


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 system including all staves.

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