use of com.xenoage.zong.musicxml.types.MxlStem in project Zong by Xenoage.
the class StemReader method read.
/**
* Reads and returns the stem of the given chord.
* If not available, {@link Stem#defaultStem} is returned.
* @param context the global context
* @param chord the chord, whose notes are already collected
* @param staff the staff index of the current chord
*/
public Stem read(Context context, Chord chord, int staff) {
if (mxlStem == null)
return Companion.getDefaultStem();
// direction
StemDirection direction = readStemDirection();
// length
Float length = null;
MxlPosition yPos = mxlStem.getPosition();
if (yPos.getDefaultY() != null) {
// convert position in tenths relative to topmost staff line into
// a length in interline spaces measured from the outermost chord note on stem side
float stemEndLinePosition = convertDefaultYToLP(context, yPos.getDefaultY(), staff);
VSide side = (direction == StemDirection.Up ? VSide.Top : VSide.Bottom);
length = Math.abs(stemEndLinePosition - getOuterNoteLp(context, chord, side, staff)) / 2;
}
// create stem
return new Stem(direction, length);
}
Aggregations