com.softsynth.jmsl.score
Class Staff

java.lang.Object
  extended by com.softsynth.jmsl.MusicJob
      extended by com.softsynth.jmsl.ParallelCollection
          extended by com.softsynth.jmsl.score.Staff
All Implemented Interfaces:
Composable, Playable, XMLWritable, java.lang.Runnable

public class Staff
extends ParallelCollection
implements XMLWritable

Staff
A Staff is a ParallelCollection of up to any number of Tracks, which get drawn on the same staff, played by the same instrument.
JMSL Notation Project

Author:
Nick Didkovsky, copyright 2000 Nick Didkovsky

Field Summary
static java.lang.String copyright
           
static int DEFAULT_STAFF_SPACE_ABOVE
           
static int DEFAULT_STAFF_SPACE_BELOW
           
static int LEVEL_OF_BOTTOM_LINE
           
static int LEVEL_OF_MIDDLE_LINE
           
static int LEVEL_OF_TOP_LINE
           
static int SPACE_INTERVAL
           
 
Fields inherited from class com.softsynth.jmsl.MusicJob
repeatCount
 
Constructor Summary
Staff(Measure measure)
           
Staff(Measure measure, Instrument ins)
           
 
Method Summary
 void addToSpaceAbove(double delta)
           
 void addToSpaceBelow(double delta)
           
 Track addTrack()
          add a new Track to this staff.
 Track addTrack(Instrument ins)
          add a new Track to this staff, handing it indicated instrument.
 Track getActiveTrack()
           
static int getActiveTrackIndex()
           
 Clef getClef()
           
 boolean getClefSetByHand()
          Used to signal the end of a run of clef changes.
 boolean getDisplayClef()
           
 boolean getDisplayKeySignature()
           
 boolean getDisplayTimeSig()
           
 java.awt.Point getDrawingAnchor()
          drawingAnchor is the (x,y) point at top left of drawable object, set by layout manager, changes as measures stretch, compress, realign, etc
 java.lang.String getHierarchy()
           
 int getInsertionIndex(java.awt.Point p)
          return the index at which a Note is to be inserted, based on location p.
 boolean getInsIndexSetByHand()
           
 int getInstrumentIndex()
           
 KeySignature getKeySignature()
           
 boolean getKeySignatureSetByHand()
          Used to signal the end of a run of clef changes.
 double getMaxDuration()
           
 Measure getMeasure()
           
 int getNearestLevel(java.awt.Point p)
           
 int getNonEmptyTrackCount()
           
 Score getScore()
           
 double getSpaceAbove()
          for layout; unscaled space above staff
 double getSpaceBelow()
          for layout; unscaled space below staff
static double getStaffHeight()
          for layout; unscaled distance between top and bottom line of staff
 int getStaffIndex()
           
 double getTotalHeight()
           
 Track getTrack(int n)
           
 boolean isMultiTrack()
           
 void layoutChildren()
          Set the drawingAnchor for each Track equal to the left of the top line of the staff itelf
 int levelOfTopLine()
           
 void render(java.awt.Graphics g, double zoom)
           
static void setActiveTrackIndex(int trackIndex)
           
 void setClef(Clef clef)
           
 void setClefSetByHand(boolean flag)
          Used to signal the end of a run of clef changes.
 void setDisplayClef(boolean flag)
          /** used by layout manager to indicate whether or not this should render and make room for a clef
 void setDisplayKeySignature(boolean flag)
          used by layout manager to indicate whether or not this should render and make room for a key sig
 void setDisplayTimeSig(boolean flag)
          used by layout manager to indicate whether or not this should render and make room for a time sig
 void setDrawingAnchor(java.awt.Point p)
          drawingAnchor is the (x,y) point at top left of drawable object, set by layout manager, changes as measures stretch, compress, realign, etc
 void setInsIndexSetByHand(boolean f)
           
 void setInstrument()
           
 void setInstrumentIndex(int index)
           
 void setKeySignature(KeySignature ks)
           
 void setKeySignatureSetByHand(boolean flag)
          Used to signal the end of a run of key changes.
 void setSpaceAbove(double d)
          for layout; set unscaled distance above staff
 void setSpaceBelow(double d)
          for layout; set unscaled distance below staff
 java.lang.String toString()
           
 boolean within(java.awt.Point p)
           
 void writeXML(java.io.PrintWriter out)
           
 
Methods inherited from class com.softsynth.jmsl.ParallelCollection
get, halt, internalRepeat, main, print, printHierarchy, set
 
Methods inherited from class com.softsynth.jmsl.MusicJob
add, addPlayLurker, addRepeatPlayable, addStartPlayable, addStopPlayable, advanceCurrentTime, contains, elements, finish, finishAll, getChild, getChildren, getCurrentTime, getDataTranslator, getDuration, getInstrument, getName, getParent, getPlayLurkers, getRepeatCount, getRepeatPause, getRepeats, getStartDelay, getStartPause, getStartTime, getStopDelay, getTimeStretch, getTransposition, indexOf, insert, isRunning, launch, launch, play, play, printHierarchy, remove, remove, removeAll, removeAllPlayLurkers, removeAllRepeatPlayables, removeAllStartPlayables, removeAllStopPlayables, removePlayLurker, removeRepeatPlayable, removeStartPlayable, removeStopPlayable, repeat, run, setCurrentTime, setDataTranslator, setDuration, setInstrument, setName, setParent, setRepeatPause, setRepeats, setStartDelay, setStartPause, setStartTime, setStopDelay, setTimeStretch, setTransposition, size, start, stop, timeStretch, transposition, waitForDone
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SPACE_INTERVAL

public static final int SPACE_INTERVAL
See Also:
Constant Field Values

DEFAULT_STAFF_SPACE_ABOVE

public static final int DEFAULT_STAFF_SPACE_ABOVE
See Also:
Constant Field Values

DEFAULT_STAFF_SPACE_BELOW

public static final int DEFAULT_STAFF_SPACE_BELOW
See Also:
Constant Field Values

LEVEL_OF_MIDDLE_LINE

public static final int LEVEL_OF_MIDDLE_LINE
See Also:
Constant Field Values

LEVEL_OF_TOP_LINE

public static final int LEVEL_OF_TOP_LINE
See Also:
Constant Field Values

LEVEL_OF_BOTTOM_LINE

public static final int LEVEL_OF_BOTTOM_LINE
See Also:
Constant Field Values

copyright

public static final java.lang.String copyright
See Also:
Constant Field Values
Constructor Detail

Staff

public Staff(Measure measure)

Staff

public Staff(Measure measure,
             Instrument ins)
Method Detail

getStaffIndex

public int getStaffIndex()

setInstrumentIndex

public void setInstrumentIndex(int index)

getInstrumentIndex

public int getInstrumentIndex()

setInstrument

public void setInstrument()

setClefSetByHand

public void setClefSetByHand(boolean flag)
Used to signal the end of a run of clef changes.


addTrack

public Track addTrack()
add a new Track to this staff. Staff has two tracks when constructed, so only call this if you want 3 or more tracks on a staff

Returns:
the new track

addTrack

public Track addTrack(Instrument ins)
add a new Track to this staff, handing it indicated instrument. Staff has two tracks when constructed, so only call this if you want 3 or more tracks on a staff

Returns:
the new track

getClefSetByHand

public boolean getClefSetByHand()
Used to signal the end of a run of clef changes. Ex. If user sets clef of measure 10 to bass, then changes clef of measure 7 to alto, measures 7, 8, and 9 will change to alto, stopping at 10 which was manally changed.


setKeySignatureSetByHand

public void setKeySignatureSetByHand(boolean flag)
Used to signal the end of a run of key changes. If true for a staff in measure n, then changing a keysignature in measures less than n will not affect the keysig measure n or measures later than n


getKeySignatureSetByHand

public boolean getKeySignatureSetByHand()
Used to signal the end of a run of clef changes. If true for a staff in measure n, then changing a keysignature in measures less than n will not affect measure n or measures later than n


getInsIndexSetByHand

public boolean getInsIndexSetByHand()

setInsIndexSetByHand

public void setInsIndexSetByHand(boolean f)

getKeySignature

public KeySignature getKeySignature()

setKeySignature

public void setKeySignature(KeySignature ks)

setDisplayClef

public void setDisplayClef(boolean flag)
/** used by layout manager to indicate whether or not this should render and make room for a clef


getDisplayClef

public boolean getDisplayClef()
Returns:
whether or not this should render and make room for a clef

setDisplayTimeSig

public void setDisplayTimeSig(boolean flag)
used by layout manager to indicate whether or not this should render and make room for a time sig


getDisplayTimeSig

public boolean getDisplayTimeSig()
Returns:
whether or not this should render and make room for a time sig

setDisplayKeySignature

public void setDisplayKeySignature(boolean flag)
used by layout manager to indicate whether or not this should render and make room for a key sig


getDisplayKeySignature

public boolean getDisplayKeySignature()
Returns:
whether or not this should render and make room for a key sig

isMultiTrack

public boolean isMultiTrack()
Returns:
true if this staff holds more than one non-empty track. (ie NOT just a synonym for size() > 1)

getNonEmptyTrackCount

public int getNonEmptyTrackCount()
Returns:
number of non-empty tracks contained in this staff (ie NOT just a synonym for size())

getMeasure

public Measure getMeasure()
Returns:
the measure to which this Staff belongs

getTrack

public Track getTrack(int n)
Returns:
Track at indicated index

getActiveTrack

public Track getActiveTrack()
Returns:
Track selected for editing. Determinded by static activeTrackIndex

setActiveTrackIndex

public static void setActiveTrackIndex(int trackIndex)

getActiveTrackIndex

public static int getActiveTrackIndex()

getScore

public Score getScore()
Returns:
parent score

getMaxDuration

public double getMaxDuration()

setClef

public void setClef(Clef clef)

getClef

public Clef getClef()

getSpaceAbove

public double getSpaceAbove()
for layout; unscaled space above staff


getSpaceBelow

public double getSpaceBelow()
for layout; unscaled space below staff


getStaffHeight

public static double getStaffHeight()
for layout; unscaled distance between top and bottom line of staff


getTotalHeight

public double getTotalHeight()
Returns:
sum of space above, below, and the staff itself

setSpaceAbove

public void setSpaceAbove(double d)
for layout; set unscaled distance above staff


setSpaceBelow

public void setSpaceBelow(double d)
for layout; set unscaled distance below staff


addToSpaceAbove

public void addToSpaceAbove(double delta)

addToSpaceBelow

public void addToSpaceBelow(double delta)

setDrawingAnchor

public void setDrawingAnchor(java.awt.Point p)
drawingAnchor is the (x,y) point at top left of drawable object, set by layout manager, changes as measures stretch, compress, realign, etc


getDrawingAnchor

public java.awt.Point getDrawingAnchor()
drawingAnchor is the (x,y) point at top left of drawable object, set by layout manager, changes as measures stretch, compress, realign, etc


layoutChildren

public void layoutChildren()
Set the drawingAnchor for each Track equal to the left of the top line of the staff itelf


levelOfTopLine

public int levelOfTopLine()
Returns:
y position of top line of Staff

within

public boolean within(java.awt.Point p)
Returns:
true if point is within bounding box of this staff

getInsertionIndex

public int getInsertionIndex(java.awt.Point p)
return the index at which a Note is to be inserted, based on location p. 0 if before first element (ie become element 0 and push the rest up as a Java Vector insert is implemented). Selects based on active track.


getNearestLevel

public int getNearestLevel(java.awt.Point p)
Returns:
the level nearest to the Point.y

render

public void render(java.awt.Graphics g,
                   double zoom)

getHierarchy

public java.lang.String getHierarchy()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

writeXML

public void writeXML(java.io.PrintWriter out)
              throws java.io.IOException
Specified by:
writeXML in interface XMLWritable
Throws:
java.io.IOException