Package com.softsynth.jmsl.score
Class Staff
java.lang.Object
com.softsynth.jmsl.MusicJob
com.softsynth.jmsl.ParallelCollection
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
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
Fields Modifier and Type Field Description 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
Constructors Constructor Description Staff(Measure measure)
Staff(Measure measure, Instrument ins)
-
Method Summary
Modifier and Type Method Description 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.void
addUserBean(java.lang.Object bean)
Add a bean to a Staff.void
closeStaffPropertiesXML(java.io.PrintWriter out)
java.util.Properties
getBoundingInfo()
Clef
getClef()
boolean
getClefSetByHand()
Used to signal the end of a run of clef changes.boolean
getDisplayClef()
boolean
getDisplayKeySignature()
boolean
getDisplayTimeSig()
java.awt.geom.Point2D
getDrawingAnchor()
drawingAnchor is the (x,y) point at top left of drawable object, set by layout manager, changes as measures stretch, compress, realign, etcint
getExtendedLinesAbove()
Additional staff lines above the standard 5int
getExtendedLinesBelow()
Additional staff lines below the standard 5java.lang.String
getHierarchy()
int
getInsertionIndex(java.awt.geom.Point2D p, int trackIndex)
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 staffdouble
getSpaceBelow()
for layout; unscaled space below staffstatic double
getStaffHeight()
for layout; unscaled distance between top and bottom line of staffint
getStaffIndex()
double
getTotalHeight()
Track
getTrack(int n)
java.util.Vector
getUserBeans()
boolean
isMultiTrack()
boolean
isStaffVisible()
void
layoutChildren()
Set the drawingAnchor for each Track equal to the left of the top line of the staff itelfdouble
levelOfTopLine()
void
removeUserBean(java.lang.Object bean)
void
render(java.awt.Graphics g, double zoom)
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 clefvoid
setDisplayKeySignature(boolean flag)
used by layout manager to indicate whether or not this should render and make room for a key sigvoid
setDisplayTimeSig(boolean flag)
used by layout manager to indicate whether or not this should render and make room for a time sigvoid
setDrawingAnchor(java.awt.geom.Point2D p)
drawingAnchor is the (x,y) point at top left of drawable object, set by layout manager, changes as measures stretch, compress, realign, etcvoid
setExtendedLinesAbove(int extendedLinesAbove)
Additional staff lines above the standard 5void
setExtendedLinesBelow(int extendedLinesbelow)
Additional staff lines below the standard 5void
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
setMaxKeySignatureWidthInMeasure(int maxKeySignatureWidthInMeasure)
void
setSpaceAbove(double d)
for layout; set unscaled distance above staffvoid
setSpaceBelow(double d)
for layout; set unscaled distance below staffvoid
setStaffVisible(boolean isStaffVisible)
java.lang.String
toString()
boolean
within(java.awt.Point p)
void
writeStaffPropertiesXML(java.io.PrintWriter out)
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, getRepeatPlayables, getRepeats, getStartDelay, getStartPause, getStartPlayables, getStartTime, getStopDelay, getStopPlayables, 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 Details
-
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 Details
-
Staff
-
Staff
-
-
Method Details
-
getExtendedLinesAbove
public int getExtendedLinesAbove()Additional staff lines above the standard 5- Returns:
- the extendedLinesAbove
-
setExtendedLinesAbove
public void setExtendedLinesAbove(int extendedLinesAbove)Additional staff lines above the standard 5- Parameters:
extendedLinesAbove
- the extendedLinesAbove to set
-
getExtendedLinesBelow
public int getExtendedLinesBelow()Additional staff lines below the standard 5- Returns:
- the extendedLinesbelow
-
setExtendedLinesBelow
public void setExtendedLinesBelow(int extendedLinesbelow)Additional staff lines below the standard 5- Parameters:
extendedLinesbelow
- the extendedLinesbelow to set
-
isStaffVisible
public boolean isStaffVisible()- Returns:
- the isStaffVisible
-
setStaffVisible
public void setStaffVisible(boolean isStaffVisible)- Parameters:
isStaffVisible
- the isStaffVisible to set
-
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
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
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
-
setKeySignature
-
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
- Returns:
- the measure to which this Staff belongs
-
getTrack
- Returns:
- Track at indicated index
-
getScore
- Returns:
- parent score
-
getMaxDuration
public double getMaxDuration() -
setClef
-
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.geom.Point2D 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.geom.Point2D 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 double 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.geom.Point2D p, int trackIndex)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
-
getBoundingInfo
public java.util.Properties getBoundingInfo() -
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 classjava.lang.Object
-
writeXML
public void writeXML(java.io.PrintWriter out) throws java.io.IOException- Specified by:
writeXML
in interfaceXMLWritable
- Throws:
java.io.IOException
-
closeStaffPropertiesXML
public void closeStaffPropertiesXML(java.io.PrintWriter out)- Parameters:
out
-
-
writeStaffPropertiesXML
public void writeStaffPropertiesXML(java.io.PrintWriter out)- Parameters:
out
-
-
getUserBeans
public java.util.Vector getUserBeans() -
addUserBean
public void addUserBean(java.lang.Object bean)Add a bean to a Staff. A bean is an object with primitive fields and matching getters and setters. These will be restored when loaded.- Parameters:
bean
- The bean to add.
-
removeUserBean
public void removeUserBean(java.lang.Object bean) -
setMaxKeySignatureWidthInMeasure
public void setMaxKeySignatureWidthInMeasure(int maxKeySignatureWidthInMeasure)- Parameters:
maxKeySignatureWidthInMeasure
- The maxKeySignatureWidthInMeasure to set.
-