org.niffty
Class MeasureStartTimeSlice

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

public class MeasureStartTimeSlice
extends HeirarchyNode
implements Anchored

A MeasureStartTimeSlice has a start time and optional tags and is always type MEASURE_START. A MeasureStartTimeSlice also stores the EVENT TimeSlice objects following the measure start time slice. Strictly speaking, this is slightly different than the NIFF spec where all the time slice and music symbol chunks are on the same "level" in the Staff, 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.

See Also:
TimeSlice

Constructor Summary
MeasureStartTimeSlice(Rational startTime, Tags tags)
          Creates a new MeasureStartTimeSlice with the given start time and tags, and an empty TimeSlice list.
 
Method Summary
 void addTimeSlice(TimeSlice timeSlice)
          Add the given timeslice to the TimeSlice list.
 void draw(java.awt.Graphics graphics)
           
 Rational getDuration()
          Return the duration of this measure.
 int getIndex()
          Return the index of this measure start time slice in the parent's measure start time slice list.
 Score getParentScore()
          Return the ultimate Score object of which this is a child.
 Staff getParentStaff()
          Return the parent Staff.
 FinalPoint getScreenHotspot()
          Get the hotspot for this object in screen coordinates.
 Rational getStartTime()
          Returns the start time Rational.
 int getSymbolCount()
           
 int getSymbolPosition(Rational startTime)
           
 Tags getTags()
          Returns the Tags object containing the optional tags.
 TimeSlice getTimeSlice(int index)
          Return the event time slice at the given index.
 int getTimeSliceCount()
          Return the number of event time slices in the time slice list.
 int getWidth()
          Return the width of this measure in screen pixels.
 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 time slice including all following music symbols.
 java.lang.String toString()
          This only returns the info for this time slice, not the following music symbols.
 
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, wait, wait, wait
 

Constructor Detail

MeasureStartTimeSlice

public MeasureStartTimeSlice(Rational startTime,
                             Tags tags)
Creates a new MeasureStartTimeSlice with the given start time and tags, and an empty TimeSlice list. The type is MEASURE_START.

Parameters:
startTime - see getStartTime()
tags - the tags for this time slice. If this is null, then this uses an empty Tags object.
Method Detail

addTimeSlice

public void addTimeSlice(TimeSlice timeSlice)
Add the given timeslice to the TimeSlice list. This does not call invalidate(), but you may need to before displaying.

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

getParentStaff

public Staff getParentStaff()
Return the parent Staff.


getParentScore

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


getTags

public Tags getTags()
Returns the Tags object containing the optional tags.


getStartTime

public Rational getStartTime()
Returns the start time Rational. Since this is a measure start time slice, this is the time since the beginning of the score.


getTimeSliceCount

public int getTimeSliceCount()
Return the number of event time slices in the time slice list.


getTimeSlice

public TimeSlice getTimeSlice(int index)
Return the event time slice 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 measure start time slice in the parent's measure start time slice 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.


getDuration

public Rational getDuration()
Return the duration of this measure. If this MeasureStartTimeSlice has a following MeasureStartTimeSlice in the Staff, the duration is the start time difference of this measure start and the following measure start. If no following measure start, the duration of this measure is the start time of the last event TimeSlice. Note that this assumes the last event TimeSlice has zero duration, but this is reasonable since the last event TimeSlice usually just holds a bar line.


getWidth

public int getWidth()
Return the width of this measure in screen pixels. If this MeasureStartTimeSlice has a following MeasureStartTimeSlice in the Staff, the width is the screen hotspot X difference of this measure start and the following measure start. If no following measure start, the width of this measure is the X coordinate difference between the end of the staff and this screen hotspot.


getSymbolCount

public int getSymbolCount()

getSymbolPosition

public int getSymbolPosition(Rational startTime)

getScreenHotspot

public FinalPoint getScreenHotspot()
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()

draw

public void draw(java.awt.Graphics graphics)

toString

public java.lang.String toString()
This only returns the info for this time slice, not the following music symbols.

Overrides:
toString in class java.lang.Object

print

public void print(java.lang.String indent,
                  java.io.PrintStream output)
This prints the time slice including all following music symbols.

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